Sync from openai/math@faee2cf485a8 (part 9)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveProjectionBounds.lean+124-124
- lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveRecordBounds.lean+102-102
- lean/OAI/Combinatorics/HadwigerCounterexample/AdditionalProbeBounds.lean+171-171
- lean/OAI/Combinatorics/HadwigerCounterexample/AffineFrames.lean+195-195
- lean/OAI/Combinatorics/HadwigerCounterexample/AggregateCostBounds.lean+124-124
- lean/OAI/Combinatorics/HadwigerCounterexample/AmbientBatchSlots.lean+211-211
- lean/OAI/Combinatorics/HadwigerCounterexample/AnalyticParameters.lean+143-143
- lean/OAI/Combinatorics/HadwigerCounterexample/AtomFlavors.lean+148-148
- lean/OAI/Combinatorics/HadwigerCounterexample/AttackCutDecomposition.lean+277-277
- lean/OAI/Combinatorics/HadwigerCounterexample/BaselineExtension.lean+124-124
- lean/OAI/Combinatorics/HadwigerCounterexample/BaselineForms.lean+147-147
- lean/OAI/Combinatorics/HadwigerCounterexample/BasisConditioning.lean+113-113
- lean/OAI/Combinatorics/HadwigerCounterexample/BatchCharacters.lean+153-153
- lean/OAI/Combinatorics/HadwigerCounterexample/BiasedRotationBounds.lean+142-142
- lean/OAI/Combinatorics/HadwigerCounterexample/BilinearBlockCorrelation.lean+107-107
- lean/OAI/Combinatorics/HadwigerCounterexample/BilinearCompression.lean+126-126
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryEvaluationForms.lean+174-174
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMatrices.lean+125-125
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMixingBounds.lean+106-106
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryPrescriptions.lean+265-265
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryStatusComparison.lean+143-143
- lean/OAI/Combinatorics/HadwigerCounterexample/BooleanLabels.lean+151-151
- lean/OAI/Combinatorics/HadwigerCounterexample/BoundedQueryTemplates.lean+134-134
- lean/OAI/Combinatorics/HadwigerCounterexample/CellPositivityScales.lean+177-177
- lean/OAI/Combinatorics/HadwigerCounterexample/CellPruning.lean+128-128
- lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFactorization.lean+144-144
- lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFrameLaws.lean+186-186
- lean/OAI/Combinatorics/HadwigerCounterexample/CollisionInequality.lean+204-204
- lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitionRefinement.lean+79-79
- lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitions.lean+119-119
- lean/OAI/Combinatorics/HadwigerCounterexample/CommonPredictions.lean+112-112
- lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleOptionRealization.lean+130-130
- lean/OAI/Combinatorics/HadwigerCounterexample/CompatiblePairTests.lean+105-105
- lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleTableEvents.lean+149-149
- lean/OAI/Combinatorics/HadwigerCounterexample/ComponentIndices.lean+115-115
- lean/OAI/Combinatorics/HadwigerCounterexample/ConcentrationScales.lean+169-169
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalCellEntropy.lean+156-156
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFlags.lean+107-107
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFourCorners.lean+101-101
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalLargeSetHits.lean+106-106
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProductLaws.lean+125-125
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProjection.lean+96-96
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalSignaturePositivity.lean+110-110
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedBatchLaws.lean+198-198
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedCorrelations.lean+97-97
- lean/OAI/Combinatorics/HadwigerCounterexample/ConstructionScales.lean+100-100
- lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateBlocks.lean+147-147
- lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateDuality.lean+87-87
- lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateEmbeddings.lean+163-163
- lean/OAI/Combinatorics/HadwigerCounterexample/CoverAlternatives.lean+86-86
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import OAI.Combinatorics.HadwigerCounterexample.KeyProjectionBoundsnamespace OAI/-! # Adaptive Projection Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrixopen scoped BigOperators Topologyopen Templatenamespace StatusAnalysisvariable {p:Shape} {n N K M r z s0:ℕ} {q:Format} {d e:Rates} {b:Bool}private theorem avg_side_bounds {A : Type} [Fintype A] (w : Wgt A) (hw:IsLaw w)(b:Bool) (f : Wgt A) (F:A×A→ℝ) (h:∀ i,F i≤f (onSide i b)) :avg (pairW w w) F≤avg w f := byapply (avg_mono (pairW_law hw hw).nz h).transcases b· rw [pairW_avg]simp [onSide,hw.avg_const]rw [pairW_avg]; simp only [onSide,ite_true,hw.avg_const]; rflnamespace Quillvariable (w:Quill p q d b)(m:Mixer p n) (t:Tagging p (Messenger q)) (φ:Messenger q→F)(u:LeafMixture p n N) (Y:Silhouette p N r)set_option maxHeartbeats 1200000 intheorem oneTrestle (omega_:Wgt u.T) (hv:IsLaw omega_) (s:u.T→ Charts p n d)(μ:u.T→Wgt (UnitType p n N)) (hμ:∀ i,IsLaw (μ i))(P : Keys (p:=p) t N→ Fin z) (F:u.T×u.T → UnitType p n N→Prop)(hF : ∀ i o,F i o→PreparationParameters.frameSide p m o)(hw:∀ i,IsLaw (w.policies t φ n i)) (hν:IsLaw (lawNu p N t φ))(ε v A B:ℝ) (he:0≤ε)(ha:∀ i:Fin z,pr (mixW omega_ μ) (w.flunk t φ Y (fun x=>ind (P x=i)) m v ε) ≤ A)(hh: pr (mixW omega_ μ) (fun x=>¬ w.matchesArea t φ Y x v)≤B) :let L (i:u.T×u.T):=onSide i bavg (pairW omega_ omega_) (fun i=>varOne (mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P)(mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P)) ≤ z*(ε+2*(A+B)) := byclassicalintro Llet Q (i:u.T×u.T) (x:Fin z):=|mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P x-mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P x|let V:= pairW omega_ omega_have h (x : Fin z) :avg V (fun i=>Q i x) ≤ ε+ 2*(A+B) := bylet H k:= P k=xlet R:= w.flunk t φ Y (fun i=>ind (H i)) m v εlet Z (i:UnitType p n N):= ¬ w.matchesArea t φ Y i vlet S o:=R o∨ Z ohave heq (i): Q i x≤ ε+2*pr (μ (L i)) S := byrefine w.display_test t φ (μ (L i)) (F i) m (s (L i)) Y H (hμ _) hw hν S he(fun y hy hz=> ?_)by_cases hf :Z y· exact Or.inr hfexact Or.inl ⟨hF _ _ hy,not_not.mp hf,s (L i),hz⟩let U:=mixW omega_ μhave hu : IsLaw U:=mixW_law hv hμhave hm (o) : avg omega_ (fun i=>pr (μ i) o)= pr U o := (mixW_avg ..).symmapply (avg_side_bounds omega_ hv b (fun i=>ε+2*pr (μ i) S) _ heq).transrw [avg_add,avg_mul',hm,hv.avg_const]exact add_le_add_right (mul_le_mul_of_nonneg_left ((pr_or_le hu.nz).trans(add_le_add (ha _) hh)) (by norm_num)) _change avg V (fun x=> ∑ i,Q x i) ≤ _rw [avg_sum]; exact (Finset.sum_le_sum fun i _=> h i).trans_eq (by simp; ring)end Quillopen Station PreparationParametersnamespace Stationvariable {w:LeafMixture p n N} (t:Station p n N K w)(x:Typus p q d e) (m:Mixer p n) (k: Fin (2^deckMax p K))(μ:Wgt (UnitType p n N)) (Y:Silhouette p N r)theorem gauzed_area (Y:Silhouette p N r) (w : Quill p q d b)(t: Tagging p (Messenger q)) (u : Messenger q → F)(h:w.moral t u) (δ:ℝ){K : ℕ} {m:Mixer p n} {ε v:ℝ} (he:ε≤v)(o : UnitType p n N) (hc:gauze p ε δ Y m K o) :w.matchesArea t u Y o v := byintro i; have heq := w.allure_apt t u h iexact ((hc _ (w.allure t u i)).1 heq).trans heset_option maxHeartbeats 1200000 intheorem projectSum (P : Keys (p:=p) x.t N→Fin z)(h :apart w.T) (hm:IsLaw μ) (hw :∀ i∈w.T,0<partMass μ i) (hs : 0<w.amount μ)(ha : ∀ i,IsLaw (x.qA.policies x.t x.z n i)) (hb:∀ i,IsLaw (x.qB.policies x.t x.z n i))(hν : IsLaw (lawNu p N x.t x.z)) (ε v v' τ B δ : ℝ) (he:0≤ε)(hf : x.permission)(ht : τ ≤ v ∧ τ≤v')(hh : pr (w.sap μ) (fun i=>¬gauze p τ δ Y m K i)≤B)(hx : ∀ i:Fin z,pr (w.sap μ) (x.qA.flunk x.t x.z Y (fun y=>ind (P y=i)) m v ε)≤B)(hy : ∀ i:Fin z,pr (w.sap μ) (x.qB.flunk x.t x.z Y (fun y=>ind (P y=i)) m v' ε)≤B) :t.due x m μ k Y P≤2*(z*(ε+2*(B+B))) := byclassicalobtain ⟨hp,hq⟩:=rebuild hm.nz h hw hslet A (i:w.T):=partW μ i.vallet u:=portionW μ w.Thave hQ : w.sap μ=mixW u A :=hqlet V:=pairW u u; have hA i:IsLaw (A i):=on_law hm.nz (hw i.val i.property)have hL : avg V (fun i=> taxLeft t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := byrefine x.qA.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i d) A hA P(fun i=> t.frontPage x m i.1 i.2 k) (fun i o h => h.2.2.1) ha hν ε v B B he(fun i=>by rw [←hQ]; exact hx i) ?_rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hhexact fun i hi h=> hi (gauzed_area _ _ _ _ hf.2.1 δ ht.1 i h)have hR : avg V (fun i=> taxRight t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := byrefine x.qB.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i e) A hA P(fun i=> t.backPage x m i.1 i.2 k) (fun i o h => h.2.2.1) hb hν ε v' B B he(fun i=>by rw [←hQ]; exact hy i) ?_rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hhexact fun i hi h=>hi (gauzed_area _ _ _ _ hf.2.2.1 δ ht.2 i h)unfold due; rw [avg_add,two_mul]exact add_le_add hL hRend Stationend StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import OAI.Combinatorics.HadwigerCounterexample.KeyProjectionBoundsnamespace OAI/-! # Adaptive Projection Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrixopen scoped BigOperators Topologyopen Templatenamespace StatusAnalysisvariable {p:Shape} {n N K M r z s0:ℕ} {q:Format} {d e:Rates} {b:Bool}private theorem avg_side_bounds {A : Type} [Fintype A] (w : Wgt A) (hw:IsLaw w)(b:Bool) (f : Wgt A) (F:A×A→ℝ) (h:∀ i,F i≤f (onSide i b)) :avg (pairW w w) F≤avg w f := byapply (avg_mono (pairW_law hw hw).nz h).transcases b· rw [pairW_avg]simp [onSide,hw.avg_const]rw [pairW_avg]; simp only [onSide,ite_true,hw.avg_const]; rflnamespace Quillvariable (w:Quill p q d b)(m:Mixer p n) (t:Tagging p (Messenger q)) (φ:Messenger q→F)(u:LeafMixture p n N) (Y:Silhouette p N r)set_option maxHeartbeats 1200000 intheorem oneTrestle (omega_:Wgt u.T) (hv:IsLaw omega_) (s:u.T→ Charts p n d)(μ:u.T→Wgt (UnitType p n N)) (hμ:∀ i,IsLaw (μ i))(P : Keys (p:=p) t N→ Fin z) (F:u.T×u.T → UnitType p n N→Prop)(hF : ∀ i o,F i o→PreparationParameters.frameSide p m o)(hw:∀ i,IsLaw (w.policies t φ n i)) (hν:IsLaw (lawNu p N t φ))(ε v A B:ℝ) (he:0≤ε)(ha:∀ i:Fin z,pr (mixW omega_ μ) (w.flunk t φ Y (fun x=>ind (P x=i)) m v ε) ≤ A)(hh: pr (mixW omega_ μ) (fun x=>¬ w.matchesArea t φ Y x v)≤B) :let L (i:u.T×u.T):=onSide i bavg (pairW omega_ omega_) (fun i=>varOne (mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P)(mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P)) ≤ z*(ε+2*(A+B)) := byclassicalintro Llet Q (i:u.T×u.T) (x:Fin z):=|mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P x-mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P x|let V:= pairW omega_ omega_have h (x : Fin z) :avg V (fun i=>Q i x) ≤ ε+ 2*(A+B) := bylet H k:= P k=xlet R:= w.flunk t φ Y (fun i=>ind (H i)) m v εlet Z (i:UnitType p n N):= ¬ w.matchesArea t φ Y i vlet S o:=R o∨ Z ohave heq (i): Q i x≤ ε+2*pr (μ (L i)) S := byrefine w.display_test t φ (μ (L i)) (F i) m (s (L i)) Y H (hμ _) hw hν S he(fun y hy hz=> ?_)by_cases hf :Z y· exact Or.inr hfexact Or.inl ⟨hF _ _ hy,not_not.mp hf,s (L i),hz⟩let U:=mixW omega_ μhave hu : IsLaw U:=mixW_law hv hμhave hm (o) : avg omega_ (fun i=>pr (μ i) o)= pr U o := (mixW_avg ..).symmapply (avg_side_bounds omega_ hv b (fun i=>ε+2*pr (μ i) S) _ heq).transrw [avg_add,avg_mul',hm,hv.avg_const]exact add_le_add_right (mul_le_mul_of_nonneg_left ((pr_or_le hu.nz).trans(add_le_add (ha _) hh)) (by norm_num)) _change avg V (fun x=> ∑ i,Q x i) ≤ _rw [avg_sum]; exact (Finset.sum_le_sum fun i _=> h i).trans_eq (by simp; ring)end Quillopen Station PreparationParametersnamespace Stationvariable {w:LeafMixture p n N} (t:Station p n N K w)(x:Typus p q d e) (m:Mixer p n) (k: Fin (2^deckMax p K))(μ:Wgt (UnitType p n N)) (Y:Silhouette p N r)theorem gauzed_area (Y:Silhouette p N r) (w : Quill p q d b)(t: Tagging p (Messenger q)) (u : Messenger q → F)(h:w.moral t u) (δ:ℝ){K : ℕ} {m:Mixer p n} {ε v:ℝ} (he:ε≤v)(o : UnitType p n N) (hc:gauze p ε δ Y m K o) :w.matchesArea t u Y o v := byintro i; have heq := w.allure_apt t u h iexact ((hc _ (w.allure t u i)).1 heq).trans heset_option maxHeartbeats 1200000 intheorem projectSum (P : Keys (p:=p) x.t N→Fin z)(h :apart w.T) (hm:IsLaw μ) (hw :∀ i∈w.T,0<partMass μ i) (hs : 0<w.amount μ)(ha : ∀ i,IsLaw (x.qA.policies x.t x.z n i)) (hb:∀ i,IsLaw (x.qB.policies x.t x.z n i))(hν : IsLaw (lawNu p N x.t x.z)) (ε v v' τ B δ : ℝ) (he:0≤ε)(hf : x.permission)(ht : τ ≤ v ∧ τ≤v')(hh : pr (w.sap μ) (fun i=>¬gauze p τ δ Y m K i)≤B)(hx : ∀ i:Fin z,pr (w.sap μ) (x.qA.flunk x.t x.z Y (fun y=>ind (P y=i)) m v ε)≤B)(hy : ∀ i:Fin z,pr (w.sap μ) (x.qB.flunk x.t x.z Y (fun y=>ind (P y=i)) m v' ε)≤B) :t.due x m μ k Y P≤2*(z*(ε+2*(B+B))) := byclassicalobtain ⟨hp,hq⟩:=rebuild hm.nz h hw hslet A (i:w.T):=partW μ i.vallet u:=portionW μ w.Thave hQ : w.sap μ=mixW u A :=hqlet V:=pairW u u; have hA i:IsLaw (A i):=on_law hm.nz (hw i.val i.property)have hL : avg V (fun i=> taxLeft t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := byrefine x.qA.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i d) A hA P(fun i=> t.frontPage x m i.1 i.2 k) (fun i o h => h.2.2.1) ha hν ε v B B he(fun i=>by rw [←hQ]; exact hx i) ?_rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hhexact fun i hi h=> hi (gauzed_area _ _ _ _ hf.2.1 δ ht.1 i h)have hR : avg V (fun i=> taxRight t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := byrefine x.qB.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i e) A hA P(fun i=> t.backPage x m i.1 i.2 k) (fun i o h => h.2.2.1) hb hν ε v' B B he(fun i=>by rw [←hQ]; exact hy i) ?_rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hhexact fun i hi h=>hi (gauzed_area _ _ _ _ hf.2.2.1 δ ht.2 i h)unfold due; rw [avg_add,two_mul]exact add_le_add hL hRend Stationend StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102import OAI.Combinatorics.HadwigerCounterexample.IndependentTestWitnessesnamespace OAI/-! # Adaptive Record Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Module Submodule Function Finsetopen scoped BigOperatorsvariable {p : Shape} {n N r : ℕ} {T : Cov p N}def quest (p : Shape) (r k n N : ℕ) (H ε : ℝ) :=∀ x : ℕ,x≤2*r →bp ((x:ℝ)*N)*bp (0.51*k*N)*(H*heatRate p n N ε x k)≤bp (-0.2*N)namespace Bazaarvariable (s : Bazaar p n r T)set_option maxHeartbeats 800000 inprivate theorem probe_event {w : Wgt (UnitType p n N)} {Δ}(hw : IsLaw w) (h : s.opened Δ w)(S : Party) (j : Bool) (hi : S j=1) {k : ℕ}{q : Place p→ℕ} (R : DTuple (p:=p) q N) (F : Catalog p T r q)(hq : ctot p q=k) (hr : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))(m : Mixer p n) {ε H : ℝ} (he₀ : initCap p N m ε) (hH : 0≤H) (hZ : quest p r k n N H ε)(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)(hT : num (Atlas p r T) ≤ bp (0.002*N)) :pr w (fun x => s.atList S j R F x ∧ glimpse p x j R) ≤ bp (-0.1*N) := byclassicallet P (M : Atlas p r T) (z : Batch M N) (v : DTuple (p:=p) q N) :=fun x => basisFrom p (x : UnitType p n N) j z ∧ glimpse p x j R ∧ thermal p x S R=vlet L (M : Atlas p r T) (x) := standard M ∧ ∃ z,∃ v∈ F M z,P M z v xhave he x : w x≠0 → s.atList S j R F x ∧ glimpse p x j R →∃ M,L M x := byrintro hx ⟨hx',hy⟩exact ⟨s.ix x,(h x hx).1,s.bag (s.ix x) j x, thermal p x S R,hx',((h x hx).2 j).1,hy,rfl⟩have ht (M : Atlas p r T) : pr w (L M) ≤ bp (-0.2*N) := byby_cases hu : standard M· let x := cells Mhave hb (z : Batch M N) :pr w (fun y => ∃ v∈F M z,P M z v y) ≤ bp (0.51*k*N)*(H*heatRate p n N ε x k) := byhave ha v : pr w (P M z v) ≤ H*heatRate p n N ε x k := byrw [← hq]; exact (pr_cap hg _).trans(mul_le_mul_of_nonneg_left (heat_rate _ S hi R v z m he₀) hH)refine (pr_union_le hw.nz (F M z) (P M z)).trans ((Finset.sum_le_sum fun v _ => ha v).trans ?_)rw [Finset.sum_const,nsmul_eq_mul]apply mul_le_mul_of_nonneg_right (hr M z)unfold heatRateexact mul_nonneg hH (mul_nonneg (bp_pos _).le (bp_pos _).le)simp only [L,hu,true_and]refine (pr_exists_le hw.nz (fun z y => ∃ v∈F M z,P M z v y)).trans((Finset.sum_le_sum (fun z _ => hb z)).trans ?_)simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_space]rw [show dim (Batch M N)=x*N from tuple_dim.trans (Nat.mul_comm ..),Nat.cast_mul, ← mul_assoc]exact hZ x hu.2.1simp only [L,hu,false_and,pr_false]exact (bp_pos _).lerefine ((pr_on_mono hw.nz he).trans (pr_exists_le hw.nz L)).trans((Finset.sum_le_sum fun i _ => ht i).trans ?_)rw [Finset.sum_const,nsmul_eq_mul]apply (mul_le_mul_of_nonneg_right hT (bp_pos _).le).transrw [←bp_add]apply bp_le; linarith [(Nat.cast_nonneg N : 0≤(N:ℝ))]set_option maxHeartbeats 600000 intheorem frequent_sparse {w : Wgt (UnitType p n N)} {Δ}(hw : IsLaw w) (h : s.opened Δ w)(S : Party) (j : Bool) (hi : S j=1)(k d : ℕ) (hh : k ≤ d) (l : ℝ) (hl : 0< l)(hC : ∀ C : Cov p N,cdim p C≤d → pr w (fun x => offsetCov (s.ix x) ≤ C) ≤ l)(hb : ∀ A M Z,(↑(s.bids w S j A M Z).card:ℝ) ≤ bp (0.51*N))(m : Mixer p n) {ε H L : ℝ} (hN : 2*num (Full p n)-N≤ -1)(he : initCap p N m ε)(hH : 0≤H) (hZ : quest p r k n N H ε)(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)(hL : 0 ≤ L) (hv : bySide p w m L)(hT : num (Atlas p r T) ≤ bp (0.002*N))(hk : glimpsesBill p k L+bp (-0.1*N)<l^(k+1)) :pr (pairW w w) (fun x => s.frequent w S j (s.ix x.1) (s.ix x.2) x.2) ≤5*l := byclassicalby_contra! hrobtain ⟨q,R,F,hq,hR,hF,hx⟩ := s.shooting hw S j k d hh l hl hr.le hC hbhave hp := s.probe_event hw h S j hi R F hq hF m he hH hZ hg hThave hq' z : q z≤ k := hq ▸ Finset.single_le_sum (fun i _ => Nat.zero_le (q i))(Finset.mem_univ z)have hu := glimpse_failure m hL hv hw.sub j hN R k hR hq'let T := fun (x : UnitType p n N) => glimpse p x j Rlet V := s.atList S j R Fhave hh' x : V x → ¬T x ∨ (V x ∧ T x) := fun h => by by_cases ht:T x <;> simp [ht,h]exact not_lt_of_ge(hx.trans ((pr_mono hw.nz hh').trans ((pr_or_le hw.nz).trans (add_le_add hu hp)))) hkend Bazaarend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102import OAI.Combinatorics.HadwigerCounterexample.IndependentTestWitnessesnamespace OAI/-! # Adaptive Record Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Module Submodule Function Finsetopen scoped BigOperatorsvariable {p : Shape} {n N r : ℕ} {T : Cov p N}def quest (p : Shape) (r k n N : ℕ) (H ε : ℝ) :=∀ x : ℕ,x≤2*r →bp ((x:ℝ)*N)*bp (0.51*k*N)*(H*heatRate p n N ε x k)≤bp (-0.2*N)namespace Bazaarvariable (s : Bazaar p n r T)set_option maxHeartbeats 800000 inprivate theorem probe_event {w : Wgt (UnitType p n N)} {Δ}(hw : IsLaw w) (h : s.opened Δ w)(S : Party) (j : Bool) (hi : S j=1) {k : ℕ}{q : Place p→ℕ} (R : DTuple (p:=p) q N) (F : Catalog p T r q)(hq : ctot p q=k) (hr : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))(m : Mixer p n) {ε H : ℝ} (he₀ : initCap p N m ε) (hH : 0≤H) (hZ : quest p r k n N H ε)(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)(hT : num (Atlas p r T) ≤ bp (0.002*N)) :pr w (fun x => s.atList S j R F x ∧ glimpse p x j R) ≤ bp (-0.1*N) := byclassicallet P (M : Atlas p r T) (z : Batch M N) (v : DTuple (p:=p) q N) :=fun x => basisFrom p (x : UnitType p n N) j z ∧ glimpse p x j R ∧ thermal p x S R=vlet L (M : Atlas p r T) (x) := standard M ∧ ∃ z,∃ v∈ F M z,P M z v xhave he x : w x≠0 → s.atList S j R F x ∧ glimpse p x j R →∃ M,L M x := byrintro hx ⟨hx',hy⟩exact ⟨s.ix x,(h x hx).1,s.bag (s.ix x) j x, thermal p x S R,hx',((h x hx).2 j).1,hy,rfl⟩have ht (M : Atlas p r T) : pr w (L M) ≤ bp (-0.2*N) := byby_cases hu : standard M· let x := cells Mhave hb (z : Batch M N) :pr w (fun y => ∃ v∈F M z,P M z v y) ≤ bp (0.51*k*N)*(H*heatRate p n N ε x k) := byhave ha v : pr w (P M z v) ≤ H*heatRate p n N ε x k := byrw [← hq]; exact (pr_cap hg _).trans(mul_le_mul_of_nonneg_left (heat_rate _ S hi R v z m he₀) hH)refine (pr_union_le hw.nz (F M z) (P M z)).trans ((Finset.sum_le_sum fun v _ => ha v).trans ?_)rw [Finset.sum_const,nsmul_eq_mul]apply mul_le_mul_of_nonneg_right (hr M z)unfold heatRateexact mul_nonneg hH (mul_nonneg (bp_pos _).le (bp_pos _).le)simp only [L,hu,true_and]refine (pr_exists_le hw.nz (fun z y => ∃ v∈F M z,P M z v y)).trans((Finset.sum_le_sum (fun z _ => hb z)).trans ?_)simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_space]rw [show dim (Batch M N)=x*N from tuple_dim.trans (Nat.mul_comm ..),Nat.cast_mul, ← mul_assoc]exact hZ x hu.2.1simp only [L,hu,false_and,pr_false]exact (bp_pos _).lerefine ((pr_on_mono hw.nz he).trans (pr_exists_le hw.nz L)).trans((Finset.sum_le_sum fun i _ => ht i).trans ?_)rw [Finset.sum_const,nsmul_eq_mul]apply (mul_le_mul_of_nonneg_right hT (bp_pos _).le).transrw [←bp_add]apply bp_le; linarith [(Nat.cast_nonneg N : 0≤(N:ℝ))]set_option maxHeartbeats 600000 intheorem frequent_sparse {w : Wgt (UnitType p n N)} {Δ}(hw : IsLaw w) (h : s.opened Δ w)(S : Party) (j : Bool) (hi : S j=1)(k d : ℕ) (hh : k ≤ d) (l : ℝ) (hl : 0< l)(hC : ∀ C : Cov p N,cdim p C≤d → pr w (fun x => offsetCov (s.ix x) ≤ C) ≤ l)(hb : ∀ A M Z,(↑(s.bids w S j A M Z).card:ℝ) ≤ bp (0.51*N))(m : Mixer p n) {ε H L : ℝ} (hN : 2*num (Full p n)-N≤ -1)(he : initCap p N m ε)(hH : 0≤H) (hZ : quest p r k n N H ε)(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)(hL : 0 ≤ L) (hv : bySide p w m L)(hT : num (Atlas p r T) ≤ bp (0.002*N))(hk : glimpsesBill p k L+bp (-0.1*N)<l^(k+1)) :pr (pairW w w) (fun x => s.frequent w S j (s.ix x.1) (s.ix x.2) x.2) ≤5*l := byclassicalby_contra! hrobtain ⟨q,R,F,hq,hR,hF,hx⟩ := s.shooting hw S j k d hh l hl hr.le hC hbhave hp := s.probe_event hw h S j hi R F hq hF m he hH hZ hg hThave hq' z : q z≤ k := hq ▸ Finset.single_le_sum (fun i _ => Nat.zero_le (q i))(Finset.mem_univ z)have hu := glimpse_failure m hL hv hw.sub j hN R k hR hq'let T := fun (x : UnitType p n N) => glimpse p x j Rlet V := s.atList S j R Fhave hh' x : V x → ¬T x ∨ (V x ∧ T x) := fun h => by by_cases ht:T x <;> simp [ht,h]exact not_lt_of_ge(hx.trans ((pr_mono hw.nz hh').trans ((pr_or_le hw.nz).trans (add_le_add hu hp)))) hkend Bazaarend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171import OAI.Combinatorics.HadwigerCounterexample.SingletonPhaseTestsnamespace OAI/-! # Additional Probe Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module Submodule Function Finsetopen scoped BigOperatorsvariable {I J K : Type} [Fintype I] [Fintype J] [Fintype K]private def moreMatrix {r : ℕ} (A : Mat I (Fin r)) (v : Vec I) : Mat I (Fin (r+1)) :=Matrix.of (fun i => Fin.cons (v i) (A i))omit [Fintype I] inprivate theorem moreMatrix_act {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)(x : Vec (Fin (r+1))) :moreMatrix A v *ᵥ x=x 0 • v + A *ᵥ (fun i => x i.succ) := byfunext i; simp only [Matrix.mulVec,dotProduct,moreMatrix,Matrix.of_apply,Fin.sum_univ_succ,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Fin.cons_zero,Fin.cons_succ]congr 1; exact mul_comm _ _omit [Fintype I] inprivate theorem moreMatrix_inj {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)(ha : Injective A.mulVec) (h : v∉colSp A) :Injective (moreMatrix A v).mulVec := byrw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]intro x hxrw [moreMatrix_act] at hxlet b (i : Fin r) := x i.succrcases bit_cases (x 0) with he|he· have hh : b=0 := byapply harw [he,zero_smul,zero_add] at hxexact hx.trans (Matrix.mulVec_zero _).symmfunext irefine Fin.cases he (fun k => ?_) iexact congr_fun hh k· rw [he,one_smul] at hxhave heq : v=A *ᵥ b := add_right_cancel (hx.trans (char_two _).symm)exact (h ⟨b,heq.symm⟩).elimomit [Fintype J] inprivate theorem moreMatrix_mul {r} (B : Mat J I) (A : Mat I (Fin r)) (v) :B*moreMatrix A v=moreMatrix (B*A) (B *ᵥ v) := byext i jrefine Fin.cases ?_ (fun j => ?_) j· rflsimp only [moreMatrix,Matrix.mul_apply,Matrix.of_apply,Fin.cons_succ]variable {p : Shape} {n N r : ℕ} {T : Cov p N}variable {q : Place p → ℕ}private def growFmt (q : Place p→ℕ) (z : Place p) := fun i =>q i+(if i=z then 1 else 0)private theorem grow_sum (q : Place p→ℕ) (z : Place p) :ctot p (growFmt (p:=p) q z)=ctot p q+1 := by simp [growFmt,ctot,Finset.sum_add_distrib]private def growing (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N)) :DTuple (p:=p) (growFmt (p:=p) q z) N := fun i => bychange Mat (Fin N) (Fin (q i+ if i=z then 1 else 0))by_cases h : i=z· rw [ite_eq_left h]; exact moreMatrix (A i) vrw [ite_eq_right h]; exact A iprivate theorem castMat_inj {r n m : ℕ} (e : r=n)(A : Mat (Fin m) (Fin r)) (h : Injective A.mulVec) :Injective (cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A).mulVec := bysubst nexact hprivate theorem castMat_prod {r n m : ℕ} (e : r=n)(A : Mat (Fin m) (Fin r)) (B : Mat (Fin m) (Fin m)) :B*(cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A) =cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) (B*A) := bysubst n; rflprivate theorem growth_inj (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))(hv : v∉colSp (A z)) (h : ∀ i, Injective (A i).mulVec) :∀ i,Injective (growing A z v i).mulVec := byintro iby_cases he : i=z· subst isimp [growing,growFmt]apply castMat_inj _ (moreMatrix (A z) v) (moreMatrix_inj (A z) v (h z) hv)simpsimp [growing,growFmt,he]apply castMat_inj _ (A i) (h i)simp [he]private theorem growth_value (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))(x : UnitType p n N) (S : Party) :thermal p x S (growing A z v)=growing (thermal p x S A) z (heat p x S z *ᵥ v) := byfunext iby_cases he : i=z· subst isimp [thermal,growing,growFmt]rw [←moreMatrix_mul]apply castMat_prodsimpsimp [thermal,growing,growFmt,he]apply castMat_prodsimp [he]theorem column_observe (A : DTuple (p:=p) q N) (z : Place p) (j : Fin (q z))(x : UnitType p n N) (S : Party) :heat p x S z *ᵥ (A z).col j=(thermal p x S A z).col j := rflnamespace Bazaarvariable (s : Bazaar p n r T)abbrev Catalog (p : Shape) {N} (T : Cov p N) (r : ℕ) (q : Place p→ℕ) :=(M : Atlas p r T) → Batch M N → Finset (DTuple (p:=p) q N)def atList (s : Bazaar p n r T) (S : Party) (j : Bool)(A : DTuple (p:=p) q N) (F : Catalog p T r q) (x : UnitType p n N) :=let M := s.ix xthermal p x S A∈ F M (s.bag M j x)def probed (p : Shape) {N} {q : Place p→ℕ} (A : DTuple (p:=p) q N) : Cov p N :=fun z => colSp (A z)theorem extend_probe (w : Wgt (UnitType p n N)) (S : Party) (j : Bool) {k : ℕ}(A : DTuple (p:=p) q N) (hq : ctot p q=k)(h : ∀ i, Injective (A i).mulVec)(F : Catalog p T r q) (hF : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))(G : Atlas p r T) (hg : ¬ offsetCov G ≤ probed p A)(hb : ∀ M Z,(↑(s.bids w S j G M Z).card:ℝ) ≤ bp (0.51*N)) :∃ (q : Place p→ℕ) (A' : DTuple (p:=p) q N)(F' : Catalog p T r q), ctot p q=k+1 ∧(∀ i, Injective (A' i).mulVec) ∧(∀ M Z,(↑(F' M Z).card:ℝ) ≤ bp (0.51*(k+1)*N)) ∧∀ x,s.atList S j A F x → s.frequent w S j G (s.ix x) x →s.atList S j A' F' x := byclassicalobtain ⟨z,i,hg⟩ :∃ (z : Place p) (i : Fin (breadth G z)),(src G z).col i∉colSp (A z) := byby_contra! hhapply hgintro zchange colSp (src G z) ≤ _rw [colSp,range_mulVecLin]exact Submodule.span_le.mpr (Set.range_subset_iff.mpr (hh z))let q' := growFmt (p:=p) q zlet v := (src G z).col ilet f (M Z) : Finset (DTuple (p:=p) q' N) :=((F M Z) ×ˢ (s.bids w S j G M Z)).image(fun a => growing a.1 z ((a.2 z).col i))refine ⟨q',growing A z v, f,(grow_sum q z).trans (by rw [hq]),growth_inj A z v hg h,fun M Z => ?_,fun x hx hi => ?_⟩· have he := bp_pos (0.51*(k:ℝ)*N)have h1 :(↑(f M Z).card:ℝ) ≤ (↑(F M Z).card:ℝ)*(↑(s.bids w S j G M Z).card:ℝ) := byexact_mod_cast (show (f M Z).card ≤ _*_ fromFinset.card_image_le.trans_eq (Finset.card_product ..))apply (h1.trans (mul_le_mul (hF M Z) (hb M Z) (Nat.cast_nonneg _) he.le)).trans_eqrw [←bp_add]; congr 1; ring· rw [atList,growth_value]refine Finset.mem_image.mpr ⟨(thermal p x S A,thermal p x S (src G)),?_,?_⟩· exact Finset.mem_product.mpr ⟨hx,(s.bids_mem ..).mp hi⟩· change growing _ _ _ = _rw [show heat p x S z *ᵥ v=_ from column_observe (src G) z i x S]end Bazaarend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171import OAI.Combinatorics.HadwigerCounterexample.SingletonPhaseTestsnamespace OAI/-! # Additional Probe Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module Submodule Function Finsetopen scoped BigOperatorsvariable {I J K : Type} [Fintype I] [Fintype J] [Fintype K]private def moreMatrix {r : ℕ} (A : Mat I (Fin r)) (v : Vec I) : Mat I (Fin (r+1)) :=Matrix.of (fun i => Fin.cons (v i) (A i))omit [Fintype I] inprivate theorem moreMatrix_act {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)(x : Vec (Fin (r+1))) :moreMatrix A v *ᵥ x=x 0 • v + A *ᵥ (fun i => x i.succ) := byfunext i; simp only [Matrix.mulVec,dotProduct,moreMatrix,Matrix.of_apply,Fin.sum_univ_succ,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Fin.cons_zero,Fin.cons_succ]congr 1; exact mul_comm _ _omit [Fintype I] inprivate theorem moreMatrix_inj {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)(ha : Injective A.mulVec) (h : v∉colSp A) :Injective (moreMatrix A v).mulVec := byrw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]intro x hxrw [moreMatrix_act] at hxlet b (i : Fin r) := x i.succrcases bit_cases (x 0) with he|he· have hh : b=0 := byapply harw [he,zero_smul,zero_add] at hxexact hx.trans (Matrix.mulVec_zero _).symmfunext irefine Fin.cases he (fun k => ?_) iexact congr_fun hh k· rw [he,one_smul] at hxhave heq : v=A *ᵥ b := add_right_cancel (hx.trans (char_two _).symm)exact (h ⟨b,heq.symm⟩).elimomit [Fintype J] inprivate theorem moreMatrix_mul {r} (B : Mat J I) (A : Mat I (Fin r)) (v) :B*moreMatrix A v=moreMatrix (B*A) (B *ᵥ v) := byext i jrefine Fin.cases ?_ (fun j => ?_) j· rflsimp only [moreMatrix,Matrix.mul_apply,Matrix.of_apply,Fin.cons_succ]variable {p : Shape} {n N r : ℕ} {T : Cov p N}variable {q : Place p → ℕ}private def growFmt (q : Place p→ℕ) (z : Place p) := fun i =>q i+(if i=z then 1 else 0)private theorem grow_sum (q : Place p→ℕ) (z : Place p) :ctot p (growFmt (p:=p) q z)=ctot p q+1 := by simp [growFmt,ctot,Finset.sum_add_distrib]private def growing (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N)) :DTuple (p:=p) (growFmt (p:=p) q z) N := fun i => bychange Mat (Fin N) (Fin (q i+ if i=z then 1 else 0))by_cases h : i=z· rw [ite_eq_left h]; exact moreMatrix (A i) vrw [ite_eq_right h]; exact A iprivate theorem castMat_inj {r n m : ℕ} (e : r=n)(A : Mat (Fin m) (Fin r)) (h : Injective A.mulVec) :Injective (cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A).mulVec := bysubst nexact hprivate theorem castMat_prod {r n m : ℕ} (e : r=n)(A : Mat (Fin m) (Fin r)) (B : Mat (Fin m) (Fin m)) :B*(cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A) =cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) (B*A) := bysubst n; rflprivate theorem growth_inj (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))(hv : v∉colSp (A z)) (h : ∀ i, Injective (A i).mulVec) :∀ i,Injective (growing A z v i).mulVec := byintro iby_cases he : i=z· subst isimp [growing,growFmt]apply castMat_inj _ (moreMatrix (A z) v) (moreMatrix_inj (A z) v (h z) hv)simpsimp [growing,growFmt,he]apply castMat_inj _ (A i) (h i)simp [he]private theorem growth_value (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))(x : UnitType p n N) (S : Party) :thermal p x S (growing A z v)=growing (thermal p x S A) z (heat p x S z *ᵥ v) := byfunext iby_cases he : i=z· subst isimp [thermal,growing,growFmt]rw [←moreMatrix_mul]apply castMat_prodsimpsimp [thermal,growing,growFmt,he]apply castMat_prodsimp [he]theorem column_observe (A : DTuple (p:=p) q N) (z : Place p) (j : Fin (q z))(x : UnitType p n N) (S : Party) :heat p x S z *ᵥ (A z).col j=(thermal p x S A z).col j := rflnamespace Bazaarvariable (s : Bazaar p n r T)abbrev Catalog (p : Shape) {N} (T : Cov p N) (r : ℕ) (q : Place p→ℕ) :=(M : Atlas p r T) → Batch M N → Finset (DTuple (p:=p) q N)def atList (s : Bazaar p n r T) (S : Party) (j : Bool)(A : DTuple (p:=p) q N) (F : Catalog p T r q) (x : UnitType p n N) :=let M := s.ix xthermal p x S A∈ F M (s.bag M j x)def probed (p : Shape) {N} {q : Place p→ℕ} (A : DTuple (p:=p) q N) : Cov p N :=fun z => colSp (A z)theorem extend_probe (w : Wgt (UnitType p n N)) (S : Party) (j : Bool) {k : ℕ}(A : DTuple (p:=p) q N) (hq : ctot p q=k)(h : ∀ i, Injective (A i).mulVec)(F : Catalog p T r q) (hF : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))(G : Atlas p r T) (hg : ¬ offsetCov G ≤ probed p A)(hb : ∀ M Z,(↑(s.bids w S j G M Z).card:ℝ) ≤ bp (0.51*N)) :∃ (q : Place p→ℕ) (A' : DTuple (p:=p) q N)(F' : Catalog p T r q), ctot p q=k+1 ∧(∀ i, Injective (A' i).mulVec) ∧(∀ M Z,(↑(F' M Z).card:ℝ) ≤ bp (0.51*(k+1)*N)) ∧∀ x,s.atList S j A F x → s.frequent w S j G (s.ix x) x →s.atList S j A' F' x := byclassicalobtain ⟨z,i,hg⟩ :∃ (z : Place p) (i : Fin (breadth G z)),(src G z).col i∉colSp (A z) := byby_contra! hhapply hgintro zchange colSp (src G z) ≤ _rw [colSp,range_mulVecLin]exact Submodule.span_le.mpr (Set.range_subset_iff.mpr (hh z))let q' := growFmt (p:=p) q zlet v := (src G z).col ilet f (M Z) : Finset (DTuple (p:=p) q' N) :=((F M Z) ×ˢ (s.bids w S j G M Z)).image(fun a => growing a.1 z ((a.2 z).col i))refine ⟨q',growing A z v, f,(grow_sum q z).trans (by rw [hq]),growth_inj A z v hg h,fun M Z => ?_,fun x hx hi => ?_⟩· have he := bp_pos (0.51*(k:ℝ)*N)have h1 :(↑(f M Z).card:ℝ) ≤ (↑(F M Z).card:ℝ)*(↑(s.bids w S j G M Z).card:ℝ) := byexact_mod_cast (show (f M Z).card ≤ _*_ fromFinset.card_image_le.trans_eq (Finset.card_product ..))apply (h1.trans (mul_le_mul (hF M Z) (hb M Z) (Nat.cast_nonneg _) he.le)).trans_eqrw [←bp_add]; congr 1; ring· rw [atList,growth_value]refine Finset.mem_image.mpr ⟨(thermal p x S A,thermal p x S (src G)),?_,?_⟩· exact Finset.mem_product.mpr ⟨hx,(s.bids_mem ..).mp hi⟩· change growing _ _ _ = _rw [show heat p x S z *ᵥ v=_ from column_observe (src G) z i x S]end Bazaarend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195import OAI.Combinatorics.HadwigerCounterexample.QuadraticTestersimport OAI.Combinatorics.HadwigerCounterexample.SampledGraphsimport Mathlib.Data.Matrix.ColumnRowPartitionednamespace OAI/-! # Affine Frames -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrixopen scoped BigOperatorsstructure Mixer (p : Shape) (n : ℕ) wheremixL : Fin p.J → Comp p.g → Comp p.g → Moment p nmixR : Fin p.J → Comp p.g → Comp p.g → Moment p nmixM : Fin p.b → Mat (Fin n) (Fin n)abbrev Pdual (p : Shape) (n : ℕ) := Profile p n →ₗ[F] Fdef linTensor {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F) : V →ₗ[F] V →ₗ[F] F :=a.smulRight btheorem linTensor_val {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F)(x y : V) : linTensor a b x y = a x * b y := rflvariable {p : Shape} {n N : ℕ}def T0 (p : Shape) (n : ℕ) : Profile p n →ₗ[F] Pdual p n :=linTensor (role p n) (role p n) +∑ i : Tag p.g, (linTensor (roleT p n i) (sharedT p n i) +linTensor (sharedT p n i) (roleT p n i))theorem T0_val (x y : Profile p n) : T0 p n x y =role p n x * role p n y +∑ i : Tag p.g, (roleT p n i x * sharedT p n i y + sharedT p n i x * roleT p n i y) := bysimp only [T0,LinearMap.add_apply,LinearMap.sum_apply,linTensor_val]def B1 (m : Mixer p n) : Profile p n →ₗ[F] Pdual p n wheretoFun x := {toFun := fun y => ∑ j, ∑ e, ∑ f,mpair (x e) (liftM (m.mixL j e f) (m.mixR j e f) (y f))map_add' y z := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]map_smul' b y := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,smul_eq_mul,Finset.mul_sum] }map_add' x y := LinearMap.ext fun z => bysimp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.add_apply,Pi.add_apply,mpair_add, Finset.sum_add_distrib]map_smul' b x := LinearMap.ext fun z => bysimp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.smul_apply,RingHom.id_apply,Pi.smul_apply,mpair_smul,smul_eq_mul, Finset.mul_sum]def Tmix (m : Mixer p n) := B1 m + LinearMap.flip (B1 m)def Tsym (m : Mixer p n) := T0 p n + Tmix mtheorem Tsym_val (m : Mixer p n) (x y : Profile p n) :Tsym m x y = T0 p n x y + (B1 m x y + B1 m y x) := bychange (T0 p n + (B1 m + _)) x y = _simptheorem T_swap (m : Mixer p n) (x y : Profile p n) : Tsym m x y = Tsym m y x := bysimp only [Tsym_val,T0_val]refine congrArg₂ (· + ·) (congrArg₂ (· + ·) (mul_comm _ _)(Finset.sum_congr rfl fun i _ => ?_)) (add_comm _ _)rw [mul_comm (roleT p n i x),mul_comm (sharedT p n i x),add_comm]theorem T_diag (m : Mixer p n) (x : Profile p n) : Tsym m x x = role p n x := byhave h (a b : F) : a*b+b*a=0 := by rw [mul_comm b a,char_two]simp only [Tsym_val,T0_val,char_two,h,Finset.sum_const_zero,add_zero,bit_sq]def grad (m : Mixer p n) (x : Profile p n) := role p n + Tsym m xtheorem grad_val (m : Mixer p n) (x y : Profile p n) :grad m x y = role p n y + Tsym m x y := rflabbrev Full (p : Shape) (n : ℕ) := Row p n ⊕ Fin p.habbrev RawFrame (I J : Type) := Mat J I × Mat J Iabbrev Oframe (p : Shape) (n N : ℕ) := RawFrame (Full p n) (Fin N)abbrev Orient (p : Shape) (n N : ℕ) := Comp p.g → Oframe p n Ndef primary {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E I := M.submatrix id Sum.inldef channel {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E J := M.submatrix id Sum.inrtheorem fromCols_frame {I J E : Type} (M : Mat E (I ⊕ J)) :fromCols (primary M) (channel M) = M := by ext i j; rcases j with i|j <;> rfltheorem primary_inj {I J E : Type} [Fintype I] [Fintype J]{M : Mat E (I ⊕ J)} (h : Function.Injective M.mulVec) :Function.Injective (primary M).mulVec := byintro a b hablet v (x : Vec I) := Sum.elim x (fun _ : J => (0:F))have he (x : Vec I) : M *ᵥ v x = primary M *ᵥ x := byconv_lhs => rw [← fromCols_frame M]unfold v; rw [fromCols_mulVec_sumElim]change _ + (channel M *ᵥ 0) = _rw [Matrix.mulVec_zero,add_zero]have hh : v a = v b := h (by rw [he,he]; exact hab)exact funext fun i => congr_fun hh (.inl i)def valid (M : Moment p n) (o : Oframe p n N) : Prop :=Function.Injective o.1.mulVec ∧ Function.Injective o.2.mulVec ∧(primary o.1)ᵀ * primary o.2 = M ∧ (channel o.1)ᵀ * primary o.2 = 0 ∧(primary o.1)ᵀ * channel o.2 = 0def frameLaw (m : Mixer p n) (o : Orient p n N) :=∀ e, valid (selfM p n m.mixM) (o e)abbrev Ambient (p : Shape) (N : ℕ) := Comp p.g → Mat (Fin N) (Fin N)def Uembed (o : Orient p n N) : Profile p n →ₗ[F] Ambient p N wheretoFun x e := liftM (primary (o e).1) (primary (o e).2) (x e)map_add' x y := by funext e; simp only [Pi.add_apply,map_add]map_smul' a x := by funext e; simp only [Pi.smul_apply,map_smul,RingHom.id_apply]def ufun (o : Orient p n N) : Ambient p N →ₗ[F] F wheretoFun x := ∑ e, mpair (channel (o e).2 * (channel (o e).1)ᵀ) (x e)map_add' x y := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]map_smul' a x := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,smul_eq_mul,Finset.mul_sum]theorem Uembed_inj {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) :Function.Injective (Uembed o) := byintro x y eexact funext fun i =>liftM_inj (primary_inj (h i).1) (primary_inj (h i).2.1) (congr_fun e i)theorem ufun_self {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) (x : Profile p n) :ufun o (Uembed o x) = 0 := bysimp only [ufun,Uembed,LinearMap.coe_mk,AddHom.coe_mk]refine Finset.sum_eq_zero fun i _ => ?_rw [mpair_liftM,liftM_def,← Matrix.mul_assoc,(h i).2.2.2.2,Matrix.zero_mul,Matrix.zero_mul,mpair_comm,map_zero]/-- Witnesses v,w are in the cut-profile space. The gradients agree over that*whole* space. -/def hole (m : Mixer p n) (x y : Orient p n N) :=frameLaw m x ∧ frameLaw m y ∧ ∃ v w : Profile p n,v ∈ Xspace p n ∧ w ∈ Xspace p n ∧Uembed x v = Uembed y w ∧(∀ i ∈ Xspace p n, ufun y (Uembed x i) = grad m v i) ∧(∀ i ∈ Xspace p n, ufun x (Uembed y i) = grad m w i) ∧role p n v + role p n w = 1theorem hole_sym {m : Mixer p n} {x y : Orient p n N} (h : hole m x y) : hole m y x := byobtain ⟨hx,hy,v,w,hv,hw,e,h,g,p⟩ := hexact ⟨hy,hx,w,v,hw,hv,e.symm,g,h,(add_comm _ _).trans p⟩theorem not_hole_self (m : Mixer p n) (x : Orient p n N) : ¬hole m x x := byrintro ⟨hx,_,v,w,_,_,e,_,_,hp⟩rw [Uembed_inj hx e,char_two] at hpexact zero_ne_one hptheorem hole_triangle {m : Mixer p n} {x y z : Orient p n N}(h1 : hole m x y) (h2 : hole m y z) : ¬ hole m x z := byintro h3obtain ⟨_,_,a,b,ha,hb,hab,u1,u2,p1⟩ := h1obtain ⟨_,_,c,d,hc,hd,hcd,u3,u4,p2⟩ := h2obtain ⟨_,_,e,f,he,hf,hef,u5,u6,p3⟩ := h3have hx : grad m b c = grad m f d := by rw [←u2 _ hc, ←u6 _ hd,hcd]have hy : grad m a e = grad m d f := by rw [←u1 _ he, ←u4 _ hf,hef]have hz : grad m e a = grad m c b := by rw [←u5 _ ha, ←u3 _ hb,hab]simp only [grad_val] at hx hy hzlet A := role p nhave hw (x y : F) (h : x=y) : x+y=0 := by rw [h,char_two]have hp : (A a+A b)+(A c+A d)+(A e+A f)=0 := bylet H := Tsym mchange A _ + H _ _ = A _ + H _ _ at hx hy hzcalc (A a+A b)+(A c+A d)+(A e+A f)_ = ((A c+H b c)+(A d+H f d)) +((A e+H a e)+(A f+H d f)) +((A a+H e a)+(A b+H c b)) := byhave h (x y) : H x y+H y x=0 := hw _ _ (T_swap m _ _)symmcalc ((A c+H b c)+(A d+H f d)) +((A e+H a e)+(A f+H d f)) +((A a+H e a)+(A b+H c b))_ = ((A a+A b)+(A c+A d)+(A e+A f)) + (H b c+H c b) +(H f d+H d f)+(H a e+H e a) := by ac_rfl_ = _ := by simp only [h,add_zero]_ = 0 := by rw [hw _ _ hx, hw _ _ hy, hw _ _ hz]; simpunfold A at hprw [p1,p2,p3,char_two,zero_add] at hpexact one_ne_zero hpdef rawHoles (m : Mixer p n) : Holes (Orient p n N) whererel := hole msym := hole_symirr := not_hole_self mntri := hole_triangleend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195import OAI.Combinatorics.HadwigerCounterexample.QuadraticTestersimport OAI.Combinatorics.HadwigerCounterexample.SampledGraphsimport Mathlib.Data.Matrix.ColumnRowPartitionednamespace OAI/-! # Affine Frames -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrixopen scoped BigOperatorsstructure Mixer (p : Shape) (n : ℕ) wheremixL : Fin p.J → Comp p.g → Comp p.g → Moment p nmixR : Fin p.J → Comp p.g → Comp p.g → Moment p nmixM : Fin p.b → Mat (Fin n) (Fin n)abbrev Pdual (p : Shape) (n : ℕ) := Profile p n →ₗ[F] Fdef linTensor {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F) : V →ₗ[F] V →ₗ[F] F :=a.smulRight btheorem linTensor_val {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F)(x y : V) : linTensor a b x y = a x * b y := rflvariable {p : Shape} {n N : ℕ}def T0 (p : Shape) (n : ℕ) : Profile p n →ₗ[F] Pdual p n :=linTensor (role p n) (role p n) +∑ i : Tag p.g, (linTensor (roleT p n i) (sharedT p n i) +linTensor (sharedT p n i) (roleT p n i))theorem T0_val (x y : Profile p n) : T0 p n x y =role p n x * role p n y +∑ i : Tag p.g, (roleT p n i x * sharedT p n i y + sharedT p n i x * roleT p n i y) := bysimp only [T0,LinearMap.add_apply,LinearMap.sum_apply,linTensor_val]def B1 (m : Mixer p n) : Profile p n →ₗ[F] Pdual p n wheretoFun x := {toFun := fun y => ∑ j, ∑ e, ∑ f,mpair (x e) (liftM (m.mixL j e f) (m.mixR j e f) (y f))map_add' y z := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]map_smul' b y := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,smul_eq_mul,Finset.mul_sum] }map_add' x y := LinearMap.ext fun z => bysimp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.add_apply,Pi.add_apply,mpair_add, Finset.sum_add_distrib]map_smul' b x := LinearMap.ext fun z => bysimp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.smul_apply,RingHom.id_apply,Pi.smul_apply,mpair_smul,smul_eq_mul, Finset.mul_sum]def Tmix (m : Mixer p n) := B1 m + LinearMap.flip (B1 m)def Tsym (m : Mixer p n) := T0 p n + Tmix mtheorem Tsym_val (m : Mixer p n) (x y : Profile p n) :Tsym m x y = T0 p n x y + (B1 m x y + B1 m y x) := bychange (T0 p n + (B1 m + _)) x y = _simptheorem T_swap (m : Mixer p n) (x y : Profile p n) : Tsym m x y = Tsym m y x := bysimp only [Tsym_val,T0_val]refine congrArg₂ (· + ·) (congrArg₂ (· + ·) (mul_comm _ _)(Finset.sum_congr rfl fun i _ => ?_)) (add_comm _ _)rw [mul_comm (roleT p n i x),mul_comm (sharedT p n i x),add_comm]theorem T_diag (m : Mixer p n) (x : Profile p n) : Tsym m x x = role p n x := byhave h (a b : F) : a*b+b*a=0 := by rw [mul_comm b a,char_two]simp only [Tsym_val,T0_val,char_two,h,Finset.sum_const_zero,add_zero,bit_sq]def grad (m : Mixer p n) (x : Profile p n) := role p n + Tsym m xtheorem grad_val (m : Mixer p n) (x y : Profile p n) :grad m x y = role p n y + Tsym m x y := rflabbrev Full (p : Shape) (n : ℕ) := Row p n ⊕ Fin p.habbrev RawFrame (I J : Type) := Mat J I × Mat J Iabbrev Oframe (p : Shape) (n N : ℕ) := RawFrame (Full p n) (Fin N)abbrev Orient (p : Shape) (n N : ℕ) := Comp p.g → Oframe p n Ndef primary {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E I := M.submatrix id Sum.inldef channel {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E J := M.submatrix id Sum.inrtheorem fromCols_frame {I J E : Type} (M : Mat E (I ⊕ J)) :fromCols (primary M) (channel M) = M := by ext i j; rcases j with i|j <;> rfltheorem primary_inj {I J E : Type} [Fintype I] [Fintype J]{M : Mat E (I ⊕ J)} (h : Function.Injective M.mulVec) :Function.Injective (primary M).mulVec := byintro a b hablet v (x : Vec I) := Sum.elim x (fun _ : J => (0:F))have he (x : Vec I) : M *ᵥ v x = primary M *ᵥ x := byconv_lhs => rw [← fromCols_frame M]unfold v; rw [fromCols_mulVec_sumElim]change _ + (channel M *ᵥ 0) = _rw [Matrix.mulVec_zero,add_zero]have hh : v a = v b := h (by rw [he,he]; exact hab)exact funext fun i => congr_fun hh (.inl i)def valid (M : Moment p n) (o : Oframe p n N) : Prop :=Function.Injective o.1.mulVec ∧ Function.Injective o.2.mulVec ∧(primary o.1)ᵀ * primary o.2 = M ∧ (channel o.1)ᵀ * primary o.2 = 0 ∧(primary o.1)ᵀ * channel o.2 = 0def frameLaw (m : Mixer p n) (o : Orient p n N) :=∀ e, valid (selfM p n m.mixM) (o e)abbrev Ambient (p : Shape) (N : ℕ) := Comp p.g → Mat (Fin N) (Fin N)def Uembed (o : Orient p n N) : Profile p n →ₗ[F] Ambient p N wheretoFun x e := liftM (primary (o e).1) (primary (o e).2) (x e)map_add' x y := by funext e; simp only [Pi.add_apply,map_add]map_smul' a x := by funext e; simp only [Pi.smul_apply,map_smul,RingHom.id_apply]def ufun (o : Orient p n N) : Ambient p N →ₗ[F] F wheretoFun x := ∑ e, mpair (channel (o e).2 * (channel (o e).1)ᵀ) (x e)map_add' x y := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]map_smul' a x := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,smul_eq_mul,Finset.mul_sum]theorem Uembed_inj {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) :Function.Injective (Uembed o) := byintro x y eexact funext fun i =>liftM_inj (primary_inj (h i).1) (primary_inj (h i).2.1) (congr_fun e i)theorem ufun_self {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) (x : Profile p n) :ufun o (Uembed o x) = 0 := bysimp only [ufun,Uembed,LinearMap.coe_mk,AddHom.coe_mk]refine Finset.sum_eq_zero fun i _ => ?_rw [mpair_liftM,liftM_def,← Matrix.mul_assoc,(h i).2.2.2.2,Matrix.zero_mul,Matrix.zero_mul,mpair_comm,map_zero]/-- Witnesses v,w are in the cut-profile space. The gradients agree over that*whole* space. -/def hole (m : Mixer p n) (x y : Orient p n N) :=frameLaw m x ∧ frameLaw m y ∧ ∃ v w : Profile p n,v ∈ Xspace p n ∧ w ∈ Xspace p n ∧Uembed x v = Uembed y w ∧(∀ i ∈ Xspace p n, ufun y (Uembed x i) = grad m v i) ∧(∀ i ∈ Xspace p n, ufun x (Uembed y i) = grad m w i) ∧role p n v + role p n w = 1theorem hole_sym {m : Mixer p n} {x y : Orient p n N} (h : hole m x y) : hole m y x := byobtain ⟨hx,hy,v,w,hv,hw,e,h,g,p⟩ := hexact ⟨hy,hx,w,v,hw,hv,e.symm,g,h,(add_comm _ _).trans p⟩theorem not_hole_self (m : Mixer p n) (x : Orient p n N) : ¬hole m x x := byrintro ⟨hx,_,v,w,_,_,e,_,_,hp⟩rw [Uembed_inj hx e,char_two] at hpexact zero_ne_one hptheorem hole_triangle {m : Mixer p n} {x y z : Orient p n N}(h1 : hole m x y) (h2 : hole m y z) : ¬ hole m x z := byintro h3obtain ⟨_,_,a,b,ha,hb,hab,u1,u2,p1⟩ := h1obtain ⟨_,_,c,d,hc,hd,hcd,u3,u4,p2⟩ := h2obtain ⟨_,_,e,f,he,hf,hef,u5,u6,p3⟩ := h3have hx : grad m b c = grad m f d := by rw [←u2 _ hc, ←u6 _ hd,hcd]have hy : grad m a e = grad m d f := by rw [←u1 _ he, ←u4 _ hf,hef]have hz : grad m e a = grad m c b := by rw [←u5 _ ha, ←u3 _ hb,hab]simp only [grad_val] at hx hy hzlet A := role p nhave hw (x y : F) (h : x=y) : x+y=0 := by rw [h,char_two]have hp : (A a+A b)+(A c+A d)+(A e+A f)=0 := bylet H := Tsym mchange A _ + H _ _ = A _ + H _ _ at hx hy hzcalc (A a+A b)+(A c+A d)+(A e+A f)_ = ((A c+H b c)+(A d+H f d)) +((A e+H a e)+(A f+H d f)) +((A a+H e a)+(A b+H c b)) := byhave h (x y) : H x y+H y x=0 := hw _ _ (T_swap m _ _)symmcalc ((A c+H b c)+(A d+H f d)) +((A e+H a e)+(A f+H d f)) +((A a+H e a)+(A b+H c b))_ = ((A a+A b)+(A c+A d)+(A e+A f)) + (H b c+H c b) +(H f d+H d f)+(H a e+H e a) := by ac_rfl_ = _ := by simp only [h,add_zero]_ = 0 := by rw [hw _ _ hx, hw _ _ hy, hw _ _ hz]; simpunfold A at hprw [p1,p2,p3,char_two,zero_add] at hpexact one_ne_zero hpdef rawHoles (m : Mixer p n) : Holes (Orient p n N) whererel := hole msym := hole_symirr := not_hole_self mntri := hole_triangleend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import OAI.Combinatorics.HadwigerCounterexample.PositiveTestMassnamespace OAI/-! # Aggregate Cost Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Filter Functionopen scoped BigOperators Topologyopen Templatevariable {p:Shape} {n N r M s0 K:ℕ}namespace StatusAnalysisopen PreparationParameters Station DualAnalysistheorem couplings {I A : Type} [Fintype I] [Fintype A] (p:Wgt I)(f:I→ Wgt A)(F:(I×A)×(I×A)→ℝ):avg (pairW (semi p f) (semi p f)) F=avg (pairW p p) (fun i=>avg (pairW (f i.1) (f i.2)) (fun a=>F ((i.1,a.1),(i.2,a.2)))) := byrw [pairW_avg,pairW_avg]simp_rw [semi_avg,pairW_avg]refine avg_congr (fun i _=>?_); exact avg_avg ..theorem ship_cost (w:LeafMixture p n N)(U:Wgt (UnitType p n N))(m:Mixer p n)(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r) :avg (cirque w U) (fun x=>v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2))= v.stratum i.2.2 m U i.2.1 Y := couplings (portionW U w.T) (fun i=>partW U i.val) _theorem ship_pos (w:LeafMixture p n N) (m:Mixer p n)(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r)(h:i.2.2.permission)(hp:1≤p.r)(hn:2*p.r≤n)(x:ViewPair p n N w):0≤ v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2) := byclassicallet a:=i.2.2have hA j:= Appearance.witLaw (a.qA.allure_apt a.t a.z h.2.1 j) hp hnhave hB j:= Appearance.witLaw (a.qB.allure_apt a.t a.z h.2.2.1 j) hp hnlet s:= v.cAxes x.1.1 (toRates i.1.2.1)let t:= v.cAxes x.2.1 (toRates i.1.2.2)have hc (j) : 0≤ a.chimera x.1.2 x.2.2 s t m Y j := avg_nonneg (unifOn_sub _).nz(fun k=> mul_nonneg (a.qA.seraphFloor a.t a.z x.1.2 m s Y j (hA j) k).1(a.qB.seraphFloor a.t a.z x.2.2 m t Y j (hB j) k).1)have hM : 0≤a.momus:= mul_nonneg (kappa_pos _).le (kappa_pos _).leexact mul_nonneg (ind_nonneg _) (mul_nonneg hM (Finset.prod_nonneg fun i _=>hc i))theorem prognosis (w:LeafMixture p n N) (U: Wgt (UnitType p n N)) (m:Mixer p n)(b:PreparationParameters) (v:Station p n N b.pins w) (Y:Silhouette p N r){ε a : ℝ} (he:0 ≤ ε)(ha:0<a) (hp:1≤p.r)(hn:2*p.r≤n)(hs:Lead U w m b)(h:∀ i:Scrip p b.pins,i.2.2.permission→v.stratum i.2.2 m U i.2.1 Y ≤ ε):pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a)≤ num (Scrip p b.pins)*(ε/a) := byclassicallet J:= Scrip p b.pins; let I:=ViewPair p n N w; let V:=cirque w Ulet Q (i:J)(x:I):= v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2)have ht:= (troupe_bill hs).1; have hv:IsLaw V:=pairW_law ht htlet P (i:J)(x:I):= i.2.2.permission∧ a ≤ Q i xhave hF (i:J): pr V (P i)≤ ε/a := byby_cases ht:i.2.2.permission· simp only [P,ht,true_and]refine (le_div_iff₀ ha).mpr ?_rw [mul_comm]exact ((le_avg_markov hv.nz (ship_pos w m v i Y ht hp hn) a).trans_eq (ship_cost ..)).trans(h i ht)rw [show P i=(fun _=>False) from funext fun a=>eq_false fun hh=>ht hh.1,pr_false]; exact div_nonneg he ha.lechange pr V (fun x=>∃ i,P i x)≤ _exact ((pr_exists_le hv.nz P).trans (Finset.sum_le_sum fun i _=> hF i)).trans_eq (by simp [J,num])structure Beams (b:PreparationParameters) (m:Mixer p n) (Y:Silhouette p N r)(w:LeafMixture p n N)(U:Wgt (UnitType p n N)) (v:Station p n N b.pins w)(a ε δ τ :ℝ):Prop wheresoft : origami p r (wisp p Y) δrare : pr (w.sap U) (fun i=>¬gauze p δ δ Y m b.pins i) ≤ τzone : pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a) ≤ τhaze : 0<δ∧ δ≤ εvariable {l:Filter ℕ} {m:cycleM p} {U:tale p M} {w:rhythms p M} {b:PreparationParameters}set_option maxHeartbeats 1400000 intheorem lightmap (v:Stations p M b.pins w) (h:veil p M b s0 l m w U)(a ε τ:ℝ) (ha:0<a)(he:0<ε)(hτ:0<τ)(k:ℕ)(Y:∀ n,Silhouette p (M*n) k):∃ (r:ℕ) (δ:ℝ), ∀ᶠ n in l,∃ X:Silhouette p (M*n) r,refines X (Y n)∧Beams b (m n) X (w n) (U n) (v n) a ε δ τ := byclassicallet L:= num (Scrip p b.pins); have hL:0≤L:=Nat.cast_nonneg _let η := a*τ/(L+1)have hη:0<η:=by unfold η; positivitylet u:= min τ (min ε (1/4))have hu :0<u:=lt_min hτ (lt_min he (by norm_num))obtain ⟨r,δ,hd,hV,hT⟩:= lateSilk v h η u hη hu krefine ⟨r,δ,?_⟩; have he:= h.easel.enter.firstfilter_upwards [h.upright,hT,h.moment,h.durableS.shape,h.durableS.mass.positive,(trend_sizes l h.timeL he.hM).2.eventually (eventually_ge_atTop (2*num (Toast p)+1))]with n hn ht hp hC hP hNobtain ⟨X,hX,hW,hY⟩:=ht (Y n)let N:=M*nrefine ⟨X,hX, ?_,hW.trans (min_le_left ..),?_, hd,?_⟩· have h0 i j:IsLaw (wisp p X i j):=mapW_law (omegaLaw p i j (show 2*num (Toast p)-(N:ℝ)≤-1 bychange _≤(N:ℝ) at hNlinarith only [hN])) _refine ⟨h0,fun i j=>?_⟩let ν:=wisp p X i jhave hs : pr ν (fun i=>¬δ≤ν i) = 1-pr ν (fun i=>δ≤ν i) :=by rw [pr_not,(show tot ν=1from (h0 i j).total)]have hi:u≤1/4:=le_trans (min_le_right ..) (min_le_right ..)simp_rw [not_le] at hshave hf:= haze_small ν δ hd.lelinarith only [hf,hs,hV,hi,hd]· apply (prognosis (w n) (U n) (m n) b (v n) X hη.le ha he.hR hn.age⟨hC.1,hP,hp.1.law,hC.2⟩ hY).transchange L*(η/a)≤τhave h : η/a= τ/(L+1) := by unfold η; field_simprw [h,mul_div_assoc',div_le_iff₀ (by linarith)]linarith only [hτ]have hi:u≤ε:=le_trans (min_le_right ..) (min_le_left ..)nlinarith only [hi,hV,hd,Nat.cast_nonneg (α:=ℝ) r]end StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import OAI.Combinatorics.HadwigerCounterexample.PositiveTestMassnamespace OAI/-! # Aggregate Cost Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Filter Functionopen scoped BigOperators Topologyopen Templatevariable {p:Shape} {n N r M s0 K:ℕ}namespace StatusAnalysisopen PreparationParameters Station DualAnalysistheorem couplings {I A : Type} [Fintype I] [Fintype A] (p:Wgt I)(f:I→ Wgt A)(F:(I×A)×(I×A)→ℝ):avg (pairW (semi p f) (semi p f)) F=avg (pairW p p) (fun i=>avg (pairW (f i.1) (f i.2)) (fun a=>F ((i.1,a.1),(i.2,a.2)))) := byrw [pairW_avg,pairW_avg]simp_rw [semi_avg,pairW_avg]refine avg_congr (fun i _=>?_); exact avg_avg ..theorem ship_cost (w:LeafMixture p n N)(U:Wgt (UnitType p n N))(m:Mixer p n)(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r) :avg (cirque w U) (fun x=>v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2))= v.stratum i.2.2 m U i.2.1 Y := couplings (portionW U w.T) (fun i=>partW U i.val) _theorem ship_pos (w:LeafMixture p n N) (m:Mixer p n)(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r)(h:i.2.2.permission)(hp:1≤p.r)(hn:2*p.r≤n)(x:ViewPair p n N w):0≤ v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2) := byclassicallet a:=i.2.2have hA j:= Appearance.witLaw (a.qA.allure_apt a.t a.z h.2.1 j) hp hnhave hB j:= Appearance.witLaw (a.qB.allure_apt a.t a.z h.2.2.1 j) hp hnlet s:= v.cAxes x.1.1 (toRates i.1.2.1)let t:= v.cAxes x.2.1 (toRates i.1.2.2)have hc (j) : 0≤ a.chimera x.1.2 x.2.2 s t m Y j := avg_nonneg (unifOn_sub _).nz(fun k=> mul_nonneg (a.qA.seraphFloor a.t a.z x.1.2 m s Y j (hA j) k).1(a.qB.seraphFloor a.t a.z x.2.2 m t Y j (hB j) k).1)have hM : 0≤a.momus:= mul_nonneg (kappa_pos _).le (kappa_pos _).leexact mul_nonneg (ind_nonneg _) (mul_nonneg hM (Finset.prod_nonneg fun i _=>hc i))theorem prognosis (w:LeafMixture p n N) (U: Wgt (UnitType p n N)) (m:Mixer p n)(b:PreparationParameters) (v:Station p n N b.pins w) (Y:Silhouette p N r){ε a : ℝ} (he:0 ≤ ε)(ha:0<a) (hp:1≤p.r)(hn:2*p.r≤n)(hs:Lead U w m b)(h:∀ i:Scrip p b.pins,i.2.2.permission→v.stratum i.2.2 m U i.2.1 Y ≤ ε):pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a)≤ num (Scrip p b.pins)*(ε/a) := byclassicallet J:= Scrip p b.pins; let I:=ViewPair p n N w; let V:=cirque w Ulet Q (i:J)(x:I):= v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2)have ht:= (troupe_bill hs).1; have hv:IsLaw V:=pairW_law ht htlet P (i:J)(x:I):= i.2.2.permission∧ a ≤ Q i xhave hF (i:J): pr V (P i)≤ ε/a := byby_cases ht:i.2.2.permission· simp only [P,ht,true_and]refine (le_div_iff₀ ha).mpr ?_rw [mul_comm]exact ((le_avg_markov hv.nz (ship_pos w m v i Y ht hp hn) a).trans_eq (ship_cost ..)).trans(h i ht)rw [show P i=(fun _=>False) from funext fun a=>eq_false fun hh=>ht hh.1,pr_false]; exact div_nonneg he ha.lechange pr V (fun x=>∃ i,P i x)≤ _exact ((pr_exists_le hv.nz P).trans (Finset.sum_le_sum fun i _=> hF i)).trans_eq (by simp [J,num])structure Beams (b:PreparationParameters) (m:Mixer p n) (Y:Silhouette p N r)(w:LeafMixture p n N)(U:Wgt (UnitType p n N)) (v:Station p n N b.pins w)(a ε δ τ :ℝ):Prop wheresoft : origami p r (wisp p Y) δrare : pr (w.sap U) (fun i=>¬gauze p δ δ Y m b.pins i) ≤ τzone : pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a) ≤ τhaze : 0<δ∧ δ≤ εvariable {l:Filter ℕ} {m:cycleM p} {U:tale p M} {w:rhythms p M} {b:PreparationParameters}set_option maxHeartbeats 1400000 intheorem lightmap (v:Stations p M b.pins w) (h:veil p M b s0 l m w U)(a ε τ:ℝ) (ha:0<a)(he:0<ε)(hτ:0<τ)(k:ℕ)(Y:∀ n,Silhouette p (M*n) k):∃ (r:ℕ) (δ:ℝ), ∀ᶠ n in l,∃ X:Silhouette p (M*n) r,refines X (Y n)∧Beams b (m n) X (w n) (U n) (v n) a ε δ τ := byclassicallet L:= num (Scrip p b.pins); have hL:0≤L:=Nat.cast_nonneg _let η := a*τ/(L+1)have hη:0<η:=by unfold η; positivitylet u:= min τ (min ε (1/4))have hu :0<u:=lt_min hτ (lt_min he (by norm_num))obtain ⟨r,δ,hd,hV,hT⟩:= lateSilk v h η u hη hu krefine ⟨r,δ,?_⟩; have he:= h.easel.enter.firstfilter_upwards [h.upright,hT,h.moment,h.durableS.shape,h.durableS.mass.positive,(trend_sizes l h.timeL he.hM).2.eventually (eventually_ge_atTop (2*num (Toast p)+1))]with n hn ht hp hC hP hNobtain ⟨X,hX,hW,hY⟩:=ht (Y n)let N:=M*nrefine ⟨X,hX, ?_,hW.trans (min_le_left ..),?_, hd,?_⟩· have h0 i j:IsLaw (wisp p X i j):=mapW_law (omegaLaw p i j (show 2*num (Toast p)-(N:ℝ)≤-1 bychange _≤(N:ℝ) at hNlinarith only [hN])) _refine ⟨h0,fun i j=>?_⟩let ν:=wisp p X i jhave hs : pr ν (fun i=>¬δ≤ν i) = 1-pr ν (fun i=>δ≤ν i) :=by rw [pr_not,(show tot ν=1from (h0 i j).total)]have hi:u≤1/4:=le_trans (min_le_right ..) (min_le_right ..)simp_rw [not_le] at hshave hf:= haze_small ν δ hd.lelinarith only [hf,hs,hV,hi,hd]· apply (prognosis (w n) (U n) (m n) b (v n) X hη.le ha he.hR hn.age⟨hC.1,hP,hp.1.law,hC.2⟩ hY).transchange L*(η/a)≤τhave h : η/a= τ/(L+1) := by unfold η; field_simprw [h,mul_div_assoc',div_le_iff₀ (by linarith)]linarith only [hτ]have hi:u≤ε:=le_trans (min_le_right ..) (min_le_left ..)nlinarith only [hi,hV,hd,Nat.cast_nonneg (α:=ℝ) r]end StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211import OAI.Combinatorics.HadwigerCounterexample.TesterSummaryMassimport OAI.Combinatorics.HadwigerCounterexample.ChannelFrameLawsnamespace OAI/-! # Ambient Batch Slots -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module LinearMap Finset Functionopen scoped BigOperatorsvariable {I J G A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]variable {p : Shape} {n N : ℕ}omit [Fintype B] intheorem mapW_equiv_val (e : A≃B) (w : Wgt A) (y : B) :mapW w e y=w (e.symm y) := byclassicalhave h : (fun x => e x=y)=(fun x => x=e.symm y) := byfunext x; apply propextexact ⟨fun h => by rw [← h,Equiv.symm_apply_apply],fun h => by rw [h,Equiv.apply_symm_apply]⟩unfold mapW; rw [h]; simptheorem unif_equiv (e : A≃B) : mapW unif e = unif := byfunext x; rw [mapW_equiv_val, unif_apply, unif_apply, Fintype.card_congr e]theorem on_equiv (e : A≃B) (p : B→Prop) :mapW (unifOn (fun x => p (e x))) e = unifOn p := byclassicalhave h : nbr (fun x => p (e x))=nbr p := Equiv.sum_comp e (fun y => ind (p y))funext xrw [mapW_equiv_val,unifOn_val,unifOn_val]; simp only [Equiv.apply_symm_apply,h]abbrev PlusRack (I : Type) (N : ℕ) := Mat (Fin N) Iabbrev Rack (I : Type) (N : ℕ) := PlusRack I N × PlusRack I Ndef sectionR {I J : Type} (f : J→I) (x : Rack I N) : Rack J N :=((x.1).submatrix _root_.id f, (x.2).submatrix _root_.id f)abbrev Route (I G : Type) := I → Gabbrev Port {I G : Type} (f : Route I G) (g : G) := {i:I//f i=g}abbrev Network {I G : Type} (f : Route I G) (N : ℕ) := ∀ i,Rack (Port f i) Nvariable [Fintype G]variable [DecidableEq I] [DecidableEq J] [DecidableEq G]variable {f : Route I G}def rackEquiv (f : Route I G) (N : ℕ) : Rack I N ≃ Network f N wheretoFun x i := sectionR Subtype.val xinvFun x := (Matrix.of (fun j i => (x (f i)).1 j ⟨i,rfl⟩),Matrix.of (fun j i => (x (f i)).2 j ⟨i,rfl⟩))left_inv x := by apply Prod.ext <;> rflright_inv x := byfunext i; apply Prod.ext <;>· ext j ⟨y,rfl⟩; rflabbrev GeoM (f : Route I G) := ∀ i,Mat (Port f i) (Port f i)def gramPart {N} (A : GeoM f) (x : Rack I N) :=∀ i,let P:=rackEquiv f N x i;P.1ᵀ*P.2=A idef injPart (f : Route I G) {N} (x : Rack I N) :=∀ i,let P:=rackEquiv f N x i;Injective P.1.mulVec ∧ Injective P.2.mulVecdef bothPart {N} (A : GeoM f) (x : Rack I N) := ∀ i, gramGood (A i) (rackEquiv f N x i)def scoreR {I : Type} (x : Rack I N) (i j : I) : F := (x.1ᵀ*x.2) i jomit [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] intheorem part_scores (x : Rack I N) (A : GeoM f) :gramPart A x↔ ∀ i, ∀ a b : Port f i,scoreR x a.val b.val=A i a b := byconstructor· intro h i a b; exact congr_fun (congr_fun (h i) a) bintro h i; exact Matrix.ext (fun a b => h i a b)omit [Fintype G] [DecidableEq I] intheorem both_test (A : GeoM f) (x : Rack I N) :bothPart A x↔ gramPart A x ∧injPart f x := by simp [gramPart,injPart,bothPart,gramGood,forall_and]private theorem pi_unif {I : Type} [Fintype I] [DecidableEq I]{A : I→Type} [∀ i,Fintype (A i)] :unif (α:=(∀ i,A i)) = prodW (fun i => unif (α:=A i)) := byclassicalfunext xsimp [unif_apply,prodW,Fintype.card_pi]private theorem pi_unifOn {I : Type} [Fintype I] [DecidableEq I]{A : I→Type} [∀ i,Fintype (A i)] (p : ∀ i,A i→Prop) :unifOn (fun x => ∀ i,p i (x i)) = prodW (fun i => unifOn (p i)) := byclassicalfunext xrw [unifOn_val]have he : nbr (fun x : (∀ i, A i) => ∀ i,p i (x i)) = ∏ i,nbr (p i) := byunfold nbr; simp_rw [ind_all]exact prodW_tot (fun (i : I) (x : A i) => ind (p i x))simp only [prodW,he,unifOn_val,ind_all,Finset.prod_div_distrib]def rackStation (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (bothPart A)def rackWave (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (gramPart A)theorem station_split (A : GeoM f) (N : ℕ) :mapW (rackStation A N) (rackEquiv f N)=prodW (fun i => unifOn (gramGood (A i))) := byclassicalunfold rackStation bothPartrw [show mapW _ _= _ from on_equiv (rackEquiv f N)(fun x => ∀ i,gramGood (A i) (x i))]exact pi_unifOn _def netSize (f : Route I G) := ∑ i : G,num (Port f i)*num (Port f i)def netFact (f : Route I G) :=(4:ℝ)^(Fintype.card G)*bp (netSize f)omit [DecidableEq I] intheorem netFact_pos : 0<netFact f := mul_pos (pow_pos (by norm_num) _) (bp_pos _)theorem net_norm (A : GeoM f) (N : ℕ)(h : ∀ i,2*num (Port f i)-N≤ -1) :(netFact f)⁻¹ ≤ pr unif (bothPart (N:=N) A) ∧pr unif (bothPart (N:=N) A) ≤ bp (-netSize f) := byclassicallet p := fun i => gramGood (U:=Fin N) (A i)have hnum (t : ℕ) : num (Fin t)=(t:ℝ) := by simp [num]have ht i : num (Port f i) + num (Port f i)-num (Fin N)≤ -1 := by rw [←two_mul,hnum]; exact h _have he : pr unif (bothPart (N:=N) A) = ∏ i,pr unif (p i) := byunfold bothPartrw [←mapW_pr unif (rackEquiv f N) (fun x => ∀ i,p i (x i)), unif_equiv]conv_lhs => rw [pi_unif]exact prodW_pr ..rw [he]; constructor· let h' (i : G) := bp (-(num (Port f i))*num (Port f i))/4have hh i : h' i ≤ pr unif (p i) := gram_norm_quarter _ (ht _)refine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => div_nonneg (bp_pos _).le(by norm_num)) fun i _ => hh i)unfold netFactrw [_root_.mul_inv_rev,Finset.prod_div_distrib,←bp_sum,netSize,Finset.prod_const,← bp_neg, ← Finset.sum_neg_distrib]simp_rw [neg_mul, Finset.card_univ,div_eq_mul_inv]exact le_rfl· have h i :=(gram_norm (U:=Fin N) (A i) (show _≤ _ by linarith only [ht i])).1unfold netSizerw [← Finset.sum_neg_distrib, bp_sum]apply Finset.prod_le_prod₀ (fun i _ => pr_nonneg unif_law.nz)intro i _rw [pair_unif,←neg_mul]exact h itheorem wave_norm (A : GeoM f) (N : ℕ)(h : ∀ i,2*num (Port f i)-N≤ -1) :(netFact f)⁻¹ ≤ pr unif (gramPart (N:=N) A) :=((net_norm A N h).1).trans(pr_mono unif_law.nz (fun _ hx => ((both_test ..).mp hx).1))theorem injPart_failure (f : Route I G) (N : ℕ) (k : ℝ) (h : ∀ i,num (Port f i)≤k) :pr unif (fun x : Rack I N => ¬injPart f x)≤num G*(2*bp (k-N)) := byclassicallet Q := fun x : Network f N =>∀ i, Injective (x i).1.mulVec ∧ Injective (x i).2.mulVechave he :pr unif (fun x : Rack I N => ¬injPart f x)=pr (prodW (fun i : G => unif (α:=Rack (Port f i) N))) (fun x => ¬Q x) := byrw [←pi_unif,← unif_equiv (rackEquiv f N),mapW_pr]rflrw [he]let P i := fun x : Rack (Port f i) N => ¬ (Injective x.1.mulVec∧Injective x.2.mulVec)let w : Wgt (Network f N) := prodW (fun i => unif)have hw : IsLaw w := prodW_law (fun _ => unif_law)have ht i : pr unif (P i) ≤ 2*bp (k-N) := bylet g := fun x : PlusRack (Port f i) N => ¬Injective x.mulVechave hi : pr unif g≤ bp (k-N) := byrefine unif_fail.trans (bp_le ?_)have he := h isimp only [num,Fintype.card_fin] at *linarith only [he]have hQ (x : Rack (Port f i) N) :P i x→ (True∧g x.2)∨(g x.1∧True) := by unfold P g; tautorw [pair_unif,two_mul]let nz := (pairW_law (α:=PlusRack (Port f i) N) unif_law (β:=PlusRack (Port f i) N) unif_law).nzcalc pr _ __ ≤ _ := pr_mono nz hQ_ ≤ _ := pr_or_le nz_ ≤ _ := by rw [pairW_pr unif unif (fun _ : PlusRack (Port f i) N => True) g,pairW_pr unif unif g (fun _ : PlusRack (Port f i) N => True),pr_true,unif_law.total,one_mul,mul_one]exact add_le_add hi hihave hP x (h : ¬Q x) : ∃ i,P i (x i) := Classical.byContradiction (fun g =>h (fun i => Classical.byContradiction (fun he => g ⟨i,he⟩)))have hc i :pr w (fun x => P i (x i))=pr unif (P i) := bylet g (j : G) (x : Rack (Port f j) N) :=if h:j=i then by subst i; exact P j x else Truehave he (x : Network f N) :P i (x i) ↔ ∀ j,g j (x j) := byconstructor· intro h jby_cases he : j=i· subst j; exact (by simpa [g])simp [g,he]· intro h; simpa [g] using h isimp_rw [he]; unfold w; rw [prodW_pr _ g,Finset.prod_eq_single i]· simp [g]· intro j _ hj; simp [g,hj,unif_law.total]simprefine le_trans (pr_mono hw.nz hP) ((pr_exists_le hw.nz (fun i x => P i (x i))).trans ?_)simp_rw [hc]refine (Finset.sum_le_sum fun i _ => ht i).trans_eq ?_simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,num]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211import OAI.Combinatorics.HadwigerCounterexample.TesterSummaryMassimport OAI.Combinatorics.HadwigerCounterexample.ChannelFrameLawsnamespace OAI/-! # Ambient Batch Slots -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module LinearMap Finset Functionopen scoped BigOperatorsvariable {I J G A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]variable {p : Shape} {n N : ℕ}omit [Fintype B] intheorem mapW_equiv_val (e : A≃B) (w : Wgt A) (y : B) :mapW w e y=w (e.symm y) := byclassicalhave h : (fun x => e x=y)=(fun x => x=e.symm y) := byfunext x; apply propextexact ⟨fun h => by rw [← h,Equiv.symm_apply_apply],fun h => by rw [h,Equiv.apply_symm_apply]⟩unfold mapW; rw [h]; simptheorem unif_equiv (e : A≃B) : mapW unif e = unif := byfunext x; rw [mapW_equiv_val, unif_apply, unif_apply, Fintype.card_congr e]theorem on_equiv (e : A≃B) (p : B→Prop) :mapW (unifOn (fun x => p (e x))) e = unifOn p := byclassicalhave h : nbr (fun x => p (e x))=nbr p := Equiv.sum_comp e (fun y => ind (p y))funext xrw [mapW_equiv_val,unifOn_val,unifOn_val]; simp only [Equiv.apply_symm_apply,h]abbrev PlusRack (I : Type) (N : ℕ) := Mat (Fin N) Iabbrev Rack (I : Type) (N : ℕ) := PlusRack I N × PlusRack I Ndef sectionR {I J : Type} (f : J→I) (x : Rack I N) : Rack J N :=((x.1).submatrix _root_.id f, (x.2).submatrix _root_.id f)abbrev Route (I G : Type) := I → Gabbrev Port {I G : Type} (f : Route I G) (g : G) := {i:I//f i=g}abbrev Network {I G : Type} (f : Route I G) (N : ℕ) := ∀ i,Rack (Port f i) Nvariable [Fintype G]variable [DecidableEq I] [DecidableEq J] [DecidableEq G]variable {f : Route I G}def rackEquiv (f : Route I G) (N : ℕ) : Rack I N ≃ Network f N wheretoFun x i := sectionR Subtype.val xinvFun x := (Matrix.of (fun j i => (x (f i)).1 j ⟨i,rfl⟩),Matrix.of (fun j i => (x (f i)).2 j ⟨i,rfl⟩))left_inv x := by apply Prod.ext <;> rflright_inv x := byfunext i; apply Prod.ext <;>· ext j ⟨y,rfl⟩; rflabbrev GeoM (f : Route I G) := ∀ i,Mat (Port f i) (Port f i)def gramPart {N} (A : GeoM f) (x : Rack I N) :=∀ i,let P:=rackEquiv f N x i;P.1ᵀ*P.2=A idef injPart (f : Route I G) {N} (x : Rack I N) :=∀ i,let P:=rackEquiv f N x i;Injective P.1.mulVec ∧ Injective P.2.mulVecdef bothPart {N} (A : GeoM f) (x : Rack I N) := ∀ i, gramGood (A i) (rackEquiv f N x i)def scoreR {I : Type} (x : Rack I N) (i j : I) : F := (x.1ᵀ*x.2) i jomit [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] intheorem part_scores (x : Rack I N) (A : GeoM f) :gramPart A x↔ ∀ i, ∀ a b : Port f i,scoreR x a.val b.val=A i a b := byconstructor· intro h i a b; exact congr_fun (congr_fun (h i) a) bintro h i; exact Matrix.ext (fun a b => h i a b)omit [Fintype G] [DecidableEq I] intheorem both_test (A : GeoM f) (x : Rack I N) :bothPart A x↔ gramPart A x ∧injPart f x := by simp [gramPart,injPart,bothPart,gramGood,forall_and]private theorem pi_unif {I : Type} [Fintype I] [DecidableEq I]{A : I→Type} [∀ i,Fintype (A i)] :unif (α:=(∀ i,A i)) = prodW (fun i => unif (α:=A i)) := byclassicalfunext xsimp [unif_apply,prodW,Fintype.card_pi]private theorem pi_unifOn {I : Type} [Fintype I] [DecidableEq I]{A : I→Type} [∀ i,Fintype (A i)] (p : ∀ i,A i→Prop) :unifOn (fun x => ∀ i,p i (x i)) = prodW (fun i => unifOn (p i)) := byclassicalfunext xrw [unifOn_val]have he : nbr (fun x : (∀ i, A i) => ∀ i,p i (x i)) = ∏ i,nbr (p i) := byunfold nbr; simp_rw [ind_all]exact prodW_tot (fun (i : I) (x : A i) => ind (p i x))simp only [prodW,he,unifOn_val,ind_all,Finset.prod_div_distrib]def rackStation (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (bothPart A)def rackWave (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (gramPart A)theorem station_split (A : GeoM f) (N : ℕ) :mapW (rackStation A N) (rackEquiv f N)=prodW (fun i => unifOn (gramGood (A i))) := byclassicalunfold rackStation bothPartrw [show mapW _ _= _ from on_equiv (rackEquiv f N)(fun x => ∀ i,gramGood (A i) (x i))]exact pi_unifOn _def netSize (f : Route I G) := ∑ i : G,num (Port f i)*num (Port f i)def netFact (f : Route I G) :=(4:ℝ)^(Fintype.card G)*bp (netSize f)omit [DecidableEq I] intheorem netFact_pos : 0<netFact f := mul_pos (pow_pos (by norm_num) _) (bp_pos _)theorem net_norm (A : GeoM f) (N : ℕ)(h : ∀ i,2*num (Port f i)-N≤ -1) :(netFact f)⁻¹ ≤ pr unif (bothPart (N:=N) A) ∧pr unif (bothPart (N:=N) A) ≤ bp (-netSize f) := byclassicallet p := fun i => gramGood (U:=Fin N) (A i)have hnum (t : ℕ) : num (Fin t)=(t:ℝ) := by simp [num]have ht i : num (Port f i) + num (Port f i)-num (Fin N)≤ -1 := by rw [←two_mul,hnum]; exact h _have he : pr unif (bothPart (N:=N) A) = ∏ i,pr unif (p i) := byunfold bothPartrw [←mapW_pr unif (rackEquiv f N) (fun x => ∀ i,p i (x i)), unif_equiv]conv_lhs => rw [pi_unif]exact prodW_pr ..rw [he]; constructor· let h' (i : G) := bp (-(num (Port f i))*num (Port f i))/4have hh i : h' i ≤ pr unif (p i) := gram_norm_quarter _ (ht _)refine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => div_nonneg (bp_pos _).le(by norm_num)) fun i _ => hh i)unfold netFactrw [_root_.mul_inv_rev,Finset.prod_div_distrib,←bp_sum,netSize,Finset.prod_const,← bp_neg, ← Finset.sum_neg_distrib]simp_rw [neg_mul, Finset.card_univ,div_eq_mul_inv]exact le_rfl· have h i :=(gram_norm (U:=Fin N) (A i) (show _≤ _ by linarith only [ht i])).1unfold netSizerw [← Finset.sum_neg_distrib, bp_sum]apply Finset.prod_le_prod₀ (fun i _ => pr_nonneg unif_law.nz)intro i _rw [pair_unif,←neg_mul]exact h itheorem wave_norm (A : GeoM f) (N : ℕ)(h : ∀ i,2*num (Port f i)-N≤ -1) :(netFact f)⁻¹ ≤ pr unif (gramPart (N:=N) A) :=((net_norm A N h).1).trans(pr_mono unif_law.nz (fun _ hx => ((both_test ..).mp hx).1))theorem injPart_failure (f : Route I G) (N : ℕ) (k : ℝ) (h : ∀ i,num (Port f i)≤k) :pr unif (fun x : Rack I N => ¬injPart f x)≤num G*(2*bp (k-N)) := byclassicallet Q := fun x : Network f N =>∀ i, Injective (x i).1.mulVec ∧ Injective (x i).2.mulVechave he :pr unif (fun x : Rack I N => ¬injPart f x)=pr (prodW (fun i : G => unif (α:=Rack (Port f i) N))) (fun x => ¬Q x) := byrw [←pi_unif,← unif_equiv (rackEquiv f N),mapW_pr]rflrw [he]let P i := fun x : Rack (Port f i) N => ¬ (Injective x.1.mulVec∧Injective x.2.mulVec)let w : Wgt (Network f N) := prodW (fun i => unif)have hw : IsLaw w := prodW_law (fun _ => unif_law)have ht i : pr unif (P i) ≤ 2*bp (k-N) := bylet g := fun x : PlusRack (Port f i) N => ¬Injective x.mulVechave hi : pr unif g≤ bp (k-N) := byrefine unif_fail.trans (bp_le ?_)have he := h isimp only [num,Fintype.card_fin] at *linarith only [he]have hQ (x : Rack (Port f i) N) :P i x→ (True∧g x.2)∨(g x.1∧True) := by unfold P g; tautorw [pair_unif,two_mul]let nz := (pairW_law (α:=PlusRack (Port f i) N) unif_law (β:=PlusRack (Port f i) N) unif_law).nzcalc pr _ __ ≤ _ := pr_mono nz hQ_ ≤ _ := pr_or_le nz_ ≤ _ := by rw [pairW_pr unif unif (fun _ : PlusRack (Port f i) N => True) g,pairW_pr unif unif g (fun _ : PlusRack (Port f i) N => True),pr_true,unif_law.total,one_mul,mul_one]exact add_le_add hi hihave hP x (h : ¬Q x) : ∃ i,P i (x i) := Classical.byContradiction (fun g =>h (fun i => Classical.byContradiction (fun he => g ⟨i,he⟩)))have hc i :pr w (fun x => P i (x i))=pr unif (P i) := bylet g (j : G) (x : Rack (Port f j) N) :=if h:j=i then by subst i; exact P j x else Truehave he (x : Network f N) :P i (x i) ↔ ∀ j,g j (x j) := byconstructor· intro h jby_cases he : j=i· subst j; exact (by simpa [g])simp [g,he]· intro h; simpa [g] using h isimp_rw [he]; unfold w; rw [prodW_pr _ g,Finset.prod_eq_single i]· simp [g]· intro j _ hj; simp [g,hj,unif_law.total]simprefine le_trans (pr_mono hw.nz hP) ((pr_exists_le hw.nz (fun i x => P i (x i))).trans ?_)simp_rw [hc]refine (Finset.sum_le_sum fun i _ => ht i).trans_eq ?_simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,num]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import OAI.Combinatorics.HadwigerCounterexample.PairedMassIdentitiesimport OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBoundsimport OAI.Combinatorics.HadwigerCounterexample.RecursiveComparisonErrorsimport OAI.Combinatorics.HadwigerCounterexample.MixerExistencenamespace OAI/-! # Analytic Parameters -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrixopen scoped BigOperators Topologyopen StatusAnalysis StatusAnalysis.Stationdef frameBills (g K : ℕ) :=2*Fintype.card (Comp g)*K*qorth Kstructure AnalyticParameters (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ) : Prop whereenter : b.entry p Mthickness : 4≤ Mprofiles : 2*profileA p b.pins < rjump : 1≤p.JbigJ : r≤p.Jgleaming : bp (-((p.J-r:ℕ):ℝ))*bp r < glintRate b.pinspenRoom : (b.pins+1)*qorth b.pins≤p.j+1forbid : frameBills p.g b.pins+1000 ≤ b.Bspare : 3*b.B < Fintype.card (Label p.b)secure : ∀ᶠ n : ℕ in atTop, Station.earnsScore p n (M*n) b.pins (2*b.ζ)namespace PreparationParametersvariable {b : PreparationParameters} {p : Shape} {N M r : ℕ} {l : Filter ℕ} {m : cycleM p}{s : rhythms p M} {w : tale p M}def conflicted {n : ℕ} (p : Shape) (m : Mixer p n) (N : ℕ) (w : Wgt (UnitType p n N)) :=pr (pairW w w) (clash p m N)<bp (-100*p.g*(N:ℝ))structure veil (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ)(l : Filter ℕ) (m : cycleM p) (s : rhythms p M) (w : tale p M) : Prop whereeasel : AnalyticParameters p M b rtimeL : l≤atTopdurableS : b.durable l p M m w smoment : ∀ᶠ n in l,b.nascent p (M*n) (w n) (m n) ∧ unaryGood (m n) b.pins r ∧binaryGood (m n) ∧ conflicted p (m n) (M*n) (w n)abbrev Stations (p : Shape) (M K : ℕ) (s : rhythms p M) :=∀ n : ℕ, Station p n (M*n) K (s n)theorem beam_cost (p : Shape) (N : ℕ) (h : 3≤p.g) :beamPrice p N * bp (-100*p.g*(N:ℝ)) ≤ bp (-(N:ℝ)) := byunfold beamPrice; rw [←bp_add]; refine bp_le ?_have hh : kmax p ≤56*p.g := by unfold kmax; omegahave ht : (kmax p:ℝ)≤56*p.g := by exact_mod_cast hhhave hg : 3 ≤ (p.g:ℝ) := by exact_mod_cast happly le_trans ?_ (le_of_eq (neg_one_mul _))rw [← add_mul]exact mul_le_mul_of_nonneg_right (by linarith only [ht,hg]) (by positivity)set_option maxHeartbeats 1200000 intheorem veil.score_cost (h : veil p M b r l m s w)(v : Stations p M b.pins s) :∃ δ : ℕ → ℝ,ExpSmall l (fun n=> ((M*n:ℕ):ℝ)) δ ∧∀ᶠ n in l, ∀ (q : Format) (d e : Rates) (x : Typus p q d e) (k : Fin (2^deckMax p b.pins)),|arena (v n) x (m n) (w n) k|≤δ n := bylet N:=fun n : ℕ=> M*n; let z:=fun n=>((N n):ℝ)have hq := h.easelhave ht := hq.enter.firsthave hz : Tendsto z l atTop := (trend_sizes l h.timeL ht.hM).2let C n:= ((s n).amount (w n))⁻¹have hc := h.durableS.mass.inv_caplet δ n := bp (-1*z n)*C n*C n + bp (-0.005*z n)*2have hd : ExpSmall l z δ :=(((ExpSmall.bp_n zero_lt_one).mul hc).mul hc).add hz((ExpSmall.bp_n (by norm_num)).mul (expO_const hz _))refine ⟨δ,hd,?_⟩filter_upwards [h.moment,h.durableS.mass.positive,h.durableS.shape,hq.secure.filter_mono h.timeL]with n hn hN hA hB q d e x khave hm := hn.1.lawrw [abs_of_nonneg (arena_pos _ _ _ _ _ hN hm)]let u:=(s n).sap (w n)refine (arena_bound (v n) x _ _ k hA.1 hm hN hB).trans ?_have hμ i : 0≤u i := (LeafMixture.sapLaw hN hm).nz _have hk i : u i ≤ C n*w n i := LeafMixture.upper_sap hm hN ihave hv (x:UnitType p n (N n) × UnitType p n (N n)) :pairW u u x ≤ (C n*C n)*pairW (w n) (w n) x :=(mul_le_mul (hk _) (hk _) (hμ _) ((hμ _).trans (hk _))).trans_eq (by unfold pairW; ring)have hf : pr (pairW u u) (clash p (m n) (N n)) ≤(C n*C n)*bp (-100*p.g * (z n)) := (pr_cap hv _).trans(mul_le_mul_of_nonneg_left hn.2.2.2.le (mul_self_nonneg _))unfold δrw [mul_comm _ 2]refine add_le_add_left ((mul_le_mul_of_nonneg_left hf (bp_pos _).le).trans ?_) _calc _ = (beamPrice p (N n) * bp (-100 * p.g * z n))*(C n*C n) := by unfold beamPrice N; ring_ ≤ _ := (mul_le_mul_of_nonneg_right (beam_cost p (N n) ht.hG) (mul_self_nonneg _)).trans_eq(by unfold z; rw [neg_one_mul,mul_assoc])structure Align (b : PreparationParameters) (r : ℕ) (p : Shape) (M n : ℕ) (m : Mixer p n)(u : Wgt (UnitType p n (M*n))) : Prop whererum : binaryGood mhymn : unaryGood m b.pins rage : 2*p.r ≤ ncols : 2*num (Full p n)<(M*n:ℕ)drain : Template.drained m b.spJoint uset_option maxHeartbeats 1200000 intheorem veil.upright (h : veil p M b r l m s w) :∀ᶠ n in l,Align b r p M n (m n) ((s n).sap (w n)) := bylet z n:= ((M*n:ℕ):ℝ)have ht := h.easel.enter.firsthave hM : 1 ≤ (M:ℝ) := by exact_mod_cast ht.hMlet e : �� := 1/(128*M)have he : 0< e:=by unfold e; positivityhave hz := (trend_sizes l h.timeL ht.hM).2let D n:=((s n).amount (w n))⁻¹filter_upwards [h.moment,h.durableS.mass.inv_cap e he,h.durableS.mass.positive,expO_const hz b.L e he, ht.wrap.filter_mono h.timeL,(eventually_ge_atTop (2*p.r)).filter_mono h.timeL] with n hn he' ht' hL hG hHhave hw := hn.1.lawhave h1 (i) := LeafMixture.upper_sap hw ht' ihave h2 : 0≤D n := (inv_pos_of_pos ht').lehave hB : D n * b.L ≤ bp (1/32*(n:ℝ)) := byhave hi : e*z n=(1/128)*(n:ℝ) := by unfold e z; push_cast; field_simpcalc _ ≤ bp (e*z n)*bp (e*z n) :=mul_le_mul ((le_abs_self _).trans he') ((le_abs_self _).trans hL) ht.early.hL(bp_pos _).le_ ≤ _ := by rw [←bp_add,hi]; apply bp_le; linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]have hv := LeafMixture.upperSide hn.1.border h1 h2 hBrefine ⟨hn.2.2.1,hn.2.1,hH,hG.1, LeafMixture.sapLaw ht' hw, hv true,hv false,fun i=>?_⟩have hh := hn.1.total iapply ((h1 i).trans (mul_le_mul_of_nonneg_left hh h2)).transrw [←mul_assoc]refine mul_le_mul_of_nonneg_right ?_ (mul_nonneg (raw_nonneg ..) (raw_nonneg ..))have hx : e ≤1 := by unfold e; exact (div_le_iff₀ (by positivity)).mpr (by linarith)refine (mul_le_mul_of_nonneg_right ((le_abs_self _).trans he') (bp_pos _).le).trans ?_rw [←bp_add]unfold spJoint; refine bp_le ?_; rw [←add_mul]exact mul_le_mul_of_nonneg_right (by linarith only [hx]) (by positivity)end PreparationParametersend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import OAI.Combinatorics.HadwigerCounterexample.PairedMassIdentitiesimport OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBoundsimport OAI.Combinatorics.HadwigerCounterexample.RecursiveComparisonErrorsimport OAI.Combinatorics.HadwigerCounterexample.MixerExistencenamespace OAI/-! # Analytic Parameters -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrixopen scoped BigOperators Topologyopen StatusAnalysis StatusAnalysis.Stationdef frameBills (g K : ℕ) :=2*Fintype.card (Comp g)*K*qorth Kstructure AnalyticParameters (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ) : Prop whereenter : b.entry p Mthickness : 4≤ Mprofiles : 2*profileA p b.pins < rjump : 1≤p.JbigJ : r≤p.Jgleaming : bp (-((p.J-r:ℕ):ℝ))*bp r < glintRate b.pinspenRoom : (b.pins+1)*qorth b.pins≤p.j+1forbid : frameBills p.g b.pins+1000 ≤ b.Bspare : 3*b.B < Fintype.card (Label p.b)secure : ∀ᶠ n : ℕ in atTop, Station.earnsScore p n (M*n) b.pins (2*b.ζ)namespace PreparationParametersvariable {b : PreparationParameters} {p : Shape} {N M r : ℕ} {l : Filter ℕ} {m : cycleM p}{s : rhythms p M} {w : tale p M}def conflicted {n : ℕ} (p : Shape) (m : Mixer p n) (N : ℕ) (w : Wgt (UnitType p n N)) :=pr (pairW w w) (clash p m N)<bp (-100*p.g*(N:ℝ))structure veil (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ)(l : Filter ℕ) (m : cycleM p) (s : rhythms p M) (w : tale p M) : Prop whereeasel : AnalyticParameters p M b rtimeL : l≤atTopdurableS : b.durable l p M m w smoment : ∀ᶠ n in l,b.nascent p (M*n) (w n) (m n) ∧ unaryGood (m n) b.pins r ∧binaryGood (m n) ∧ conflicted p (m n) (M*n) (w n)abbrev Stations (p : Shape) (M K : ℕ) (s : rhythms p M) :=∀ n : ℕ, Station p n (M*n) K (s n)theorem beam_cost (p : Shape) (N : ℕ) (h : 3≤p.g) :beamPrice p N * bp (-100*p.g*(N:ℝ)) ≤ bp (-(N:ℝ)) := byunfold beamPrice; rw [←bp_add]; refine bp_le ?_have hh : kmax p ≤56*p.g := by unfold kmax; omegahave ht : (kmax p:ℝ)≤56*p.g := by exact_mod_cast hhhave hg : 3 ≤ (p.g:ℝ) := by exact_mod_cast happly le_trans ?_ (le_of_eq (neg_one_mul _))rw [← add_mul]exact mul_le_mul_of_nonneg_right (by linarith only [ht,hg]) (by positivity)set_option maxHeartbeats 1200000 intheorem veil.score_cost (h : veil p M b r l m s w)(v : Stations p M b.pins s) :∃ δ : ℕ → ℝ,ExpSmall l (fun n=> ((M*n:ℕ):ℝ)) δ ∧∀ᶠ n in l, ∀ (q : Format) (d e : Rates) (x : Typus p q d e) (k : Fin (2^deckMax p b.pins)),|arena (v n) x (m n) (w n) k|≤δ n := bylet N:=fun n : ℕ=> M*n; let z:=fun n=>((N n):ℝ)have hq := h.easelhave ht := hq.enter.firsthave hz : Tendsto z l atTop := (trend_sizes l h.timeL ht.hM).2let C n:= ((s n).amount (w n))⁻¹have hc := h.durableS.mass.inv_caplet δ n := bp (-1*z n)*C n*C n + bp (-0.005*z n)*2have hd : ExpSmall l z δ :=(((ExpSmall.bp_n zero_lt_one).mul hc).mul hc).add hz((ExpSmall.bp_n (by norm_num)).mul (expO_const hz _))refine ⟨δ,hd,?_⟩filter_upwards [h.moment,h.durableS.mass.positive,h.durableS.shape,hq.secure.filter_mono h.timeL]with n hn hN hA hB q d e x khave hm := hn.1.lawrw [abs_of_nonneg (arena_pos _ _ _ _ _ hN hm)]let u:=(s n).sap (w n)refine (arena_bound (v n) x _ _ k hA.1 hm hN hB).trans ?_have hμ i : 0≤u i := (LeafMixture.sapLaw hN hm).nz _have hk i : u i ≤ C n*w n i := LeafMixture.upper_sap hm hN ihave hv (x:UnitType p n (N n) × UnitType p n (N n)) :pairW u u x ≤ (C n*C n)*pairW (w n) (w n) x :=(mul_le_mul (hk _) (hk _) (hμ _) ((hμ _).trans (hk _))).trans_eq (by unfold pairW; ring)have hf : pr (pairW u u) (clash p (m n) (N n)) ≤(C n*C n)*bp (-100*p.g * (z n)) := (pr_cap hv _).trans(mul_le_mul_of_nonneg_left hn.2.2.2.le (mul_self_nonneg _))unfold δrw [mul_comm _ 2]refine add_le_add_left ((mul_le_mul_of_nonneg_left hf (bp_pos _).le).trans ?_) _calc _ = (beamPrice p (N n) * bp (-100 * p.g * z n))*(C n*C n) := by unfold beamPrice N; ring_ ≤ _ := (mul_le_mul_of_nonneg_right (beam_cost p (N n) ht.hG) (mul_self_nonneg _)).trans_eq(by unfold z; rw [neg_one_mul,mul_assoc])structure Align (b : PreparationParameters) (r : ℕ) (p : Shape) (M n : ℕ) (m : Mixer p n)(u : Wgt (UnitType p n (M*n))) : Prop whererum : binaryGood mhymn : unaryGood m b.pins rage : 2*p.r ≤ ncols : 2*num (Full p n)<(M*n:ℕ)drain : Template.drained m b.spJoint uset_option maxHeartbeats 1200000 intheorem veil.upright (h : veil p M b r l m s w) :∀ᶠ n in l,Align b r p M n (m n) ((s n).sap (w n)) := bylet z n:= ((M*n:ℕ):ℝ)have ht := h.easel.enter.firsthave hM : 1 ≤ (M:ℝ) := by exact_mod_cast ht.hMlet e : ℝ := 1/(128*M)have he : 0< e:=by unfold e; positivityhave hz := (trend_sizes l h.timeL ht.hM).2let D n:=((s n).amount (w n))⁻¹filter_upwards [h.moment,h.durableS.mass.inv_cap e he,h.durableS.mass.positive,expO_const hz b.L e he, ht.wrap.filter_mono h.timeL,(eventually_ge_atTop (2*p.r)).filter_mono h.timeL] with n hn he' ht' hL hG hHhave hw := hn.1.lawhave h1 (i) := LeafMixture.upper_sap hw ht' ihave h2 : 0≤D n := (inv_pos_of_pos ht').lehave hB : D n * b.L ≤ bp (1/32*(n:ℝ)) := byhave hi : e*z n=(1/128)*(n:ℝ) := by unfold e z; push_cast; field_simpcalc _ ≤ bp (e*z n)*bp (e*z n) :=mul_le_mul ((le_abs_self _).trans he') ((le_abs_self _).trans hL) ht.early.hL(bp_pos _).le_ ≤ _ := by rw [←bp_add,hi]; apply bp_le; linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]have hv := LeafMixture.upperSide hn.1.border h1 h2 hBrefine ⟨hn.2.2.1,hn.2.1,hH,hG.1, LeafMixture.sapLaw ht' hw, hv true,hv false,fun i=>?_⟩have hh := hn.1.total iapply ((h1 i).trans (mul_le_mul_of_nonneg_left hh h2)).transrw [←mul_assoc]refine mul_le_mul_of_nonneg_right ?_ (mul_nonneg (raw_nonneg ..) (raw_nonneg ..))have hx : e ≤1 := by unfold e; exact (div_le_iff₀ (by positivity)).mpr (by linarith)refine (mul_le_mul_of_nonneg_right ((le_abs_self _).trans he') (bp_pos _).le).trans ?_rw [←bp_add]unfold spJoint; refine bp_le ?_; rw [←add_mul]exact mul_le_mul_of_nonneg_right (by linarith only [hx]) (by positivity)end PreparationParametersend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148import OAI.Combinatorics.HadwigerCounterexample.QuadraticTestersimport OAI.Combinatorics.HadwigerCounterexample.KeyDirectionsimport OAI.Combinatorics.HadwigerCounterexample.SumRankBoundsnamespace OAI/-! # Atom Flavors -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Finset Functionopen scoped BigOperatorsvariable {g r n b : ℕ} {p : Shape}abbrev Flavor (g : ℕ) := Option (Option (Finset (Tag g × Tag g)))namespace Flavorabbrev full {g : ℕ} : Flavor g := noneabbrev sharedOnly {g : ℕ} : Flavor g := some noneabbrev pure {g : ℕ} (s : Finset (Tag g × Tag g)) : Flavor g := some (some s)def keeps (f : Flavor g) (x : Tag g) (y : Block g) : Prop :=match f,y with| none, .inl (i,_) => allowed i x| some none,.inl _ => False| some (some s),.inl (i,j) => allowed i x ∧ (i,j) ∈ s| some (some _), .inr v => v≠0| _, .inr _ => Trueinstance (f : Flavor g) (x : Tag g) (y : Block g) : Decidable (keeps f x y) :=Classical.propDecidable _theorem keep_o {f : Flavor g} {x : Tag g} {i j}(h : keeps f x (Block.O i j)) : allowed i x := byrcases f with (_|_|_) <;> simp [keeps] at h· exact hexact h.1theorem keepZ (f : Flavor g) (x : Tag g) : keeps f x Block.Z := byrcases f with (_|_|_) <;> simp [keeps]theorem keepSharp (f : Flavor g) (x : Tag g) : keeps f x Block.sharp := byrcases f with (_|_|_) <;> simp [keeps]end Flavorabbrev Knobs (g n : ℕ) := Block g → Vec (Fin n)def lit (f : Flavor g) (x : Tag g) (y : Knobs g n) : Base g n :=fun i => if f.keeps x i.1 then y i.1 i.2 else 0theorem lit_allows (f : Flavor g) (x : Tag g) (y : Knobs g n) :allows x (lit f x y) :=fun _ _ h _ => ite_eq_right (fun g => h (Flavor.keep_o g))def useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b) (f : Flavor p.g)(y : Knobs p.g n) := atom p x s (lit f x y)theorem mem_useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b)(f : Flavor p.g) (y : Knobs p.g n) : useAtom p x s f y∈Xspace p n :=atom_mem s (lit_allows f x y)abbrev ProbeIdx (g : ℕ) := (Tag g × Tag g)⊕Unitabbrev Digest (g : ℕ) := Vec (ProbeIdx g)def asBlock (i : ProbeIdx g) : Block g := i.elim (fun q => Block.O q.1 q.2) (fun _ => Block.S)theorem asBlock_inj {g : ℕ} : Injective (@asBlock g) := byrintro (⟨i,j⟩|⟨⟩) (⟨k,l⟩|⟨⟩) e <;> simp_all [asBlock,Block.O,Block.S]def zget (y : Vec (Fin n)) (i : ℕ) := if h:i<n then y ⟨i,h⟩ else 0def tested (r : ℕ) (y : Vec (Fin n)) :=∑ i : Fin r,zget y (2*i.val)*zget y (2*i.val+1)def scan (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :Digest p.g :=fun i => if Flavor.keeps f l (asBlock i) then tested p.r (x (asBlock i)) else 0namespace Digestvariable (q : Digest g)def feasible (l : Tag g) (f : Flavor g) := ∀ i,¬ Flavor.keeps f l (asBlock i) → q i=0def diagO := ∑ d : Tag g, ∑ t,q (.inl (d,t))def sumBit := q.diagO+q (.inr ())end Digesttheorem scan_feasible (p : Shape) {n} (l) (f : Flavor p.g) (x : Knobs p.g n) :(scan p l f x).feasible l f := fun _ h => ite_eq_right htheorem scan_is (p : Shape) {n} (l) (s : Label p.b) (f : Flavor p.g) (x : Knobs p.g n)(i : ProbeIdx p.g) :scan p l f x i=etab p n (asBlock i) (mom p s (lit f l x)) := byclassicalrw [mom,etab_point]let d := asBlock iunfold scansplit· rename_i hehave hg j : readBit (lit f l x) d j=zget (x d) j := byby_cases h : j<n <;> simp [readBit,zget,h,lit,d,he]unfold tested testsimp_rw [show ∀ j, readBit (lit f l x) (asBlock i) j=zget (x (asBlock i)) j from hg]rename_i heunfold testhave hZ j :readBit (lit f l x) (asBlock i) j=0 := byby_cases h : j<n <;> simp [readBit,lit,h,he]simp_rw [hZ,zero_mul,Finset.sum_const_zero]theorem etaScan (p : Shape) {n} (l s f) (x : Knobs p.g n) :(scan p l f x).sumBit=eta p n (mom p s (lit f l x)) := bysimp only [Digest.sumBit,Digest.diagO,eta,etaO,LinearMap.add_apply,LinearMap.sum_apply]simp_rw [scan_is p l s]rfltheorem role_scan (p : Shape) {n} (l s f) (x : Knobs p.g n) :role p n (useAtom p l s f x)=(scan p l f x).diagO := byunfold Digest.diagO useAtom atomlet M := mom p s (lit f l x)have h (i : Tag p.g) :(Pi.single l M : Tag p.g → Moment p n) i∈Wtag p n i := byby_cases h : i=l· subst i; rw [Pi.single_eq_same]exact Submodule.subset_span ⟨_,_,lit_allows f l x,rfl⟩simp [h]rw [role_cut _ _ h,Finset.sum_eq_single l]· rw [Pi.single_eq_same,etaO,LinearMap.sum_apply]simp_rw [LinearMap.sum_apply,scan_is p l s]rfl· intro i _ hi; simp [hi]simpdef dialed (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :=(scan p l f x).sumBitdef spins (p : Shape) (n : ℕ) : Wgt (Knobs p.g n) := draws (Block p.g) uniftheorem spins_law (p : Shape) (n : ℕ) : IsLaw (spins p n) := draws_law unif_law/-- Projection notation for conditioning on a specified (possible)diagnostic or diagonal only. -/def scopedBit (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (q : F) :Wgt (Knobs p.g n) := onW (spins p n) (fun x => dialed p l f x=q)def scopedScan (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (z : Digest p.g) :Wgt (Knobs p.g n) := onW (spins p n) (fun x => scan p l f x=z)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148import OAI.Combinatorics.HadwigerCounterexample.QuadraticTestersimport OAI.Combinatorics.HadwigerCounterexample.KeyDirectionsimport OAI.Combinatorics.HadwigerCounterexample.SumRankBoundsnamespace OAI/-! # Atom Flavors -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Finset Functionopen scoped BigOperatorsvariable {g r n b : ℕ} {p : Shape}abbrev Flavor (g : ℕ) := Option (Option (Finset (Tag g × Tag g)))namespace Flavorabbrev full {g : ℕ} : Flavor g := noneabbrev sharedOnly {g : ℕ} : Flavor g := some noneabbrev pure {g : ℕ} (s : Finset (Tag g × Tag g)) : Flavor g := some (some s)def keeps (f : Flavor g) (x : Tag g) (y : Block g) : Prop :=match f,y with| none, .inl (i,_) => allowed i x| some none,.inl _ => False| some (some s),.inl (i,j) => allowed i x ∧ (i,j) ∈ s| some (some _), .inr v => v≠0| _, .inr _ => Trueinstance (f : Flavor g) (x : Tag g) (y : Block g) : Decidable (keeps f x y) :=Classical.propDecidable _theorem keep_o {f : Flavor g} {x : Tag g} {i j}(h : keeps f x (Block.O i j)) : allowed i x := byrcases f with (_|_|_) <;> simp [keeps] at h· exact hexact h.1theorem keepZ (f : Flavor g) (x : Tag g) : keeps f x Block.Z := byrcases f with (_|_|_) <;> simp [keeps]theorem keepSharp (f : Flavor g) (x : Tag g) : keeps f x Block.sharp := byrcases f with (_|_|_) <;> simp [keeps]end Flavorabbrev Knobs (g n : ℕ) := Block g → Vec (Fin n)def lit (f : Flavor g) (x : Tag g) (y : Knobs g n) : Base g n :=fun i => if f.keeps x i.1 then y i.1 i.2 else 0theorem lit_allows (f : Flavor g) (x : Tag g) (y : Knobs g n) :allows x (lit f x y) :=fun _ _ h _ => ite_eq_right (fun g => h (Flavor.keep_o g))def useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b) (f : Flavor p.g)(y : Knobs p.g n) := atom p x s (lit f x y)theorem mem_useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b)(f : Flavor p.g) (y : Knobs p.g n) : useAtom p x s f y∈Xspace p n :=atom_mem s (lit_allows f x y)abbrev ProbeIdx (g : ℕ) := (Tag g × Tag g)⊕Unitabbrev Digest (g : ℕ) := Vec (ProbeIdx g)def asBlock (i : ProbeIdx g) : Block g := i.elim (fun q => Block.O q.1 q.2) (fun _ => Block.S)theorem asBlock_inj {g : ℕ} : Injective (@asBlock g) := byrintro (⟨i,j⟩|⟨⟩) (⟨k,l⟩|⟨⟩) e <;> simp_all [asBlock,Block.O,Block.S]def zget (y : Vec (Fin n)) (i : ℕ) := if h:i<n then y ⟨i,h⟩ else 0def tested (r : ℕ) (y : Vec (Fin n)) :=∑ i : Fin r,zget y (2*i.val)*zget y (2*i.val+1)def scan (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :Digest p.g :=fun i => if Flavor.keeps f l (asBlock i) then tested p.r (x (asBlock i)) else 0namespace Digestvariable (q : Digest g)def feasible (l : Tag g) (f : Flavor g) := ∀ i,¬ Flavor.keeps f l (asBlock i) → q i=0def diagO := ∑ d : Tag g, ∑ t,q (.inl (d,t))def sumBit := q.diagO+q (.inr ())end Digesttheorem scan_feasible (p : Shape) {n} (l) (f : Flavor p.g) (x : Knobs p.g n) :(scan p l f x).feasible l f := fun _ h => ite_eq_right htheorem scan_is (p : Shape) {n} (l) (s : Label p.b) (f : Flavor p.g) (x : Knobs p.g n)(i : ProbeIdx p.g) :scan p l f x i=etab p n (asBlock i) (mom p s (lit f l x)) := byclassicalrw [mom,etab_point]let d := asBlock iunfold scansplit· rename_i hehave hg j : readBit (lit f l x) d j=zget (x d) j := byby_cases h : j<n <;> simp [readBit,zget,h,lit,d,he]unfold tested testsimp_rw [show ∀ j, readBit (lit f l x) (asBlock i) j=zget (x (asBlock i)) j from hg]rename_i heunfold testhave hZ j :readBit (lit f l x) (asBlock i) j=0 := byby_cases h : j<n <;> simp [readBit,lit,h,he]simp_rw [hZ,zero_mul,Finset.sum_const_zero]theorem etaScan (p : Shape) {n} (l s f) (x : Knobs p.g n) :(scan p l f x).sumBit=eta p n (mom p s (lit f l x)) := bysimp only [Digest.sumBit,Digest.diagO,eta,etaO,LinearMap.add_apply,LinearMap.sum_apply]simp_rw [scan_is p l s]rfltheorem role_scan (p : Shape) {n} (l s f) (x : Knobs p.g n) :role p n (useAtom p l s f x)=(scan p l f x).diagO := byunfold Digest.diagO useAtom atomlet M := mom p s (lit f l x)have h (i : Tag p.g) :(Pi.single l M : Tag p.g → Moment p n) i∈Wtag p n i := byby_cases h : i=l· subst i; rw [Pi.single_eq_same]exact Submodule.subset_span ⟨_,_,lit_allows f l x,rfl⟩simp [h]rw [role_cut _ _ h,Finset.sum_eq_single l]· rw [Pi.single_eq_same,etaO,LinearMap.sum_apply]simp_rw [LinearMap.sum_apply,scan_is p l s]rfl· intro i _ hi; simp [hi]simpdef dialed (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :=(scan p l f x).sumBitdef spins (p : Shape) (n : ℕ) : Wgt (Knobs p.g n) := draws (Block p.g) uniftheorem spins_law (p : Shape) (n : ℕ) : IsLaw (spins p n) := draws_law unif_law/-- Projection notation for conditioning on a specified (possible)diagnostic or diagonal only. -/def scopedBit (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (q : F) :Wgt (Knobs p.g n) := onW (spins p n) (fun x => dialed p l f x=q)def scopedScan (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (z : Digest p.g) :Wgt (Knobs p.g n) := onW (spins p n) (fun x => scan p l f x=z)end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277import OAI.Combinatorics.HadwigerCounterexample.ResponseAnnihilatorsnamespace OAI/-! # Attack Cut Decomposition -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Submodule LinearMap Module Finsetopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}variable {I J : Type} [Fintype I] [Fintype J]theorem colSp_kill (S : Space (Vec I)) (M : Mat I J) :colSp M ≤ annih S ↔ ∀ x∈S,Mᵀ *ᵥ x=0 := byconstructor· intro h x hxrefine dot_ext_zero fun y => ?_rw [dotProduct_transpose_mulVec,dotProduct_comm]exact (annih_mem ..).mp (h ⟨y,rfl⟩) x hxrintro h z ⟨y,rfl⟩rw [annih_mem]; intro x hxrw [dotProduct_comm,mulVecLin_apply,←dotProduct_transpose_mulVec,h x hx,dotProduct_zero]theorem box_kill {S : Space (Vec I)} {T : Space (Vec J)} {M : Mat I J} :M∈box (annih S) (annih T) ↔ (∀ x∈S,Mᵀ *ᵥ x=0) ∧ (∀ y ∈ T,M *ᵥ y=0) := byrw [box_mem,colSp_kill,colSp_kill,transpose_transpose]theorem orth_sub {f b : Plan p n} {x y : Xpair p n} {C : ChanOut p n} {j}(hx : orth p C f b j x) (hy : orth p C f b j y) : orth p C f b j (x-y) := byintro D hd A ha; rw [map_sub,hx _ hd _ ha,hy _ hd _ ha,sub_self]theorem orth_sum {f b : Plan p n} (x : I→Xpair p n) (c : I→F) {C : ChanOut p n} {j}(hx : ∀ i,orth p C f b j (x i)) : orth p C f b j (∑ i,c i • x i) := byintro D hd A harw [map_sum]refine Finset.sum_eq_zero fun i _ => ?_rw [map_smul,hx i _ hd _ ha,smul_zero]namespace Volleyvariable (v : Volley p n I)def strike (t : Tagging p I) (ht : v.legal t) (j : I) : Xpair p n :=Pi.single (v.obj j) (⟨v.atomAt t j,atom_mem _ (ht j)⟩ : Xspace p n)theorem strike_here (t : Tagging p I) (ht : v.legal t)(c : I → F) (i : Bool) :((∑ j : I, c j • v.strike t ht j) i).val=∑ j∈v.here i,c j • v.atomAt t j := byclassicalrw [Finset.sum_apply]simp only [Submodule.coe_sum, Pi.smul_apply,Submodule.coe_smul,here,Finset.sum_filter]refine Finset.sum_congr rfl fun j _ => ?_by_cases h : v.obj j=i· simp only [ite_eq_left h]unfold strikerw [h,Pi.single_eq_same]simp [strike,h]omit [Fintype I] intheorem strike_pair (t : Tagging p I) (ht : v.legal t) (j : I) (e : Comp p.g) :purePair p n (v.strike t ht j) e=if inc e (t j) then vecMulVec (v.rayLoc j) (v.rayLoc j) else 0 := byclassicalsimp only [purePair, Finset.sum_apply]rw [Finset.sum_eq_single (v.obj j)]· rw [strike,Pi.single_eq_same]change liftM _ _ (atom p _ _ _ e)=_rw [atom_def]; split· exact liftM_outer _ _ _ _rw [map_zero]· intro i _ hi; rw [strike,Pi.single_eq_of_ne hi]; exact map_zero _simptheorem strike_orth {a b : Plan p n} {C : ChanOut p n} {i : Bool}(t : Tagging p I) (ht : v.legal t) (j : I) :orth p C (v.frozen a t) b i (v.strike t ht j) := byintro D hd A hachange ∑ e, _ = _refine Finset.sum_eq_zero fun e _ => ?_rw [v.strike_pair]by_cases h : inc e (t j)· have hy (z) : v.rayLoc j ∈ (v.frozen a t (e,z)) :=Submodule.mem_sup_right (colSp_mem (P:=v.keyM t e) (⟨j,h⟩ : visits p t e))let V := v.rayLoc jhave h1 : A e *ᵥ V=0 := (box_kill.mp ((pureSpace_mem _).mp ha e)).2 V (hy false)have h2 (z) : D (e,z) *ᵥ V=0 :=(box_kill.mp ((deltaSpace_mem _).mp hd _)).2 V (hy z)rw [ite_eq_left h,mpair_outer,evmat]change dotProduct V (((C (e,true))ᵀ * D (e,false)+(D (e,true))ᵀ * C (e,false)+A e) *ᵥ V)=_simp only [Matrix.add_mulVec, ← Matrix.mulVec_mulVec,h1,h2,mulVec_zero,dotProduct_zero,zero_add,add_zero,dotProduct_transpose_mulVec]rw [ite_eq_right h,map_zero]end Volleydef labStruct (p : Shape) (n : ℕ) (M : Moment p n) (R : ℕ)(L : Finset (Label p.b)) (Z : Label p.b→BaseMat p n) :=M=labelSum p L Z ∧ L.card ≤ R ∧ (∀ s,s∉L → Z s=0) ∧∀ s∈L,(Z s)ᵀ=Z s ∧ ∀ i,Z s i i=Z s none iprivate theorem struct_tri {M1 M2 M3 : Moment p n} {R : ℕ}{L1 L2 L3 : Finset (Label p.b)} {Z1 Z2 Z3 : Label p.b→BaseMat p n}(h1 : labStruct p n M1 R L1 Z1)(h2 : labStruct p n M2 R L2 Z2)(h3 : labStruct p n M3 R L3 Z3)(hr : 3*R≤p.j) (hm : M1+M2+M3=0) (s : Label p.b) :Z1 s+Z2 s+Z3 s=0 := byclassicallet W := L1∪L2∪L3have hs1 : L1⊆W := subset_trans subset_union_left subset_union_lefthave hs2 : L2⊆W := subset_trans subset_union_right subset_union_lefthave hs3 : L3⊆W := subset_union_righthave hh : W.card ≤ p.j+1 :=(Finset.card_union_le (L1∪L2) L3).trans ((add_le_add((Finset.card_union_le L1 L2).trans (add_le_add h1.2.1 h2.2.1)) h3.2.1).trans (by omega))by_cases hs : s∈W· have hv {M : Moment p n} {L Z} (h : labStruct p n M R L Z) (hL : L ⊆ W)(i j : AIdx p.g n) (r : SelIdx p.b p.j) :(∑ s∈W,Z s i j*monoBit s r.val) = M (r,i) (emptySel,j) := byrw [h.1,labelSum, Matrix.sum_apply,←Finset.sum_subset hL]· simp only [mput_apply,emptySel,monoBit,Finset.prod_empty,mul_one,mul_comm]intro y _ hysimp [h.2.2.1 y hy]ext i jrefine selector_indep W (fun s => (Z1 s i j+Z2 s i j+Z3 s i j)) p.j hh ?_ s hsintro T hTlet r : SelIdx p.b p.j := ⟨T,hT⟩simp only [add_mul,Finset.sum_add_distrib]rw [hv h1 hs1 i j r,hv h2 hs2 i j r,hv h3 hs3 i j r]exact congr_fun (congr_fun hm (r,i)) (emptySel,j)rw [h1.2.2.1 s (fun h => hs (hs1 h)), h2.2.2.1 s (fun h => hs (hs2 h)),h3.2.2.1 s (fun h => hs (hs3 h)), zero_add,zero_add]namespace Volleyvariable {v : Volley p n I}private theorem orth_structure {x : Xpair p n} {a b : Plan p n}{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}(hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x)(R : ℕ) (hr : 2*planRank a+28≤R) (hj : 6*R+4 ≤ p.j)(i : Bool) (e : Comp p.g) :∃ L Z,labStruct p n ((x i).val e) R L Z := byclassicalhave h (z) := v.frozen_here_dim hb a t i zhave he : ((x i).val e).rank ≤ R :=(rank_vanish (vanish_one ho i e)).trans((Nat.add_le_add (h (e,true)) (h (e,false))).trans (by omega))have hf : ((x i).val e)∈ Wspace p n := byobtain ⟨w,h,hx⟩ := mem_X.mp (x i).propertyrw [← hx]exact ((Wspace p n).add_mem ((Wtag_le _) (h e.val.1)) ((Wtag_le _) (h e.val.2)))obtain ⟨L,Z,hL,_,hZ,hA⟩ := label_support hf R hj helet g (s : Label p.b) := if s∈L then Z s else 0refine ⟨L,g,?_,hL,(fun s hs => ite_eq_right hs), fun s hs => ?_⟩· rw [hZ]exact Finset.sum_congr rfl fun s hs => by simp [g,hs]simp only [g,ite_eq_left hs]exact hA _ hsprivate theorem edge_at (l : Tag p.g) (e : Comp p.g) (h : inc e l) :∃ (k : Tag p.g) (h : l≠k),e = edge l k h := byrcases e with ⟨⟨i,j⟩,hj⟩change i=l∨j=l at hrcases h with rfl|rfl· exact ⟨j,hj.ne,(edge_eq hj).symm⟩exact ⟨i,hj.ne.symm, by rw [edge_symm,edge_eq hj]⟩private theorem cut_tri {x : Profile p n} (hx : x∈Xspace p n)(l k j : Tag p.g) (h : l≠k) (h' : l ≠ j) (h'' : k≠j) :x (edge l k h)+x (edge l j h')+x (edge k j h'')=0 := byobtain ⟨w,hv,rfl⟩ := mem_X.mp hxrw [← getPair_edge l k h (cut p n w), ←getPair_edge l j h' (cut p n w), ←getPair_edge k j h'' (cut p n w),getPair_cut,getPair_cut,getPair_cut]have he (x y z : Moment p n) : x+y+(x+z)+(y+z)=0 := calc_ = (x+x)+(y+y)+(z+z) := by ac_rfl_ = _ := by simp only [char_two]exact he _ _ _private theorem structure_mark {x : Xpair p n} {a b : Plan p n}{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}{q R : ℕ} (hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)(hr : 6*R+4≤p.j) (hq : R+14≤q)(l : I){L : Comp p.g → Finset (Label p.b)} {Z : Comp p.g → Label p.b → BaseMat p n}(he : ∀ e,labStruct p n ((x (v.obj l)).val e) R (L e) (Z e)) :∃ c : F, ∀ e,mput p (v.sel l) (Z e (v.sel l))=c • v.atomAt t l e := byclassicallet s := v.sel llet u := t llet M := vecMulVec (baseV (v.par l)) (baseV (v.par l))let coeff := fun e : Comp p.g => Z e s none nonehave h1 (e : Comp p.g) : Z e s= if inc e u then coeff e • M else 0 := byhave ⟨hE,hL,hT,hH⟩ := he eexact mark_atom hb t hv l e _ (le_trans (Nat.add_le_add_right hL 14) hq)_ hT hH (hE ▸ vanish_one ho (v.obj l) e)have h2 (e f : Comp p.g) (h : inc e u) (h' : inc f u) :coeff e=coeff f := byby_cases hi : e=f· rw [hi]obtain ⟨k,hk,rfl⟩ := edge_at u e hobtain ⟨u2,hl,rfl⟩ := edge_at u f h'have hj : k ≠ u2 := by rintro rfl; exact hi rflhave hh := cut_tri (x (v.obj l)).property u k u2 hk hl hjhave heq := struct_tri (he (edge u k hk)) (he (edge u u2 hl)) (he (edge k u2 hj))(by omega) hh shave hn : ¬ inc (edge k u2 hj) u := fun he => byrcases (inc_edge_iff _).mp he with h|h; exact hk h.symm; exact hl h.symmrw [h1 (edge k u2 hj), ite_eq_right hn,add_zero] at heqhave h0 := congr_fun (congr_fun heq none) nonechange coeff _ + coeff _ = 0 at h0exact add_right_cancel (h0.trans (char_two _).symm)have h3 (e) : mput p s (Z e s)= coeff e • v.atomAt t l e := byrw [h1,atomAt,atom_def]by_cases hf : inc e u· rw [ite_eq_left hf,ite_eq_left hf,map_smul]change coeff e • liftM (labMat p n s) (labMat p n s) M=_unfold Mrw [liftM_outer,labMat_act]; rflrw [ite_eq_right hf,ite_eq_right hf,map_zero,smul_zero]by_cases hh : ∃ e,inc e u· obtain ⟨f,hf⟩ := hhrefine ⟨coeff f,fun e => ?_⟩by_cases h : inc e u· exact (h3 e).trans (by rw [h2 e f h hf])refine (h3 e).trans ?_rw [atomAt,atom_def,ite_eq_right h,smul_zero,smul_zero]refine ⟨0,fun e => ?_��refine (h3 e).trans ?_rw [atomAt,atom_def,ite_eq_right (show ¬inc e u from fun he => hh ⟨e,he⟩),smul_zero,zero_smul]/-- a component uses at most R nonattack labels. -/def clean (v : Volley p n I) (i : Bool) (R : ℕ) (M : Moment p n) :=∃ (L : Finset (Label p.b)) (Z : Label p.b → BaseMat p n),M=labelSum p L Z ∧ L.card≤R ∧ Disjoint L (v.marked i)theorem split_orth {x : Xpair p n} {a b : Plan p n}{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}{q R : ℕ} (hb : v.bounded w) (ht : v.legal t)(ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)(hr : 6*R+4≤p.j) (hr' : 2*planRank a+28≤R) (hq : R+14≤q) :∃ (c : I → F) (y : Xpair p n), x=y+∑ i,c i • v.strike t ht i ∧orth p C (v.frozen a t) b j y ∧ ∀ i e,v.clean i R ((y i).val e) := byclassicalchoose L Z hZ using orth_structure hb ho R hr' hrchoose c hc using fun l => structure_mark hb ho hv hr hq l (hZ (v.obj l))let A := ∑ i,c i • v.strike t ht irefine ⟨c,x-A,(sub_add_cancel x A).symm,orth_sub ho (orth_sum _ _ (v.strike_orth t ht)),fun i e => ?_⟩obtain ⟨B,h1,hA,hv',h3⟩ := hv ilet T := v.marked ihave he : (A i).val e=labelSum p T (Z i e) := byrw [show (A i).val=_ from v.strike_here t ht c i, Finset.sum_apply]dsimp only [labelSum,T,marked]rw [Finset.sum_image h3]refine Finset.sum_congr rfl fun l hl => ?_have he : v.obj l=i := (mem_filter.mp hl).2exact (he ▸ hc l e).symmlet W := L i erefine ⟨W \ T,Z i e,?_,(Finset.card_le_card sdiff_subset).trans (hZ i e).2.1, ?_⟩· change (x i).val e-(A i).val e=_rw [(hZ i e).1,he]have hz : labelSum p W (Z i e)=labelSum p (W∪T) (Z i e) := byrefine Finset.sum_subset subset_union_left fun s _ hs => ?_rw [(hZ i e).2.2.1 s hs,map_zero]rw [hz]have hS : (W∪T)=(W \ T) ∪ T := by ext i; simprw [hS,labelSum,Finset.sum_union (show Disjoint (W \ T) T from Disjoint.symm disjoint_sdiff)]exact add_sub_cancel_right _ _exact Disjoint.symm disjoint_sdiffend Volleyend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277import OAI.Combinatorics.HadwigerCounterexample.ResponseAnnihilatorsnamespace OAI/-! # Attack Cut Decomposition -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Submodule LinearMap Module Finsetopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}variable {I J : Type} [Fintype I] [Fintype J]theorem colSp_kill (S : Space (Vec I)) (M : Mat I J) :colSp M ≤ annih S ↔ ∀ x∈S,Mᵀ *ᵥ x=0 := byconstructor· intro h x hxrefine dot_ext_zero fun y => ?_rw [dotProduct_transpose_mulVec,dotProduct_comm]exact (annih_mem ..).mp (h ⟨y,rfl⟩) x hxrintro h z ⟨y,rfl⟩rw [annih_mem]; intro x hxrw [dotProduct_comm,mulVecLin_apply,←dotProduct_transpose_mulVec,h x hx,dotProduct_zero]theorem box_kill {S : Space (Vec I)} {T : Space (Vec J)} {M : Mat I J} :M∈box (annih S) (annih T) ↔ (∀ x∈S,Mᵀ *ᵥ x=0) ∧ (∀ y ∈ T,M *ᵥ y=0) := byrw [box_mem,colSp_kill,colSp_kill,transpose_transpose]theorem orth_sub {f b : Plan p n} {x y : Xpair p n} {C : ChanOut p n} {j}(hx : orth p C f b j x) (hy : orth p C f b j y) : orth p C f b j (x-y) := byintro D hd A ha; rw [map_sub,hx _ hd _ ha,hy _ hd _ ha,sub_self]theorem orth_sum {f b : Plan p n} (x : I→Xpair p n) (c : I→F) {C : ChanOut p n} {j}(hx : ∀ i,orth p C f b j (x i)) : orth p C f b j (∑ i,c i • x i) := byintro D hd A harw [map_sum]refine Finset.sum_eq_zero fun i _ => ?_rw [map_smul,hx i _ hd _ ha,smul_zero]namespace Volleyvariable (v : Volley p n I)def strike (t : Tagging p I) (ht : v.legal t) (j : I) : Xpair p n :=Pi.single (v.obj j) (⟨v.atomAt t j,atom_mem _ (ht j)⟩ : Xspace p n)theorem strike_here (t : Tagging p I) (ht : v.legal t)(c : I → F) (i : Bool) :((∑ j : I, c j • v.strike t ht j) i).val=∑ j∈v.here i,c j • v.atomAt t j := byclassicalrw [Finset.sum_apply]simp only [Submodule.coe_sum, Pi.smul_apply,Submodule.coe_smul,here,Finset.sum_filter]refine Finset.sum_congr rfl fun j _ => ?_by_cases h : v.obj j=i· simp only [ite_eq_left h]unfold strikerw [h,Pi.single_eq_same]simp [strike,h]omit [Fintype I] intheorem strike_pair (t : Tagging p I) (ht : v.legal t) (j : I) (e : Comp p.g) :purePair p n (v.strike t ht j) e=if inc e (t j) then vecMulVec (v.rayLoc j) (v.rayLoc j) else 0 := byclassicalsimp only [purePair, Finset.sum_apply]rw [Finset.sum_eq_single (v.obj j)]· rw [strike,Pi.single_eq_same]change liftM _ _ (atom p _ _ _ e)=_rw [atom_def]; split· exact liftM_outer _ _ _ _rw [map_zero]· intro i _ hi; rw [strike,Pi.single_eq_of_ne hi]; exact map_zero _simptheorem strike_orth {a b : Plan p n} {C : ChanOut p n} {i : Bool}(t : Tagging p I) (ht : v.legal t) (j : I) :orth p C (v.frozen a t) b i (v.strike t ht j) := byintro D hd A hachange ∑ e, _ = _refine Finset.sum_eq_zero fun e _ => ?_rw [v.strike_pair]by_cases h : inc e (t j)· have hy (z) : v.rayLoc j ∈ (v.frozen a t (e,z)) :=Submodule.mem_sup_right (colSp_mem (P:=v.keyM t e) (⟨j,h⟩ : visits p t e))let V := v.rayLoc jhave h1 : A e *ᵥ V=0 := (box_kill.mp ((pureSpace_mem _).mp ha e)).2 V (hy false)have h2 (z) : D (e,z) *ᵥ V=0 :=(box_kill.mp ((deltaSpace_mem _).mp hd _)).2 V (hy z)rw [ite_eq_left h,mpair_outer,evmat]change dotProduct V (((C (e,true))ᵀ * D (e,false)+(D (e,true))ᵀ * C (e,false)+A e) *ᵥ V)=_simp only [Matrix.add_mulVec, ← Matrix.mulVec_mulVec,h1,h2,mulVec_zero,dotProduct_zero,zero_add,add_zero,dotProduct_transpose_mulVec]rw [ite_eq_right h,map_zero]end Volleydef labStruct (p : Shape) (n : ℕ) (M : Moment p n) (R : ℕ)(L : Finset (Label p.b)) (Z : Label p.b→BaseMat p n) :=M=labelSum p L Z ∧ L.card ≤ R ∧ (∀ s,s∉L → Z s=0) ∧∀ s∈L,(Z s)ᵀ=Z s ∧ ∀ i,Z s i i=Z s none iprivate theorem struct_tri {M1 M2 M3 : Moment p n} {R : ℕ}{L1 L2 L3 : Finset (Label p.b)} {Z1 Z2 Z3 : Label p.b→BaseMat p n}(h1 : labStruct p n M1 R L1 Z1)(h2 : labStruct p n M2 R L2 Z2)(h3 : labStruct p n M3 R L3 Z3)(hr : 3*R≤p.j) (hm : M1+M2+M3=0) (s : Label p.b) :Z1 s+Z2 s+Z3 s=0 := byclassicallet W := L1∪L2∪L3have hs1 : L1⊆W := subset_trans subset_union_left subset_union_lefthave hs2 : L2⊆W := subset_trans subset_union_right subset_union_lefthave hs3 : L3⊆W := subset_union_righthave hh : W.card ≤ p.j+1 :=(Finset.card_union_le (L1∪L2) L3).trans ((add_le_add((Finset.card_union_le L1 L2).trans (add_le_add h1.2.1 h2.2.1)) h3.2.1).trans (by omega))by_cases hs : s∈W· have hv {M : Moment p n} {L Z} (h : labStruct p n M R L Z) (hL : L ⊆ W)(i j : AIdx p.g n) (r : SelIdx p.b p.j) :(∑ s∈W,Z s i j*monoBit s r.val) = M (r,i) (emptySel,j) := byrw [h.1,labelSum, Matrix.sum_apply,←Finset.sum_subset hL]· simp only [mput_apply,emptySel,monoBit,Finset.prod_empty,mul_one,mul_comm]intro y _ hysimp [h.2.2.1 y hy]ext i jrefine selector_indep W (fun s => (Z1 s i j+Z2 s i j+Z3 s i j)) p.j hh ?_ s hsintro T hTlet r : SelIdx p.b p.j := ⟨T,hT⟩simp only [add_mul,Finset.sum_add_distrib]rw [hv h1 hs1 i j r,hv h2 hs2 i j r,hv h3 hs3 i j r]exact congr_fun (congr_fun hm (r,i)) (emptySel,j)rw [h1.2.2.1 s (fun h => hs (hs1 h)), h2.2.2.1 s (fun h => hs (hs2 h)),h3.2.2.1 s (fun h => hs (hs3 h)), zero_add,zero_add]namespace Volleyvariable {v : Volley p n I}private theorem orth_structure {x : Xpair p n} {a b : Plan p n}{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}(hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x)(R : ℕ) (hr : 2*planRank a+28≤R) (hj : 6*R+4 ≤ p.j)(i : Bool) (e : Comp p.g) :∃ L Z,labStruct p n ((x i).val e) R L Z := byclassicalhave h (z) := v.frozen_here_dim hb a t i zhave he : ((x i).val e).rank ≤ R :=(rank_vanish (vanish_one ho i e)).trans((Nat.add_le_add (h (e,true)) (h (e,false))).trans (by omega))have hf : ((x i).val e)∈ Wspace p n := byobtain ⟨w,h,hx⟩ := mem_X.mp (x i).propertyrw [← hx]exact ((Wspace p n).add_mem ((Wtag_le _) (h e.val.1)) ((Wtag_le _) (h e.val.2)))obtain ⟨L,Z,hL,_,hZ,hA⟩ := label_support hf R hj helet g (s : Label p.b) := if s∈L then Z s else 0refine ⟨L,g,?_,hL,(fun s hs => ite_eq_right hs), fun s hs => ?_⟩· rw [hZ]exact Finset.sum_congr rfl fun s hs => by simp [g,hs]simp only [g,ite_eq_left hs]exact hA _ hsprivate theorem edge_at (l : Tag p.g) (e : Comp p.g) (h : inc e l) :∃ (k : Tag p.g) (h : l≠k),e = edge l k h := byrcases e with ⟨⟨i,j⟩,hj⟩change i=l∨j=l at hrcases h with rfl|rfl· exact ⟨j,hj.ne,(edge_eq hj).symm⟩exact ⟨i,hj.ne.symm, by rw [edge_symm,edge_eq hj]⟩private theorem cut_tri {x : Profile p n} (hx : x∈Xspace p n)(l k j : Tag p.g) (h : l≠k) (h' : l ≠ j) (h'' : k≠j) :x (edge l k h)+x (edge l j h')+x (edge k j h'')=0 := byobtain ⟨w,hv,rfl⟩ := mem_X.mp hxrw [← getPair_edge l k h (cut p n w), ←getPair_edge l j h' (cut p n w), ←getPair_edge k j h'' (cut p n w),getPair_cut,getPair_cut,getPair_cut]have he (x y z : Moment p n) : x+y+(x+z)+(y+z)=0 := calc_ = (x+x)+(y+y)+(z+z) := by ac_rfl_ = _ := by simp only [char_two]exact he _ _ _private theorem structure_mark {x : Xpair p n} {a b : Plan p n}{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}{q R : ℕ} (hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)(hr : 6*R+4≤p.j) (hq : R+14≤q)(l : I){L : Comp p.g → Finset (Label p.b)} {Z : Comp p.g → Label p.b → BaseMat p n}(he : ∀ e,labStruct p n ((x (v.obj l)).val e) R (L e) (Z e)) :∃ c : F, ∀ e,mput p (v.sel l) (Z e (v.sel l))=c • v.atomAt t l e := byclassicallet s := v.sel llet u := t llet M := vecMulVec (baseV (v.par l)) (baseV (v.par l))let coeff := fun e : Comp p.g => Z e s none nonehave h1 (e : Comp p.g) : Z e s= if inc e u then coeff e • M else 0 := byhave ⟨hE,hL,hT,hH⟩ := he eexact mark_atom hb t hv l e _ (le_trans (Nat.add_le_add_right hL 14) hq)_ hT hH (hE ▸ vanish_one ho (v.obj l) e)have h2 (e f : Comp p.g) (h : inc e u) (h' : inc f u) :coeff e=coeff f := byby_cases hi : e=f· rw [hi]obtain ⟨k,hk,rfl⟩ := edge_at u e hobtain ⟨u2,hl,rfl⟩ := edge_at u f h'have hj : k ≠ u2 := by rintro rfl; exact hi rflhave hh := cut_tri (x (v.obj l)).property u k u2 hk hl hjhave heq := struct_tri (he (edge u k hk)) (he (edge u u2 hl)) (he (edge k u2 hj))(by omega) hh shave hn : ¬ inc (edge k u2 hj) u := fun he => byrcases (inc_edge_iff _).mp he with h|h; exact hk h.symm; exact hl h.symmrw [h1 (edge k u2 hj), ite_eq_right hn,add_zero] at heqhave h0 := congr_fun (congr_fun heq none) nonechange coeff _ + coeff _ = 0 at h0exact add_right_cancel (h0.trans (char_two _).symm)have h3 (e) : mput p s (Z e s)= coeff e • v.atomAt t l e := byrw [h1,atomAt,atom_def]by_cases hf : inc e u· rw [ite_eq_left hf,ite_eq_left hf,map_smul]change coeff e • liftM (labMat p n s) (labMat p n s) M=_unfold Mrw [liftM_outer,labMat_act]; rflrw [ite_eq_right hf,ite_eq_right hf,map_zero,smul_zero]by_cases hh : ∃ e,inc e u· obtain ⟨f,hf⟩ := hhrefine ⟨coeff f,fun e => ?_⟩by_cases h : inc e u· exact (h3 e).trans (by rw [h2 e f h hf])refine (h3 e).trans ?_rw [atomAt,atom_def,ite_eq_right h,smul_zero,smul_zero]refine ⟨0,fun e => ?_⟩refine (h3 e).trans ?_rw [atomAt,atom_def,ite_eq_right (show ¬inc e u from fun he => hh ⟨e,he⟩),smul_zero,zero_smul]/-- a component uses at most R nonattack labels. -/def clean (v : Volley p n I) (i : Bool) (R : ℕ) (M : Moment p n) :=∃ (L : Finset (Label p.b)) (Z : Label p.b → BaseMat p n),M=labelSum p L Z ∧ L.card≤R ∧ Disjoint L (v.marked i)theorem split_orth {x : Xpair p n} {a b : Plan p n}{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}{q R : ℕ} (hb : v.bounded w) (ht : v.legal t)(ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)(hr : 6*R+4≤p.j) (hr' : 2*planRank a+28≤R) (hq : R+14≤q) :∃ (c : I → F) (y : Xpair p n), x=y+∑ i,c i • v.strike t ht i ∧orth p C (v.frozen a t) b j y ∧ ∀ i e,v.clean i R ((y i).val e) := byclassicalchoose L Z hZ using orth_structure hb ho R hr' hrchoose c hc using fun l => structure_mark hb ho hv hr hq l (hZ (v.obj l))let A := ∑ i,c i • v.strike t ht irefine ⟨c,x-A,(sub_add_cancel x A).symm,orth_sub ho (orth_sum _ _ (v.strike_orth t ht)),fun i e => ?_⟩obtain ⟨B,h1,hA,hv',h3⟩ := hv ilet T := v.marked ihave he : (A i).val e=labelSum p T (Z i e) := byrw [show (A i).val=_ from v.strike_here t ht c i, Finset.sum_apply]dsimp only [labelSum,T,marked]rw [Finset.sum_image h3]refine Finset.sum_congr rfl fun l hl => ?_have he : v.obj l=i := (mem_filter.mp hl).2exact (he ▸ hc l e).symmlet W := L i erefine ⟨W \ T,Z i e,?_,(Finset.card_le_card sdiff_subset).trans (hZ i e).2.1, ?_⟩· change (x i).val e-(A i).val e=_rw [(hZ i e).1,he]have hz : labelSum p W (Z i e)=labelSum p (W∪T) (Z i e) := byrefine Finset.sum_subset subset_union_left fun s _ hs => ?_rw [(hZ i e).2.2.1 s hs,map_zero]rw [hz]have hS : (W∪T)=(W \ T) ∪ T := by ext i; simprw [hS,labelSum,Finset.sum_union (show Disjoint (W \ T) T from Disjoint.symm disjoint_sdiff)]exact add_sub_cancel_right _ _exact Disjoint.symm disjoint_sdiffend Volleyend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import OAI.Combinatorics.HadwigerCounterexample.PrimalChannelDecompositionnamespace OAI/-! # Baseline Extension -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Submodulevariable {p : Shape} {n : ℕ}theorem project_table (a : Plan p n) (z : Place p) (Q : Space (Dir p n))(hq : Q ≤ primal p n) (hd : Disjoint (tabSpace a z) Q) :∃ B, ProjData (tabSpace a z) Q B ∧ ∀ x∈ primal p n, B*ᵥx∈prSmall a z := byclassicallet H := channels p nlet A := primal p nlet P := prSmall a zhave hp : P≤ A := prSmall_le _ _have he : tabSpace a z=P ⊔ H := prSmall_table a zobtain ⟨X,hX⟩ := proj_exists H A channels_disjoint.symmhave hj : Disjoint P (Q⊔H) := byrw [disjoint_iff_inf_le]rintro v ⟨hv,hv'⟩obtain ⟨y,hy,w,hw,g⟩ := Submodule.mem_sup.mp hv'have h := (show w=v-y by rw [←g]; abel) ▸A.sub_mem (hp hv) (hq hy)have hz : w∈ A ⊓ H := ⟨h,hw⟩rw [channels_disjoint.eq_bot] at hzhave hi : w=0 := by simpa using hzrw [hi,add_zero] at ghave ht : v∈tabSpace a z ⊓ Q :=⟨he.symm ▸ Submodule.mem_sup_left hv,g ▸ hy⟩rwa [hd.eq_bot] at htobtain ⟨Y,hY⟩ := proj_exists P (Q⊔H) hjrefine ⟨X+Y,⟨fun x => ?_,fun x hx => ?_,fun x hx => ?_⟩, fun x hx => ?_⟩· rw [add_mulVec,he,add_comm]; exact add_mem_sup (hY.onto _) (hX.onto _)· rw [he] at hxobtain ⟨v,hv,w,hw,rfl⟩ := Submodule.mem_sup.mp hxrw [add_mulVec,mulVec_add,mulVec_add,hX.kills v (hp hv),hX.fixes _ hw,hY.fixes _ hv,hY.kills _ (Submodule.mem_sup_right hw),add_zero,zero_add,add_comm]· rw [add_mulVec,hX.kills x (hq hx),hY.kills x (Submodule.mem_sup_left hx),zero_add]· rw [add_mulVec,hX.kills x hx,zero_add]; exact hY.onto _abbrev CrossM (p : Shape) (n : ℕ) := Mat (JointIdx p n) (JointIdx p n)set_option maxHeartbeats 800000 intheorem base_pair (a b : Plan p n) (u v : Place p)(K J : Space (Dir p n)) (hk : K≤primal p n) (hj : J≤primal p n)(hK : Disjoint (tabSpace a u) K) (hJ : Disjoint (tabSpace b v) J)(A B : CrossM p n)(heq : ∀ x∈ tabSpace a u,∀ y∈tabSpace b v,x∈a u ∨ y∈b v → evmat A x y=evmat B x y) :∃ M : CrossM p n,(∀ x∈tabSpace a u,∀ y∈tabSpace b v,evmat M x y=evmat B x y) ∧(∀ x y, x∈ (a u⊔K) ∨ y∈(b v⊔J) → evmat M x y=evmat A x y) ∧(∀ i,(Mᵀ*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +2*planRank a) ∧(∀ i,(M*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +2*planRank b) := bylet P := a u⊔Klet Q := b v⊔Jobtain ⟨X,hX⟩ := proj_exists P ⊥ disjoint_bot_rightobtain ⟨Y,hY⟩ := proj_exists Q ⊥ disjoint_bot_rightobtain ⟨L,hL,gL⟩ := project_table a u K hk hKobtain ⟨R,hR,gR⟩ := project_table b v J hj hJlet C := pullM X (1:CrossM p n) A + pullM (1-X) Y Alet M := C + pullM L R (B-C)have h1 (x y) (hx : x∈P ∨ y∈Q) : evmat C x y=evmat A x y := byrw [show C=_ from rfl,evmat_addM,evmat_pull,evmat_pull,sub_mulVec,Matrix.one_mulVec,Matrix.one_mulVec]rcases hx with h|h· rw [hX.fixes _ h,sub_self]; simp [evmat]rw [hY.fixes _ h]simp [evmat,sub_dotProduct]have h2 (x y) : evmat M x y=evmat C x y+(evmat B (L *ᵥ x) (R *ᵥ y)-evmat C (L*ᵥ x) (R*ᵥ y)) := byrw [show M=_ from rfl,evmat_addM,evmat_pull,evmat_subM]have hRank : C.rank≤dim P+dim Q := byapply (mrk_add_le ..).transhave hx : X.rank≤dim P := rank_maps _ hX.ontohave hy : Y.rank≤dim Q := rank_maps _ hY.ontoapply Nat.add_le_add· rw [pullM_def]refine ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans ?_rwa [Matrix.rank_transpose]· rw [pullM_def]; exact (Matrix.rank_mul_le_right ..).trans hyhave hr (i) {a : Plan p n} (u)(R : CrossM p n) (h : ∀ x∈primal p n,R*ᵥ x∈prSmall a u) :(R*IP p n i).rank≤ 2*planRank a := byapply le_trans (rank_maps (prSmall a u) _)(prSmall_dim a u)intro xrw [← Matrix.mulVec_mulVec]exact h _ (ip_le_primal i (show IP p n i*ᵥx∈colSp (IP p n i) from ⟨x,rfl⟩))refine ⟨M, fun x hx y hy => ?_, fun x y h => ?_, fun i => ?_, fun i => ?_⟩· rw [h2,hL.fixes x hx,hR.fixes y hy,add_sub_cancel]· have hi : L*ᵥ x ∈ a u ∨ R *ᵥ y ∈ b v := byrcases h with h|h· left; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp hrwa [Matrix.mulVec_add,hL.kills _ hy,hL.fixes _ (pin_le_table _ _ hx),add_zero]right; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp hrwa [Matrix.mulVec_add,hR.kills _ hy,hR.fixes _ (pin_le_table _ _ hx),add_zero]have he : L*ᵥx ∈ P ∨ R*ᵥy∈Q := hi.imp Submodule.mem_sup_left Submodule.mem_sup_leftrw [h2,h1 _ _ h,h1 _ _ he,heq _ (hL.onto _) _ (hR.onto _) hi,sub_self,add_zero]· unfold Mrw [transpose_add,Matrix.add_mul]refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)· exact (Matrix.rank_mul_le_left ..).trans ((Matrix.rank_transpose _).trans_le hRank)rw [pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc,Matrix.mul_assoc]exact ((Matrix.rank_mul_le_right ..).trans (Matrix.rank_mul_le_right ..)).trans (hr i u L gL)· unfold Mrw [Matrix.add_mul]refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)· exact (Matrix.rank_mul_le_left ..).trans hRankrw [pullM_def,Matrix.mul_assoc]exact (Matrix.rank_mul_le_right ..).trans (hr i v R gR)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import OAI.Combinatorics.HadwigerCounterexample.PrimalChannelDecompositionnamespace OAI/-! # Baseline Extension -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Submodulevariable {p : Shape} {n : ℕ}theorem project_table (a : Plan p n) (z : Place p) (Q : Space (Dir p n))(hq : Q ≤ primal p n) (hd : Disjoint (tabSpace a z) Q) :∃ B, ProjData (tabSpace a z) Q B ∧ ∀ x∈ primal p n, B*ᵥx∈prSmall a z := byclassicallet H := channels p nlet A := primal p nlet P := prSmall a zhave hp : P≤ A := prSmall_le _ _have he : tabSpace a z=P ⊔ H := prSmall_table a zobtain ⟨X,hX⟩ := proj_exists H A channels_disjoint.symmhave hj : Disjoint P (Q⊔H) := byrw [disjoint_iff_inf_le]rintro v ⟨hv,hv'⟩obtain ⟨y,hy,w,hw,g⟩ := Submodule.mem_sup.mp hv'have h := (show w=v-y by rw [←g]; abel) ▸A.sub_mem (hp hv) (hq hy)have hz : w∈ A ⊓ H := ⟨h,hw⟩rw [channels_disjoint.eq_bot] at hzhave hi : w=0 := by simpa using hzrw [hi,add_zero] at ghave ht : v∈tabSpace a z ⊓ Q :=⟨he.symm ▸ Submodule.mem_sup_left hv,g ▸ hy⟩rwa [hd.eq_bot] at htobtain ⟨Y,hY⟩ := proj_exists P (Q⊔H) hjrefine ⟨X+Y,⟨fun x => ?_,fun x hx => ?_,fun x hx => ?_⟩, fun x hx => ?_⟩· rw [add_mulVec,he,add_comm]; exact add_mem_sup (hY.onto _) (hX.onto _)· rw [he] at hxobtain ⟨v,hv,w,hw,rfl⟩ := Submodule.mem_sup.mp hxrw [add_mulVec,mulVec_add,mulVec_add,hX.kills v (hp hv),hX.fixes _ hw,hY.fixes _ hv,hY.kills _ (Submodule.mem_sup_right hw),add_zero,zero_add,add_comm]· rw [add_mulVec,hX.kills x (hq hx),hY.kills x (Submodule.mem_sup_left hx),zero_add]· rw [add_mulVec,hX.kills x hx,zero_add]; exact hY.onto _abbrev CrossM (p : Shape) (n : ℕ) := Mat (JointIdx p n) (JointIdx p n)set_option maxHeartbeats 800000 intheorem base_pair (a b : Plan p n) (u v : Place p)(K J : Space (Dir p n)) (hk : K≤primal p n) (hj : J≤primal p n)(hK : Disjoint (tabSpace a u) K) (hJ : Disjoint (tabSpace b v) J)(A B : CrossM p n)(heq : ∀ x∈ tabSpace a u,∀ y∈tabSpace b v,x∈a u ∨ y∈b v → evmat A x y=evmat B x y) :∃ M : CrossM p n,(∀ x∈tabSpace a u,∀ y∈tabSpace b v,evmat M x y=evmat B x y) ∧(∀ x y, x∈ (a u⊔K) ∨ y∈(b v⊔J) → evmat M x y=evmat A x y) ∧(∀ i,(Mᵀ*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +2*planRank a) ∧(∀ i,(M*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +2*planRank b) := bylet P := a u⊔Klet Q := b v⊔Jobtain ⟨X,hX⟩ := proj_exists P ⊥ disjoint_bot_rightobtain ⟨Y,hY⟩ := proj_exists Q ⊥ disjoint_bot_rightobtain ⟨L,hL,gL⟩ := project_table a u K hk hKobtain ⟨R,hR,gR⟩ := project_table b v J hj hJlet C := pullM X (1:CrossM p n) A + pullM (1-X) Y Alet M := C + pullM L R (B-C)have h1 (x y) (hx : x∈P ∨ y∈Q) : evmat C x y=evmat A x y := byrw [show C=_ from rfl,evmat_addM,evmat_pull,evmat_pull,sub_mulVec,Matrix.one_mulVec,Matrix.one_mulVec]rcases hx with h|h· rw [hX.fixes _ h,sub_self]; simp [evmat]rw [hY.fixes _ h]simp [evmat,sub_dotProduct]have h2 (x y) : evmat M x y=evmat C x y+(evmat B (L *ᵥ x) (R *ᵥ y)-evmat C (L*ᵥ x) (R*ᵥ y)) := byrw [show M=_ from rfl,evmat_addM,evmat_pull,evmat_subM]have hRank : C.rank≤dim P+dim Q := byapply (mrk_add_le ..).transhave hx : X.rank≤dim P := rank_maps _ hX.ontohave hy : Y.rank≤dim Q := rank_maps _ hY.ontoapply Nat.add_le_add· rw [pullM_def]refine ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans ?_rwa [Matrix.rank_transpose]· rw [pullM_def]; exact (Matrix.rank_mul_le_right ..).trans hyhave hr (i) {a : Plan p n} (u)(R : CrossM p n) (h : ∀ x∈primal p n,R*ᵥ x∈prSmall a u) :(R*IP p n i).rank≤ 2*planRank a := byapply le_trans (rank_maps (prSmall a u) _)(prSmall_dim a u)intro xrw [← Matrix.mulVec_mulVec]exact h _ (ip_le_primal i (show IP p n i*ᵥx∈colSp (IP p n i) from ⟨x,rfl⟩))refine ⟨M, fun x hx y hy => ?_, fun x y h => ?_, fun i => ?_, fun i => ?_⟩· rw [h2,hL.fixes x hx,hR.fixes y hy,add_sub_cancel]· have hi : L*ᵥ x ∈ a u ∨ R *ᵥ y ∈ b v := byrcases h with h|h· left; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp hrwa [Matrix.mulVec_add,hL.kills _ hy,hL.fixes _ (pin_le_table _ _ hx),add_zero]right; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp hrwa [Matrix.mulVec_add,hR.kills _ hy,hR.fixes _ (pin_le_table _ _ hx),add_zero]have he : L*ᵥx ∈ P ∨ R*ᵥy∈Q := hi.imp Submodule.mem_sup_left Submodule.mem_sup_leftrw [h2,h1 _ _ h,h1 _ _ he,heq _ (hL.onto _) _ (hR.onto _) hi,sub_self,add_zero]· unfold Mrw [transpose_add,Matrix.add_mul]refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)· exact (Matrix.rank_mul_le_left ..).trans ((Matrix.rank_transpose _).trans_le hRank)rw [pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc,Matrix.mul_assoc]exact ((Matrix.rank_mul_le_right ..).trans (Matrix.rank_mul_le_right ..)).trans (hr i u L gL)· unfold Mrw [Matrix.add_mul]refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)· exact (Matrix.rank_mul_le_left ..).trans hRankrw [pullM_def,Matrix.mul_assoc]exact (Matrix.rank_mul_le_right ..).trans (hr i v R gR)end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import OAI.Combinatorics.HadwigerCounterexample.BaselineExtensionnamespace OAI/-! # Baseline Forms -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrixvariable {p : Shape} {n N : ℕ}def lowCross (K : ℕ) (B : Cross p n) :=∀ z i,( (B z)ᵀ * IP p n i).rank ≤ Kdef fitsTable (a b : Plan p n) (B T : Cross p n) :=∀ z, ∀ x∈tabSpace a z,∀ y∈tabSpace b (flipZ p z), evmat (B z) x y=evmat (T z) x ytheorem fits_recip {B T : Cross p n} {a b : Plan p n} (h : fitsTable a b B T) :fitsTable b a (reciprocal p B) (reciprocal p T) := byintro z x hx y hyhave hx' : x∈tabSpace b (flipZ p (flipZ p z)) := by rwa [flipZ_flip]change evmat _ _ _=evmat _ _ _unfold reciprocalrw [evmat_transpose,evmat_transpose,h _ y hy x hx']def blin (K : ℕ) := 4*K+56set_option maxHeartbeats 800000 intheorem start_form (a b : Pin p n N) (x y : UnitType p n N) (T : Cross p n)(ka kb : Plan p n)(hA : ∀ z,ka z≤primal p n) (hB : ∀ z,kb z≤primal p n)(hd : ∀ z, Disjoint (tabSpace a.sp z) (ka z))(hd' : ∀ z, Disjoint (tabSpace b.sp z) (kb z))(ha : a.agree x) (hb : b.agree y) (h1 : tableFlag a b T x)(h2 : tableFlag b a (reciprocal p T) y)(K : ℕ) (hk : planRank a.sp ≤ K) (hk' : planRank b.sp ≤ K)(hv : ∀ z, dim (ka z) ≤ 28) (hv' : ∀ z, dim (kb z) ≤ 28) :∃ M : Cross p n, fitsTable a.sp b.sp M T ∧rowAgree (a.sp ⊔ ka) M (actual p x y) ∧rowAgree (b.sp ⊔ kb) (reciprocal p M) (actual p y x) ∧lowCross (blin K) M ∧ lowCross (blin K) (reciprocal p M) := bylet A := actual p x yhave hh (z : Place p) (u v) (hu : u∈tabSpace a.sp z) (hv : v∈tabSpace b.sp (flipZ p z))(h : u∈a.sp z ∨ v∈b.sp (flipZ p z)) : evmat (A z) u v=evmat (T z) u v := byrcases h with h|h· have h' : u ∈ a.sp (flipZ p (flipZ p z)) := by rwa [flipZ_flip]have he := h2 _ v hv u h'have hf := flag_actual (a:=b) y x ha (flipZ p z) v hv u h'have hg := hf.trans he.symmrw [← reciprocal_actual x y] at hgsimp only [reciprocal,flipZ_flip,evmat_transpose] at hgexact hgexact (flag_actual (a:=a) x y hb _ u hu v h).trans (h1 _ u hu v h).symmchoose M hC hD hE hF using fun z =>base_pair a.sp b.sp z (flipZ p z) (ka z) (kb (flipZ p z)) (hA _) (hB _) (hd _) (hd' _)(A z) (T z) (fun u hu v hv g => hh z u v hu hv g)have hr (z) {a s : Plan p n} (h : planRank a≤K) (hg : ∀ z,dim (s z)≤28) :dim (a z ⊔ s z : Submodule _ _) ≤ K+28 :=(Submodule.finrank_add_le_finrank_add_finrank ..).trans(Nat.add_le_add ((dim_le_plan a _).trans h) (hg _))have hm z {L} (hl : L≤K) : dim (a.sp z ⊔ ka z : Submodule _ _)+dim (b.sp (flipZ p z) ⊔ kb (flipZ p z):Submodule _ _)+2*L ≤ blin K := byapply le_trans (Nat.add_le_add (Nat.add_le_add (hr z hk hv) (hr _ hk' hv'))(Nat.mul_le_mul_left 2 hl))unfold blin; omegarefine ⟨M,hC,(fun z u hu v => hD z u v (Or.inl hu)),?_,fun z i => (hE z i).trans (hm z hk),?_⟩· rw [← reciprocal_actual x y]intro z v hv uunfold reciprocal; rw [evmat_transpose,evmat_transpose]apply hDrightrw [flipZ_flip]; exact hvintro z iunfold reciprocal; rw [transpose_transpose]exact (hF (flipZ p z) i).trans (hm _ hk')theorem channel_eval (p : Shape) {n} (M : Cross p n) (j : Bool) (z : Place p)(x : Dir p n) (y : Vec (Chan p)) :dotProduct y (channelOut p M j z *ᵥ x)=evmat (M z) x (IH p n j *ᵥ y) := byunfold channelOut evmatrw [dotProduct_transpose_mulVec, Matrix.mulVec_mulVec]theorem channel_same {M T : Cross p n} (i z u)(h : ∀ v : Vec (Chan p), evmat (M z) u (IH p n i *ᵥ v)=evmat (T z) u (IH p n i *ᵥ v)) :channelOut p M i z *ᵥ u = channelOut p T i z *ᵥ u := byclassicalfunext jhave he v : dotProduct v (channelOut p M i z *ᵥ u)=dotProduct v (channelOut p T i z*ᵥ u) := byrw [channel_eval, channel_eval, h]simpa using he (Pi.single j 1)theorem fits_channel {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)(z : Place p) (x : Dir p n) (hx : x∈tabSpace a z) (j : Bool) :channelOut p M j z *ᵥ x = channelOut p T j z *ᵥ x := byapply channel_same jintro vexact h z x hx _ (channel_le_table b _ j ⟨_,rfl⟩)theorem fits_inj {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)(ht : tableInj a b T) : tableInj a b M := byintro z i j v hv hhapply ht z i j v hvrwa [fits_channel h z _ (pin_le_table a z hv) j] at hhprivate theorem cout_ev (A B : Mat (Chan p) (JointIdx p n)) (x y) :evmat (Aᵀ*B) x y=dotProduct (A *ᵥ x) (B *ᵥ y) := byrw [evmat,← mulVec_mulVec,dotProduct_transpose_mulVec,dotProduct_comm]theorem fits_contract {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)(i j : Bool) (x : Profile p n) (hx : x ∈ effective a i) :contract p M i j x=contract p T i j x := bychange ∑ e : Comp p.g, _ = _refine Finset.sum_congr rfl fun e _ => ?_apply (box_eval_iff (tabSpace a (e,true)) (tabSpace a (e,false)) _ _).mp ?_ _· have hp := lift_mem_box (IP p n i) (IP p n i) ((effective_mem.mp hx).2 e)exact box_le (le_trans le_sup_left (half_le_table a _ i))(le_trans le_sup_left (half_le_table a _ i)) hpintro x hx y hy; rw [cout_ev, cout_ev,fits_channel h _ _ hx,fits_channel h _ _ hy]variable {I : Type} [Fintype I]theorem frozen_contract_key {M T : Cross p n} {a} (v : Volley p n I) (t : Tagging p I)(h : rowAgree (a⊔v.keyPlan t) M T) (i : I) (j : Bool) :contract p M (v.obj i) j (v.atomAt t i)=contract p T (v.obj i) j (v.atomAt t i) := byclassicalchange ∑ e : Comp p.g, _ = _refine Finset.sum_congr rfl fun e _ => ?_by_cases he : inc e (t i)· have hx b :v.rayLoc i ∈ (v.keyPlan t (e,b)) := colSp_mem (P:=v.keyM t e)(⟨i,he⟩ : Volley.visits p t e)have hE (b : Bool) : channelOut p M j (e,b) *ᵥ v.rayLoc i =channelOut p T j (e,b) *ᵥ v.rayLoc i :=channel_same j _ _ (fun y => h _ _ (Submodule.mem_sup_right (hx b)) _)simp only [Volley.atomAt,atom_def,he, ite_true,mom,liftM_outer,mpair_outer]rw [cout_ev,cout_ev]exact congrArg₂ dotProduct (hE true) (hE false)simp only [Volley.atomAt,atom_def,he,ite_false,map_zero]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import OAI.Combinatorics.HadwigerCounterexample.BaselineExtensionnamespace OAI/-! # Baseline Forms -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrixvariable {p : Shape} {n N : ℕ}def lowCross (K : ℕ) (B : Cross p n) :=∀ z i,( (B z)ᵀ * IP p n i).rank ≤ Kdef fitsTable (a b : Plan p n) (B T : Cross p n) :=∀ z, ∀ x∈tabSpace a z,∀ y∈tabSpace b (flipZ p z), evmat (B z) x y=evmat (T z) x ytheorem fits_recip {B T : Cross p n} {a b : Plan p n} (h : fitsTable a b B T) :fitsTable b a (reciprocal p B) (reciprocal p T) := byintro z x hx y hyhave hx' : x∈tabSpace b (flipZ p (flipZ p z)) := by rwa [flipZ_flip]change evmat _ _ _=evmat _ _ _unfold reciprocalrw [evmat_transpose,evmat_transpose,h _ y hy x hx']def blin (K : ℕ) := 4*K+56set_option maxHeartbeats 800000 intheorem start_form (a b : Pin p n N) (x y : UnitType p n N) (T : Cross p n)(ka kb : Plan p n)(hA : ∀ z,ka z≤primal p n) (hB : ∀ z,kb z≤primal p n)(hd : ∀ z, Disjoint (tabSpace a.sp z) (ka z))(hd' : ∀ z, Disjoint (tabSpace b.sp z) (kb z))(ha : a.agree x) (hb : b.agree y) (h1 : tableFlag a b T x)(h2 : tableFlag b a (reciprocal p T) y)(K : ℕ) (hk : planRank a.sp ≤ K) (hk' : planRank b.sp ≤ K)(hv : ∀ z, dim (ka z) ≤ 28) (hv' : ∀ z, dim (kb z) ≤ 28) :∃ M : Cross p n, fitsTable a.sp b.sp M T ∧rowAgree (a.sp ⊔ ka) M (actual p x y) ∧rowAgree (b.sp ⊔ kb) (reciprocal p M) (actual p y x) ∧lowCross (blin K) M ∧ lowCross (blin K) (reciprocal p M) := bylet A := actual p x yhave hh (z : Place p) (u v) (hu : u∈tabSpace a.sp z) (hv : v∈tabSpace b.sp (flipZ p z))(h : u∈a.sp z ∨ v∈b.sp (flipZ p z)) : evmat (A z) u v=evmat (T z) u v := byrcases h with h|h· have h' : u ∈ a.sp (flipZ p (flipZ p z)) := by rwa [flipZ_flip]have he := h2 _ v hv u h'have hf := flag_actual (a:=b) y x ha (flipZ p z) v hv u h'have hg := hf.trans he.symmrw [← reciprocal_actual x y] at hgsimp only [reciprocal,flipZ_flip,evmat_transpose] at hgexact hgexact (flag_actual (a:=a) x y hb _ u hu v h).trans (h1 _ u hu v h).symmchoose M hC hD hE hF using fun z =>base_pair a.sp b.sp z (flipZ p z) (ka z) (kb (flipZ p z)) (hA _) (hB _) (hd _) (hd' _)(A z) (T z) (fun u hu v hv g => hh z u v hu hv g)have hr (z) {a s : Plan p n} (h : planRank a≤K) (hg : ∀ z,dim (s z)≤28) :dim (a z ⊔ s z : Submodule _ _) ≤ K+28 :=(Submodule.finrank_add_le_finrank_add_finrank ..).trans(Nat.add_le_add ((dim_le_plan a _).trans h) (hg _))have hm z {L} (hl : L≤K) : dim (a.sp z ⊔ ka z : Submodule _ _)+dim (b.sp (flipZ p z) ⊔ kb (flipZ p z):Submodule _ _)+2*L ≤ blin K := byapply le_trans (Nat.add_le_add (Nat.add_le_add (hr z hk hv) (hr _ hk' hv'))(Nat.mul_le_mul_left 2 hl))unfold blin; omegarefine ⟨M,hC,(fun z u hu v => hD z u v (Or.inl hu)),?_,fun z i => (hE z i).trans (hm z hk),?_⟩· rw [← reciprocal_actual x y]intro z v hv uunfold reciprocal; rw [evmat_transpose,evmat_transpose]apply hDrightrw [flipZ_flip]; exact hvintro z iunfold reciprocal; rw [transpose_transpose]exact (hF (flipZ p z) i).trans (hm _ hk')theorem channel_eval (p : Shape) {n} (M : Cross p n) (j : Bool) (z : Place p)(x : Dir p n) (y : Vec (Chan p)) :dotProduct y (channelOut p M j z *ᵥ x)=evmat (M z) x (IH p n j *ᵥ y) := byunfold channelOut evmatrw [dotProduct_transpose_mulVec, Matrix.mulVec_mulVec]theorem channel_same {M T : Cross p n} (i z u)(h : ∀ v : Vec (Chan p), evmat (M z) u (IH p n i *ᵥ v)=evmat (T z) u (IH p n i *ᵥ v)) :channelOut p M i z *ᵥ u = channelOut p T i z *ᵥ u := byclassicalfunext jhave he v : dotProduct v (channelOut p M i z *ᵥ u)=dotProduct v (channelOut p T i z*ᵥ u) := byrw [channel_eval, channel_eval, h]simpa using he (Pi.single j 1)theorem fits_channel {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)(z : Place p) (x : Dir p n) (hx : x∈tabSpace a z) (j : Bool) :channelOut p M j z *ᵥ x = channelOut p T j z *ᵥ x := byapply channel_same jintro vexact h z x hx _ (channel_le_table b _ j ⟨_,rfl⟩)theorem fits_inj {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)(ht : tableInj a b T) : tableInj a b M := byintro z i j v hv hhapply ht z i j v hvrwa [fits_channel h z _ (pin_le_table a z hv) j] at hhprivate theorem cout_ev (A B : Mat (Chan p) (JointIdx p n)) (x y) :evmat (Aᵀ*B) x y=dotProduct (A *ᵥ x) (B *ᵥ y) := byrw [evmat,← mulVec_mulVec,dotProduct_transpose_mulVec,dotProduct_comm]theorem fits_contract {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)(i j : Bool) (x : Profile p n) (hx : x ∈ effective a i) :contract p M i j x=contract p T i j x := bychange ∑ e : Comp p.g, _ = _refine Finset.sum_congr rfl fun e _ => ?_apply (box_eval_iff (tabSpace a (e,true)) (tabSpace a (e,false)) _ _).mp ?_ _· have hp := lift_mem_box (IP p n i) (IP p n i) ((effective_mem.mp hx).2 e)exact box_le (le_trans le_sup_left (half_le_table a _ i))(le_trans le_sup_left (half_le_table a _ i)) hpintro x hx y hy; rw [cout_ev, cout_ev,fits_channel h _ _ hx,fits_channel h _ _ hy]variable {I : Type} [Fintype I]theorem frozen_contract_key {M T : Cross p n} {a} (v : Volley p n I) (t : Tagging p I)(h : rowAgree (a⊔v.keyPlan t) M T) (i : I) (j : Bool) :contract p M (v.obj i) j (v.atomAt t i)=contract p T (v.obj i) j (v.atomAt t i) := byclassicalchange ∑ e : Comp p.g, _ = _refine Finset.sum_congr rfl fun e _ => ?_by_cases he : inc e (t i)· have hx b :v.rayLoc i ∈ (v.keyPlan t (e,b)) := colSp_mem (P:=v.keyM t e)(⟨i,he⟩ : Volley.visits p t e)have hE (b : Bool) : channelOut p M j (e,b) *ᵥ v.rayLoc i =channelOut p T j (e,b) *ᵥ v.rayLoc i :=channel_same j _ _ (fun y => h _ _ (Submodule.mem_sup_right (hx b)) _)simp only [Volley.atomAt,atom_def,he, ite_true,mom,liftM_outer,mpair_outer]rw [cout_ev,cout_ev]exact congrArg₂ dotProduct (hE true) (hE false)simp only [Volley.atomAt,atom_def,he,ite_false,map_zero]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113import OAI.Combinatorics.HadwigerCounterexample.OrientationRankBoundsnamespace OAI/-! # Basis Conditioning -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module LinearMap Finset Filter Functionopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]theorem totalRank_pos {x : Profile p n} (h : x≠0) :0<totalRank x := byobtain ⟨i,hi⟩ := Function.ne_iff.mp happly lt_of_lt_of_le _ (Finset.single_le_sum (fun i _=>Nat.zero_le ((x i).rank))(Finset.mem_univ i))apply Nat.pos_of_ne_zero; intro hobtain ⟨A,B,hh⟩ := mul_factor (x i) 0 h.leapply hi; ext a b; rw [←hh,Matrix.mul_apply]; simpdef glintRate (K : ℕ) := bp (-((K^2:ℕ):ℝ)-3)theorem glint_within {K d : ℕ} (h : d≤ K^2) :glintRate K ≤ (1/8:ℝ)*bp (- (d:ℝ)) := byunfold glintRatehave hh : bp (-3)=1/8 := by norm_num [bp]rw [←hh,←bp_add]exact bp_le (by linarith only [(show (d:ℝ) ≤ ((K^2:ℕ):ℝ) from by exact_mod_cast h)])namespace Templatevariable (v : Solo p)def stains (m : Mixer p n) (f : Vec I →ₗ[F] Profile p n) (z : Knobs p.g n) : Vec I :=fun i=> Tsym m (f (Pi.single i 1)) (useAtom p (v.t ()) (v.s ()) (v.f ()) z)theorem staining (m : Mixer p n) (f : Vec I→ₗ[F] Profile p n) (z : Knobs p.g n) (i : Vec I) :vectorPhase i (stains v m f z)=shanty v m (f i) z := byclassicallet h := LinearMap.flip (Tsym m) (useAtom p (v.t ()) (v.s ()) (v.f ()) z) ∘ₗ fhave ht : h i=h (∑ j: I,i j • (Pi.single j 1 : Vec I)) := byhave he (j:I) : i j • (Pi.single j 1 : Vec I)=Pi.single j (i j) := byfunext k; by_cases hh:k=j <;> simp [hh]simp_rw [he]rw [Finset.univ_sum_single]change wsign (∑ j:I,i j*h (Pi.single j 1))=wsign (h i)rw [ht,map_sum]; simp_rw [map_smul]; rfldef luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n)) (D : AtomKey (p:=p) (v.t ())N →Prop) (K : ℕ) (i : Orient p n N) :=let P := offBeat v D i0<pr w P ∧ ∀ (d : ℕ), d≤ K^2 → ∀ f : Vec (Fin d)→ₗ[F] Profile p n,Injective f → (∀ x,totalRank (f x)≤K) → ∀ x,(7/8:ℝ)*bp (-(d:ℝ)) ≤ pr (onW w P) (fun z=> stains v m f z=x)set_option maxHeartbeats 800000 intheorem glow_luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n))(hw : IsLaw w)(S : AtomKey (p:=p) (v.t ()) N → Prop)(K : ℕ) (i : Orient p n N) (δ : ℝ) (hδ : 0<δ) (he : δ ≤ pr w (offBeat v S i))(h : ∀ x, 0<totalRank x → totalRank x≤K → ¬ glow v m w S (glintRate K) δ x i) :luminous v m w S K i := byclassicallet P := offBeat v S ihave hP : 0<pr w P := hδ.trans_le helet u := onW w P; have hu : IsLaw u := on_law hw.nz hPrefine ⟨hP,fun d hd f hf hg x => ?_⟩let s := stains v m fhave heq :pr u (fun z => s z=x) = avg unif (fun i => vectorPhase i x*avg u (fun z => vectorPhase i (s z))) := byunfold prsimp_rw [vector_expand]rw [avg_avg]apply avg_congrintro i hirw [avg_mul]; ringlet b := bp (-(d:ℝ))let Q (k : Vec (Fin d)) := vectorPhase k x * avg u (fun z => vectorPhase k (s z))have hb : 0 < b := bp_pos _have hh k : ind (k=0)-b/8 ≤ Q k := byby_cases hk : k=0· subst khave hQ : Q 0=1 := by unfold Q; simp only [vectorPhase,zero_dotProduct,wsign_zero,one_mul,hu.avg_const]rw [ind_one (show (0:Vec (Fin d))=0 from rfl),hQ]; linarithlet k' := f khave hT := h k' (totalRank_pos (hf.ne hk |>.trans_eq (map_zero f))) (hg k)have hz : |zsumPeak p w (v.shanty m k') P| ≤ (glintRate K)*pr w P :=le_of_lt (lt_of_not_ge (fun h => hT ⟨he,h⟩))have ht :avg u (fun z => vectorPhase k (s z))=zsumPeak p w (v.shanty m k') P/pr w P := byunfold s u onW; simp_rw [staining]; rw [avg_norm,subW_tot]congr 1; simp [zsumPeak,avg,subW,mul_assoc,k']have h1 : |Q k|≤b/8 := byunfold Q; rw [ht,abs_mul,vectorPhase,wsign_abs,one_mul,abs_div,abs_of_pos hP]refine le_trans ((div_le_iff₀ hP).mpr hz) ((glint_within hd).trans_eq (by unfold b; ring))rw [ind_zero hk,zero_sub]; exact (abs_le.mp h1).1have h0 : unif (0:Vec (Fin d))=b := byunfold b; rw [unif_apply,card_space,dim_vec,bp_neg,Fintype.card_fin]change _ ≤ pr u (fun z => s z=x)rw [heq]refine le_trans ?_ (avg_mono unif_law.nz hh)rw [avg_sub,unif_law.avg_const,show avg unif (fun i : Vec (Fin d)=> ind (i=0))=b from (pr_point' unif _).trans h0]change 7/8*b≤_linarithend Templateend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113import OAI.Combinatorics.HadwigerCounterexample.OrientationRankBoundsnamespace OAI/-! # Basis Conditioning -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module LinearMap Finset Filter Functionopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]theorem totalRank_pos {x : Profile p n} (h : x≠0) :0<totalRank x := byobtain ⟨i,hi⟩ := Function.ne_iff.mp happly lt_of_lt_of_le _ (Finset.single_le_sum (fun i _=>Nat.zero_le ((x i).rank))(Finset.mem_univ i))apply Nat.pos_of_ne_zero; intro hobtain ⟨A,B,hh⟩ := mul_factor (x i) 0 h.leapply hi; ext a b; rw [←hh,Matrix.mul_apply]; simpdef glintRate (K : ℕ) := bp (-((K^2:ℕ):ℝ)-3)theorem glint_within {K d : ℕ} (h : d≤ K^2) :glintRate K ≤ (1/8:ℝ)*bp (- (d:ℝ)) := byunfold glintRatehave hh : bp (-3)=1/8 := by norm_num [bp]rw [←hh,←bp_add]exact bp_le (by linarith only [(show (d:ℝ) ≤ ((K^2:ℕ):ℝ) from by exact_mod_cast h)])namespace Templatevariable (v : Solo p)def stains (m : Mixer p n) (f : Vec I →ₗ[F] Profile p n) (z : Knobs p.g n) : Vec I :=fun i=> Tsym m (f (Pi.single i 1)) (useAtom p (v.t ()) (v.s ()) (v.f ()) z)theorem staining (m : Mixer p n) (f : Vec I→ₗ[F] Profile p n) (z : Knobs p.g n) (i : Vec I) :vectorPhase i (stains v m f z)=shanty v m (f i) z := byclassicallet h := LinearMap.flip (Tsym m) (useAtom p (v.t ()) (v.s ()) (v.f ()) z) ∘ₗ fhave ht : h i=h (∑ j: I,i j • (Pi.single j 1 : Vec I)) := byhave he (j:I) : i j • (Pi.single j 1 : Vec I)=Pi.single j (i j) := byfunext k; by_cases hh:k=j <;> simp [hh]simp_rw [he]rw [Finset.univ_sum_single]change wsign (∑ j:I,i j*h (Pi.single j 1))=wsign (h i)rw [ht,map_sum]; simp_rw [map_smul]; rfldef luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n)) (D : AtomKey (p:=p) (v.t ())N →Prop) (K : ℕ) (i : Orient p n N) :=let P := offBeat v D i0<pr w P ∧ ∀ (d : ℕ), d≤ K^2 → ∀ f : Vec (Fin d)→ₗ[F] Profile p n,Injective f → (∀ x,totalRank (f x)≤K) → ∀ x,(7/8:ℝ)*bp (-(d:ℝ)) ≤ pr (onW w P) (fun z=> stains v m f z=x)set_option maxHeartbeats 800000 intheorem glow_luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n))(hw : IsLaw w)(S : AtomKey (p:=p) (v.t ()) N → Prop)(K : ℕ) (i : Orient p n N) (δ : ℝ) (hδ : 0<δ) (he : δ ≤ pr w (offBeat v S i))(h : ∀ x, 0<totalRank x → totalRank x≤K → ¬ glow v m w S (glintRate K) δ x i) :luminous v m w S K i := byclassicallet P := offBeat v S ihave hP : 0<pr w P := hδ.trans_le helet u := onW w P; have hu : IsLaw u := on_law hw.nz hPrefine ⟨hP,fun d hd f hf hg x => ?_⟩let s := stains v m fhave heq :pr u (fun z => s z=x) = avg unif (fun i => vectorPhase i x*avg u (fun z => vectorPhase i (s z))) := byunfold prsimp_rw [vector_expand]rw [avg_avg]apply avg_congrintro i hirw [avg_mul]; ringlet b := bp (-(d:ℝ))let Q (k : Vec (Fin d)) := vectorPhase k x * avg u (fun z => vectorPhase k (s z))have hb : 0 < b := bp_pos _have hh k : ind (k=0)-b/8 ≤ Q k := byby_cases hk : k=0· subst khave hQ : Q 0=1 := by unfold Q; simp only [vectorPhase,zero_dotProduct,wsign_zero,one_mul,hu.avg_const]rw [ind_one (show (0:Vec (Fin d))=0 from rfl),hQ]; linarithlet k' := f khave hT := h k' (totalRank_pos (hf.ne hk |>.trans_eq (map_zero f))) (hg k)have hz : |zsumPeak p w (v.shanty m k') P| ≤ (glintRate K)*pr w P :=le_of_lt (lt_of_not_ge (fun h => hT ⟨he,h⟩))have ht :avg u (fun z => vectorPhase k (s z))=zsumPeak p w (v.shanty m k') P/pr w P := byunfold s u onW; simp_rw [staining]; rw [avg_norm,subW_tot]congr 1; simp [zsumPeak,avg,subW,mul_assoc,k']have h1 : |Q k|≤b/8 := byunfold Q; rw [ht,abs_mul,vectorPhase,wsign_abs,one_mul,abs_div,abs_of_pos hP]refine le_trans ((div_le_iff₀ hP).mpr hz) ((glint_within hd).trans_eq (by unfold b; ring))rw [ind_zero hk,zero_sub]; exact (abs_le.mp h1).1have h0 : unif (0:Vec (Fin d))=b := byunfold b; rw [unif_apply,card_space,dim_vec,bp_neg,Fintype.card_fin]change _ ≤ pr u (fun z => s z=x)rw [heq]refine le_trans ?_ (avg_mono unif_law.nz hh)rw [avg_sub,unif_law.avg_const,show avg unif (fun i : Vec (Fin d)=> ind (i=0))=b from (pr_point' unif _).trans h0]change 7/8*b≤_linarithend Templateend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import OAI.Combinatorics.HadwigerCounterexample.CrossPatternCountingnamespace OAI/-! # Batch Characters -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Module LinearMap Function Finsetvariable {I J A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]variable [DecidableEq I] [DecidableEq J] [DecidableEq A] [DecidableEq B]variable {n N t : ℕ}def led (i : I) (x : Rack (I×J) N) := sectionR (fun j => (i,j)) xdef relay (I J : Type) [Fintype I] [Fintype J] (N) :Rack (I×J) N ≃ (I → Rack J N) wheretoFun x i := led i xinvFun x := (Matrix.of (fun i j => (x j.1).1 i j.2), Matrix.of (fun i j => (x j.1).2 i j.2))left_inv x := by apply Prod.ext <;> rflright_inv x := funext fun _ => Prod.ext rfl rfltheorem led_uniform (F : Wgt (I→Rack J N)) :avg (unif : Wgt (Rack (I×J) N)) (fun x => F (fun i => led i x))=avg (draws I unif) F := bychange avg unif (fun x => F (relay I J N x))=_rw [← mapW_avg,unif_equiv,← draws_unif]theorem led_piece (T : Finset I) (p : I→Rack J N→Prop) :avg unif (fun x => ∏ i∈T,ind (p i (led i x))) =∏ i∈T,pr unif (p i) := byclassicallet F (i : I) (z) := if i∈T then ind (p i z) else 1let H : Wgt (I→ Rack J N) := prodW Fhave he x : (∏ i∈T,ind (p i (led i x))) = H (fun i => led i x) := byunfold H F prodWrw [← Finset.prod_filter]; simphave hf i : avg unif (F i) = if i∈T then pr unif (p i) else 1 := byby_cases hh : i∈T <;> simp [F,pr,hh,unif_law.avg_const]simp_rw [he]; rw [led_uniform]unfold H drawsrw [prodW_avg]; simp_rw [hf]; rw [← Finset.prod_filter]; simpdef heard (T : A → I×J) := Finset.univ.image (Prod.fst ∘ T)omit [Fintype I] [Fintype J] [DecidableEq A] intheorem heard_fresh {T : A→I × J} {i : I} (B : PlusRack A N) (h : i∉heard T) (j : J) (k) :upliftR T B k (i,j)=0 := byclassicalunfold upliftRrw [Matrix.mul_apply]refine Finset.sum_eq_zero fun x _ => ?_have he : (i,j)≠T x := fun e => h (mem_image.mpr⟨x,mem_univ _, (congrArg Prod.fst e).symm⟩)simp [embedMat,he]omit [Fintype I] [Fintype J] [DecidableEq A] inprivate theorem led_off_r (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)(h : i∉heard T) :led i (x+(0,upliftR T B)) = led i x := byapply Prod.ext· ext; simp [led,sectionR]extsimp only [led,sectionR,Prod.snd_add,Matrix.add_apply,Matrix.submatrix_apply,heard_fresh B h,add_zero]omit [Fintype I] [Fintype J] [DecidableEq A] inprivate theorem led_off_l (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)(h : i∉heard T) :led i (x+(upliftR T B,0)) = led i x := byapply Prod.ext· extsimp only [led,sectionR,Prod.fst_add,Matrix.add_apply,Matrix.submatrix_apply,heard_fresh B h,add_zero]ext; simp [led,sectionR]def phot (P : I→Rack J N→Prop) (x : Rack (I×J) N) :=∏ i:I,ind (P i (led i x))set_option maxHeartbeats 800000 intheorem light_bound (M : Avenue I J) (P : I→Rack J N→Prop) (u : ℝ) (hu : 0 ≤ u)(hp : ∀ i,bp (-u) ≤ pr unif (P i)) :|avg unif (fun x => phasedBy M x*phot P x)| ≤bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * ∏ i,pr unif (P i) := byclassicalobtain ⟨T,U,hTU,hA⟩ := real_peak Mlet t := peak Mlet L := heard Tlet R := heard Ulet D := L∪Rlet S := Finset.univ \ Dhave hd : Disjoint L R := byrefine Finset.disjoint_left.mpr ?_intro x hx hyobtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hxobtain ⟨j,_,he⟩ := Finset.mem_image.mp hyexact hTU i j he.symmlet f (Z : Finset I) (x : Rack (I×J) N) := ∏ i∈Z,ind (P i (led i x))have hs (V : Finset I) x : |f V x|=f V x := abs_of_nonneg (Finset.prod_nonneg (fun i _ =>ind_nonneg _))have heq (V : Finset I) x : |f V x|≤1 := (hs V x).trans_le((Finset.prod_le_prod₀ (fun _ _ => ind_nonneg _) (fun _ _ => ind_le_one _)).trans_eq (by simp))have h1 :(∏ i,pr unif (P i))=(∏ i∈D,pr unif (P i))*(∏ i∈S,pr unif (P i)) := byrw [←Finset.prod_union (show Disjoint D S from disjoint_sdiff),Finset.union_sdiff_of_subset (Finset.subset_univ D)]have hf x : phot P x=f L x*f R x*f S x := byunfold phot frw [←Finset.prod_union hd,←Finset.prod_union (show Disjoint D S from disjoint_sdiff),Finset.union_sdiff_of_subset (Finset.subset_univ D)]have hl :|avg unif (fun x => phasedBy M x*phot P x)| ≤ bp (-(N:ℝ)*t/2) * avg unif (fun x => |f S x|) := byhave he x : phasedBy M x*phot P x=phasedBy M x*f L x*f R x*f S x := by rw [hf]; ringsimp_rw [he]rw [←show (M.submatrix T U).rank=t from(mrk_inj.mp hA).trans (Fintype.card_fin _)]refine layerLeak M (f L) (f R) (f S) T U (heq _) (heq _) (fun x y => ?_)(fun x y => ?_) (fun x y z => ?_)· refine Finset.prod_congr rfl fun i hi => ?_rw [led_off_r x y (fun h => Finset.disjoint_left.mp hd hi h)]· refine Finset.prod_congr rfl fun i hi => ?_rw [led_off_l x y (fun h => Finset.disjoint_left.mp hd h hi)]· refine Finset.prod_congr rfl fun i hi => ?_have hr := (Finset.mem_sdiff.mp hi).2rw [show x+(upliftR T y,upliftR U z)=x+(0,upliftR U z)+(upliftR T y,0) fromby rw [add_assoc]; apply congrArg; apply Prod.ext <;> simp,led_off_l _ y (fun h => hr (mem_union_left _ h)),led_off_r _ z (fun h => hr (mem_union_right _ h))]apply hl.transsimp_rw [hs]rw [show avg unif (fun x => f S x)= _ from led_piece S P,h1,← mul_assoc]refine mul_le_mul_of_nonneg_right ?_ (Finset.prod_nonneg fun _ _ => pr_nonneg unif_law.nz)have hc : D.card ≤ 2*t := byapply le_trans (Finset.card_union_le ..)have hi (T : Fin t→ I × J) : (heard T).card≤t :=Finset.card_image_le.trans_eq (by simp)rw [two_mul]; exact add_le_add (hi T) (hi U)have hQ : bp (-u*(2*(t:ℝ))) ≤ ∏ i∈D,pr unif (P i) := byrefine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => (bp_pos _).le) fun i _ => hp i)rw [Finset.prod_const,←bp_mul_nat]apply bp_leapply mul_le_mul_of_nonpos_left· exact_mod_cast hcexact neg_nonpos.mpr hucalc bp __ = bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * bp (-u*(2*t)) := by rw [←bp_add]; congr 1; unfold t; ring_ ≤ _ := mul_le_mul_of_nonneg_left hQ (bp_pos _).leend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import OAI.Combinatorics.HadwigerCounterexample.CrossPatternCountingnamespace OAI/-! # Batch Characters -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Module LinearMap Function Finsetvariable {I J A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]variable [DecidableEq I] [DecidableEq J] [DecidableEq A] [DecidableEq B]variable {n N t : ℕ}def led (i : I) (x : Rack (I×J) N) := sectionR (fun j => (i,j)) xdef relay (I J : Type) [Fintype I] [Fintype J] (N) :Rack (I×J) N ≃ (I → Rack J N) wheretoFun x i := led i xinvFun x := (Matrix.of (fun i j => (x j.1).1 i j.2), Matrix.of (fun i j => (x j.1).2 i j.2))left_inv x := by apply Prod.ext <;> rflright_inv x := funext fun _ => Prod.ext rfl rfltheorem led_uniform (F : Wgt (I→Rack J N)) :avg (unif : Wgt (Rack (I×J) N)) (fun x => F (fun i => led i x))=avg (draws I unif) F := bychange avg unif (fun x => F (relay I J N x))=_rw [← mapW_avg,unif_equiv,← draws_unif]theorem led_piece (T : Finset I) (p : I→Rack J N→Prop) :avg unif (fun x => ∏ i∈T,ind (p i (led i x))) =∏ i∈T,pr unif (p i) := byclassicallet F (i : I) (z) := if i∈T then ind (p i z) else 1let H : Wgt (I→ Rack J N) := prodW Fhave he x : (∏ i∈T,ind (p i (led i x))) = H (fun i => led i x) := byunfold H F prodWrw [← Finset.prod_filter]; simphave hf i : avg unif (F i) = if i∈T then pr unif (p i) else 1 := byby_cases hh : i∈T <;> simp [F,pr,hh,unif_law.avg_const]simp_rw [he]; rw [led_uniform]unfold H drawsrw [prodW_avg]; simp_rw [hf]; rw [← Finset.prod_filter]; simpdef heard (T : A → I×J) := Finset.univ.image (Prod.fst ∘ T)omit [Fintype I] [Fintype J] [DecidableEq A] intheorem heard_fresh {T : A→I × J} {i : I} (B : PlusRack A N) (h : i∉heard T) (j : J) (k) :upliftR T B k (i,j)=0 := byclassicalunfold upliftRrw [Matrix.mul_apply]refine Finset.sum_eq_zero fun x _ => ?_have he : (i,j)≠T x := fun e => h (mem_image.mpr⟨x,mem_univ _, (congrArg Prod.fst e).symm⟩)simp [embedMat,he]omit [Fintype I] [Fintype J] [DecidableEq A] inprivate theorem led_off_r (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)(h : i∉heard T) :led i (x+(0,upliftR T B)) = led i x := byapply Prod.ext· ext; simp [led,sectionR]extsimp only [led,sectionR,Prod.snd_add,Matrix.add_apply,Matrix.submatrix_apply,heard_fresh B h,add_zero]omit [Fintype I] [Fintype J] [DecidableEq A] inprivate theorem led_off_l (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)(h : i∉heard T) :led i (x+(upliftR T B,0)) = led i x := byapply Prod.ext· extsimp only [led,sectionR,Prod.fst_add,Matrix.add_apply,Matrix.submatrix_apply,heard_fresh B h,add_zero]ext; simp [led,sectionR]def phot (P : I→Rack J N→Prop) (x : Rack (I×J) N) :=∏ i:I,ind (P i (led i x))set_option maxHeartbeats 800000 intheorem light_bound (M : Avenue I J) (P : I→Rack J N→Prop) (u : ℝ) (hu : 0 ≤ u)(hp : ∀ i,bp (-u) ≤ pr unif (P i)) :|avg unif (fun x => phasedBy M x*phot P x)| ≤bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * ∏ i,pr unif (P i) := byclassicalobtain ⟨T,U,hTU,hA⟩ := real_peak Mlet t := peak Mlet L := heard Tlet R := heard Ulet D := L∪Rlet S := Finset.univ \ Dhave hd : Disjoint L R := byrefine Finset.disjoint_left.mpr ?_intro x hx hyobtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hxobtain ⟨j,_,he⟩ := Finset.mem_image.mp hyexact hTU i j he.symmlet f (Z : Finset I) (x : Rack (I×J) N) := ∏ i∈Z,ind (P i (led i x))have hs (V : Finset I) x : |f V x|=f V x := abs_of_nonneg (Finset.prod_nonneg (fun i _ =>ind_nonneg _))have heq (V : Finset I) x : |f V x|≤1 := (hs V x).trans_le((Finset.prod_le_prod₀ (fun _ _ => ind_nonneg _) (fun _ _ => ind_le_one _)).trans_eq (by simp))have h1 :(∏ i,pr unif (P i))=(∏ i∈D,pr unif (P i))*(∏ i∈S,pr unif (P i)) := byrw [←Finset.prod_union (show Disjoint D S from disjoint_sdiff),Finset.union_sdiff_of_subset (Finset.subset_univ D)]have hf x : phot P x=f L x*f R x*f S x := byunfold phot frw [←Finset.prod_union hd,←Finset.prod_union (show Disjoint D S from disjoint_sdiff),Finset.union_sdiff_of_subset (Finset.subset_univ D)]have hl :|avg unif (fun x => phasedBy M x*phot P x)| ≤ bp (-(N:ℝ)*t/2) * avg unif (fun x => |f S x|) := byhave he x : phasedBy M x*phot P x=phasedBy M x*f L x*f R x*f S x := by rw [hf]; ringsimp_rw [he]rw [←show (M.submatrix T U).rank=t from(mrk_inj.mp hA).trans (Fintype.card_fin _)]refine layerLeak M (f L) (f R) (f S) T U (heq _) (heq _) (fun x y => ?_)(fun x y => ?_) (fun x y z => ?_)· refine Finset.prod_congr rfl fun i hi => ?_rw [led_off_r x y (fun h => Finset.disjoint_left.mp hd hi h)]· refine Finset.prod_congr rfl fun i hi => ?_rw [led_off_l x y (fun h => Finset.disjoint_left.mp hd h hi)]· refine Finset.prod_congr rfl fun i hi => ?_have hr := (Finset.mem_sdiff.mp hi).2rw [show x+(upliftR T y,upliftR U z)=x+(0,upliftR U z)+(upliftR T y,0) fromby rw [add_assoc]; apply congrArg; apply Prod.ext <;> simp,led_off_l _ y (fun h => hr (mem_union_left _ h)),led_off_r _ z (fun h => hr (mem_union_right _ h))]apply hl.transsimp_rw [hs]rw [show avg unif (fun x => f S x)= _ from led_piece S P,h1,← mul_assoc]refine mul_le_mul_of_nonneg_right ?_ (Finset.prod_nonneg fun _ _ => pr_nonneg unif_law.nz)have hc : D.card ≤ 2*t := byapply le_trans (Finset.card_union_le ..)have hi (T : Fin t→ I × J) : (heard T).card≤t :=Finset.card_image_le.trans_eq (by simp)rw [two_mul]; exact add_le_add (hi T) (hi U)have hQ : bp (-u*(2*(t:ℝ))) ≤ ∏ i∈D,pr unif (P i) := byrefine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => (bp_pos _).le) fun i _ => hp i)rw [Finset.prod_const,←bp_mul_nat]apply bp_leapply mul_le_mul_of_nonpos_left· exact_mod_cast hcexact neg_nonpos.mpr hucalc bp __ = bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * bp (-u*(2*t)) := by rw [←bp_add]; congr 1; unfold t; ring_ ≤ _ := mul_le_mul_of_nonneg_left hQ (bp_pos _).leend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142import OAI.Combinatorics.HadwigerCounterexample.OrthogonalSpectrumBoundsnamespace OAI/-! # Biased Rotation Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Module Submodule Function LinearMap Filter Realopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}set_option maxHeartbeats 1200000 intheorem spinning (p : Shape) (w : Wgt (Knobs p.g n))(f : Flit n→Wgt (Knobs p.g n)) (P : Knobs p.g n→Prop)(hw : IsLaw w) (hf : ∀ i j,|f i j|≤1) (h : flowZ p w)(b g δ : ℝ) (hb : 0≤b)(T : Space (Vec (Fin n))) (s l : ℕ) (hk : s<n)(hh : ∀ (c : Flit n) x i, |zchar p (f c) i x|≤b ∧(i∉ c.plume T → zchar p (f c) i x=0))(hδ : 0<δ) (ht : b*bp s < g) (hP : δ≤ pr w P)(hL : 1 < l * ((g-b*bp s)*δ)^2) :pr unif (fun c => g*pr w P ≤ |zsumPeak p w (f c) P|) ≤bp (1+((dim T:ℝ)+l*(dim T:ℝ)-n)*s) := byclassicallet M := g-b*bp s; have hM : 0<M := sub_pos.mpr htlet D c := g*pr w P ≤ |zsumPeak p w (f c) P|by_contra! Hhave progress (i : ℕ) (h' : i≤l) :∃ (S : Space (Vec (Fin n))) (U : Wgt (Knobs p.g n)),zsafe p w U S ∧ dim S≤ i*dim T ∧ i*(M*δ) ≤ zsumPeak p w U P ∧avg w (fun x=>U x ^ 2) ≤ i := byinduction i with| zero =>refine ⟨⊥,fun _=>0,?_,?_,?_,?_⟩· intro i t h; simp only [zero_mul,avg_zero]· simp [dim]· simp [zsumPeak,avg_zero]simp only [zero_pow (by decide : 2 ≠ 0),avg_zero,Nat.cast_zero,le_refl]| succ i ih =>obtain ⟨S,U,hS,hU,h1,h2⟩ := ih (by omega)let Q (c : Flit n) := s < dim (c.plume T ⊓ S : Space (Vec (Fin n)))have hh' : ∃ c : Flit n, D c ∧ ¬ Q c := byby_contra! hhhave hz := (pr_mono unif_law.nz (fun c (h : D c) =>(hh c h).le)).trans (Move.plume_meets n s hk T S)have hy : (dim S:ℝ)≤ l*(dim T:ℝ) := byexact_mod_cast (hU.trans (Nat.mul_le_mul_right _ (by omega) : i*dim T ≤ l*dim T))apply (not_lt_of_ge (le_trans hz (bp_le ?_))) Hnlinarith only [mul_le_mul_of_nonneg_right hy (Nat.cast_nonneg s : 0≤(s:ℝ))]obtain ⟨c,he,hc⟩ := hh'let W := c.plume Thave hk : dim (S ⊓ W : Space (Vec (Fin n))) ≤ s := byhave hh : dim (W⊓S : Space (Vec (Fin n))) ≤ s := le_of_not_gt hcrw [inf_comm]; exact hhobtain ⟨t,a,ha,hA,hy,hz⟩ := clear_band p w (f c) P hw (hf c) h b g hb he S W s hk (hh c)let Z i := a*zim p (f c) t ilet C i := U i+Z ihave hQ : avg w (fun i=>U i * Z i)=0 := byhave he := hS (f c) t (fun i hi => (hA i hi).1)unfold Z; simp_rw [mul_left_comm _ a,avg_mul',he,mul_zero]refine ⟨S ⊔ W,C,?_,?_,?_,?_⟩· intro i s hhhave hL := zsplit_orth p (f c) i w h t s (Finset.disjoint_left.mpr (fun j hj he =>hh j he ((show W≤S⊔W from le_sup_right) (hA j hj).2)))have he := hS i s (fun j hj h => hh j hj ((show S≤S⊔W from le_sup_left) h))unfold C Z; simp only [add_mul,mul_assoc,avg_add,avg_mul',he,hL,mul_zero,add_zero]· have h := Submodule.finrank_add_le_finrank_add_finrank S Wrefine le_trans h ?_change dim S+dim W≤_unfold W; rw [Move.plume_dim c T,Nat.add_mul,one_mul]omega· unfold zsumPeak C; simp_rw [mul_add,avg_add]change _≤zsumPeak p w U P+zsumPeak p w Z Pchange M*pr w P ≤ zsumPeak p w Z P at hypush_castnlinarith only [h1,hy,mul_le_mul_of_nonneg_left hP hM.le]· have hh (i) : C i^2=U i^2+Z i^2+2*(U i*Z i) := by unfold C; ringsimp_rw [hh,avg_add,avg_mul',hQ,mul_zero,add_zero]exact (add_le_add h2 hz).trans_eq (by push_cast; rfl)obtain ⟨S,U,_,_,hu,hq⟩ := progress l (le_refl _)have hh : ↑l * (M*δ) ≤ zsumPeak p w U P := huhave hx :zsumPeak p w U P ^2 ≤ l := byapply (avg_CS hw.nz (fun i=>ind (P i)) U).transhave hz (i : Knobs p.g n) : ind (P i)^2 ≤ 1 :=calc ind (P i)^2 ≤ 1^2 := pow_le_pow_left₀ (ind_nonneg _) (ind_le_one _) __ = _ := one_pow _exact (mul_le_mul (hw.avg_le hz) hq (avg_nonneg hw.nz (fun _ => sq_nonneg _))zero_le_one).trans_eq (one_mul _)have hy := pow_le_pow_left₀ (by positivity) hh 2change 1<↑l*(M*δ)^2 at hLhave hl : 0<l := byby_contra! heobtain rfl : l=0 := by omeganorm_num at hLnlinarith only [hx,hy,mul_lt_mul_of_pos_left hL(Nat.cast_pos.mpr hl : (0:ℝ) < l)]namespace Templatevariable {K s A : ℕ}theorem rotor_levels (v : Solo p) (K s a : ℕ)(hs : 2*a<s) (hg : Odd p.g)(δ g : ℝ) (hδ : 0<δ)(hG : bp (-((p.J-s:ℕ):ℝ))*bp s < g) :∀ᶠ n : ℕ in atTop, ∀ m : Mixer p n, unaryGood m K s →∀ x : Profile p n, 0<totalRank x → totalRank x ≤ K →∀ w : Wgt (Knobs p.g n), IsLaw w → flowZ p w →∀ P : Knobs p.g n → Prop, δ ≤ pr w P →pr unif (fun c => g*pr w P ≤|zsumPeak p w (v.rotor c m x) P|) ≤ bp (-(2*a:ℝ)*n) := byclassicallet b := bp (-((p.J-s:ℕ):ℝ))have hb : b*bp s<g := hGlet t := ((g-b*bp s)*δ)^2have ht : 0<t := by apply pow_pos (mul_pos (sub_pos.mpr hb) hδ)obtain ⟨l,hl⟩ := exists_nat_gt (1/t)let d := 2*(p.J*(p.g-1)*(2*K))have ha : 0<(s:ℝ)-2*a := sub_pos.mpr (by exact_mod_cast hs)have hz : Tendsto (fun n:ℕ => (↑s-2*a:ℝ)*n) atTop atTop :=(tendsto_const_mul_atTop_of_pos ha).mpr tendsto_natCast_atTop_atTopfilter_upwards [eventually_gt_atTop s,hz.eventually (eventually_ge_atTop(1+((d:ℝ)+l*d)*s))] with n hn hN m hm x hx hK w hw hh P hPhave he := spinning p w (fun c=>v.rotor c m x) P hw (byintro i j; unfold rotor Move.zreroute shanty; rw [wsign_abs]) hh b g δ(bp_pos _).le _ s l hn (fun c y i => v.rotor_budget c m x K s hg hm hK hx y i)hδ hb hP ((div_lt_iff₀ ht).mp hl)apply he.transapply bp_lehave hy :dim (v.scroll m x) ≤ d :=(scroll_dim v m x).trans (by unfold d; gcongr)have hx : ((dim (v.scroll m x)):ℝ) ≤ d := by exact_mod_cast hychange 1+((d:ℝ)+l*d)*s≤ ((s:ℝ)-2*a)*n at hNhave hB := mul_le_mul_of_nonneg_left hx (Nat.cast_nonneg l : 0≤(l:ℝ))nlinarith only [mul_le_mul_of_nonneg_right (add_le_add hx hB)(Nat.cast_nonneg s : 0≤(s:ℝ)),hN]end Templateend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142import OAI.Combinatorics.HadwigerCounterexample.OrthogonalSpectrumBoundsnamespace OAI/-! # Biased Rotation Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Module Submodule Function LinearMap Filter Realopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}set_option maxHeartbeats 1200000 intheorem spinning (p : Shape) (w : Wgt (Knobs p.g n))(f : Flit n→Wgt (Knobs p.g n)) (P : Knobs p.g n→Prop)(hw : IsLaw w) (hf : ∀ i j,|f i j|≤1) (h : flowZ p w)(b g δ : ℝ) (hb : 0≤b)(T : Space (Vec (Fin n))) (s l : ℕ) (hk : s<n)(hh : ∀ (c : Flit n) x i, |zchar p (f c) i x|≤b ∧(i∉ c.plume T → zchar p (f c) i x=0))(hδ : 0<δ) (ht : b*bp s < g) (hP : δ≤ pr w P)(hL : 1 < l * ((g-b*bp s)*δ)^2) :pr unif (fun c => g*pr w P ≤ |zsumPeak p w (f c) P|) ≤bp (1+((dim T:ℝ)+l*(dim T:ℝ)-n)*s) := byclassicallet M := g-b*bp s; have hM : 0<M := sub_pos.mpr htlet D c := g*pr w P ≤ |zsumPeak p w (f c) P|by_contra! Hhave progress (i : ℕ) (h' : i≤l) :∃ (S : Space (Vec (Fin n))) (U : Wgt (Knobs p.g n)),zsafe p w U S ∧ dim S≤ i*dim T ∧ i*(M*δ) ≤ zsumPeak p w U P ∧avg w (fun x=>U x ^ 2) ≤ i := byinduction i with| zero =>refine ⟨⊥,fun _=>0,?_,?_,?_,?_⟩· intro i t h; simp only [zero_mul,avg_zero]· simp [dim]· simp [zsumPeak,avg_zero]simp only [zero_pow (by decide : 2 ≠ 0),avg_zero,Nat.cast_zero,le_refl]| succ i ih =>obtain ⟨S,U,hS,hU,h1,h2⟩ := ih (by omega)let Q (c : Flit n) := s < dim (c.plume T ⊓ S : Space (Vec (Fin n)))have hh' : ∃ c : Flit n, D c ∧ ¬ Q c := byby_contra! hhhave hz := (pr_mono unif_law.nz (fun c (h : D c) =>(hh c h).le)).trans (Move.plume_meets n s hk T S)have hy : (dim S:ℝ)≤ l*(dim T:ℝ) := byexact_mod_cast (hU.trans (Nat.mul_le_mul_right _ (by omega) : i*dim T ≤ l*dim T))apply (not_lt_of_ge (le_trans hz (bp_le ?_))) Hnlinarith only [mul_le_mul_of_nonneg_right hy (Nat.cast_nonneg s : 0≤(s:ℝ))]obtain ⟨c,he,hc⟩ := hh'let W := c.plume Thave hk : dim (S ⊓ W : Space (Vec (Fin n))) ≤ s := byhave hh : dim (W⊓S : Space (Vec (Fin n))) ≤ s := le_of_not_gt hcrw [inf_comm]; exact hhobtain ⟨t,a,ha,hA,hy,hz⟩ := clear_band p w (f c) P hw (hf c) h b g hb he S W s hk (hh c)let Z i := a*zim p (f c) t ilet C i := U i+Z ihave hQ : avg w (fun i=>U i * Z i)=0 := byhave he := hS (f c) t (fun i hi => (hA i hi).1)unfold Z; simp_rw [mul_left_comm _ a,avg_mul',he,mul_zero]refine ⟨S ⊔ W,C,?_,?_,?_,?_⟩· intro i s hhhave hL := zsplit_orth p (f c) i w h t s (Finset.disjoint_left.mpr (fun j hj he =>hh j he ((show W≤S⊔W from le_sup_right) (hA j hj).2)))have he := hS i s (fun j hj h => hh j hj ((show S≤S⊔W from le_sup_left) h))unfold C Z; simp only [add_mul,mul_assoc,avg_add,avg_mul',he,hL,mul_zero,add_zero]· have h := Submodule.finrank_add_le_finrank_add_finrank S Wrefine le_trans h ?_change dim S+dim W≤_unfold W; rw [Move.plume_dim c T,Nat.add_mul,one_mul]omega· unfold zsumPeak C; simp_rw [mul_add,avg_add]change _≤zsumPeak p w U P+zsumPeak p w Z Pchange M*pr w P ≤ zsumPeak p w Z P at hypush_castnlinarith only [h1,hy,mul_le_mul_of_nonneg_left hP hM.le]· have hh (i) : C i^2=U i^2+Z i^2+2*(U i*Z i) := by unfold C; ringsimp_rw [hh,avg_add,avg_mul',hQ,mul_zero,add_zero]exact (add_le_add h2 hz).trans_eq (by push_cast; rfl)obtain ⟨S,U,_,_,hu,hq⟩ := progress l (le_refl _)have hh : ↑l * (M*δ) ≤ zsumPeak p w U P := huhave hx :zsumPeak p w U P ^2 ≤ l := byapply (avg_CS hw.nz (fun i=>ind (P i)) U).transhave hz (i : Knobs p.g n) : ind (P i)^2 ≤ 1 :=calc ind (P i)^2 ≤ 1^2 := pow_le_pow_left₀ (ind_nonneg _) (ind_le_one _) __ = _ := one_pow _exact (mul_le_mul (hw.avg_le hz) hq (avg_nonneg hw.nz (fun _ => sq_nonneg _))zero_le_one).trans_eq (one_mul _)have hy := pow_le_pow_left₀ (by positivity) hh 2change 1<↑l*(M*δ)^2 at hLhave hl : 0<l := byby_contra! heobtain rfl : l=0 := by omeganorm_num at hLnlinarith only [hx,hy,mul_lt_mul_of_pos_left hL(Nat.cast_pos.mpr hl : (0:ℝ) < l)]namespace Templatevariable {K s A : ℕ}theorem rotor_levels (v : Solo p) (K s a : ℕ)(hs : 2*a<s) (hg : Odd p.g)(δ g : ℝ) (hδ : 0<δ)(hG : bp (-((p.J-s:ℕ):ℝ))*bp s < g) :∀ᶠ n : ℕ in atTop, ∀ m : Mixer p n, unaryGood m K s →∀ x : Profile p n, 0<totalRank x → totalRank x ≤ K →∀ w : Wgt (Knobs p.g n), IsLaw w → flowZ p w →∀ P : Knobs p.g n → Prop, δ ≤ pr w P →pr unif (fun c => g*pr w P ≤|zsumPeak p w (v.rotor c m x) P|) ≤ bp (-(2*a:ℝ)*n) := byclassicallet b := bp (-((p.J-s:ℕ):ℝ))have hb : b*bp s<g := hGlet t := ((g-b*bp s)*δ)^2have ht : 0<t := by apply pow_pos (mul_pos (sub_pos.mpr hb) hδ)obtain ⟨l,hl⟩ := exists_nat_gt (1/t)let d := 2*(p.J*(p.g-1)*(2*K))have ha : 0<(s:ℝ)-2*a := sub_pos.mpr (by exact_mod_cast hs)have hz : Tendsto (fun n:ℕ => (↑s-2*a:ℝ)*n) atTop atTop :=(tendsto_const_mul_atTop_of_pos ha).mpr tendsto_natCast_atTop_atTopfilter_upwards [eventually_gt_atTop s,hz.eventually (eventually_ge_atTop(1+((d:ℝ)+l*d)*s))] with n hn hN m hm x hx hK w hw hh P hPhave he := spinning p w (fun c=>v.rotor c m x) P hw (byintro i j; unfold rotor Move.zreroute shanty; rw [wsign_abs]) hh b g δ(bp_pos _).le _ s l hn (fun c y i => v.rotor_budget c m x K s hg hm hK hx y i)hδ hb hP ((div_lt_iff₀ ht).mp hl)apply he.transapply bp_lehave hy :dim (v.scroll m x) ≤ d :=(scroll_dim v m x).trans (by unfold d; gcongr)have hx : ((dim (v.scroll m x)):ℝ) ≤ d := by exact_mod_cast hychange 1+((d:ℝ)+l*d)*s≤ ((s:ℝ)-2*a)*n at hNhave hB := mul_le_mul_of_nonneg_left hx (Nat.cast_nonneg l : 0≤(l:ℝ))nlinarith only [mul_le_mul_of_nonneg_right (add_le_add hx hB)(Nat.cast_nonneg s : 0≤(s:ℝ)),hN]end Templateend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import OAI.Combinatorics.HadwigerCounterexample.OppositeEndpointFormsnamespace OAI/-! # Bilinear Block Correlation -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset LinearMap Module Matrix Functionopen scoped BigOperatorsvariable {p : Shape} {I J A : Type} [Fintype I] [Fintype J] [Fintype A]variable {n : ℕ}def spring (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)(y : Knobs p.g n) := point p s (lit f l y)theorem spring_update (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)(y : Knobs p.g n) (B) (h : f.keeps l B) (z : Vec (Fin n)) :spring p l s f (update y B z)= spring p l s f (update y B 0)+blockRay p n s B *ᵥ z := byclassicalhave he : baseV (lit f l (update y B z))=baseV (lit f l (update y B 0))+blockA p n B *ᵥ z := byfunext arcases a with _|⟨d,j⟩· simp [baseV,blockA,mulVec,dotProduct,embedMat]by_cases hk : d=B· subst d; simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,h]simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,hk]unfold spring point blockRayrw [he,map_add,←Matrix.mulVec_mulVec,labMat_act]private def dotLB (I : Type) [Fintype I] : Vec I →ₗ[F] Vec I→ₗ[F] F wheretoFun := dotLmap_add' p q := LinearMap.ext fun i => add_dotProduct p q imap_smul' a p := LinearMap.ext fun i => bychange dotProduct (a • p) i=a*dotProduct p irw [smul_dotProduct]; rfltheorem spark_walsh [DecidableEq I] [DecidableEq J] (M : Mat I J) (p : Wgt (Vec I)) (q : Wgt (Vec J))(hp : ∀ i, |p i|≤1) (hq : ∀ i, |q i|≤1) :|avg (pairW unif unif) (fun i => wsign (evmat M i.1 i.2)*(p i.1*q i.2))| ≤bp (-(M.rank:ℝ)/2) := byclassicallet Q := dotLB Ilet L := Q ∘ₗ M.mulVecLinhave he (i j) : evmat M i j=L j i := dotProduct_comm ..have hh : Injective Q := fun x y h => funext (fun i => byhave hg := LinearMap.congr_fun h (Pi.single i 1)change dotProduct x (Pi.single i 1)=dotProduct y (Pi.single i 1) at hgsimpa using hg)have ht : rk L=M.rank := byhave h : LinearMap.ker L=LinearMap.ker M.mulVecLin := byext x; change Q (M.mulVecLin x)=0 ↔ M.mulVecLin x=0rw [← map_zero Q,hh.eq_iff]have hv := L.finrank_range_add_finrank_kerrw [h, ← M.mulVecLin.finrank_range_add_finrank_ker] at hvexact Nat.add_right_cancel hvrw [pairW_avg]have hz (x : Vec I) (y : Vec J) : wsign (evmat M x y)*(p x*q y)=p x*(q y*wsign (L y x)) := byrw [he]; ringsimp_rw [hz,avg_mul']rw [←ht]exact walsh_bound _ q p hq hpset_option maxHeartbeats 800000 intheorem spark_uncap (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i| ≤ 1) (hu : ∀ i,|u i|≤1) :let Q i z := evmat M (spring p l s f i) (spring p j t g z)|avg (pairW unif unif) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤bp (-(blockRank B s t M:ℝ)/2) := byclassicalintro Qlet F (x : Knobs p.g n × _) := wsign (Q x.1 x.2)*(w x.1*u x.2)let K := Wgt (Vec (Fin n))let v : Block p.g→ K := fun _ => unifhave ht := update2_avg v v B F unif_law unif_lawhave he : prodW v=unif := draws_unif.symmlet R := blockRay p n s B; let S:=blockRay p n t Blet H := pullM R S Mhave hi (x y : Knobs p.g n) :|avg (pairW (v B) (v B)) (fun i => F (update x B i.1,update y B i.2))|≤bp (-(blockRank B s t M:ℝ)/2) := bylet X := spring p l s f (update x B 0); let Y := spring p j t g (update y B 0)let A i := evmat M (R *ᵥ i) Y; let D j := evmat M X (S *ᵥ j)+evmat M X Ylet Z i := wsign (A i)*w (update x B i); let W j := wsign (D j)*u (update y B j)have hp i j' :Q (update x B i) (update y B j')= evmat H i j'+(A i+D j') := byunfold Q; rw [spring_update _ _ _ _ _ _ hB,spring_update _ _ _ _ _ _ hB']unfold H A D X Y; rw [evmat_pull]simp only [evmat,mulVec_add,add_dotProduct,dotProduct_add,R,S]; ac_rflhave hh i j : F (update x B i,update y B j)=wsign (evmat H i j)*(Z i*W j) := byunfold F Z W; dsimp only; rw [hp,wsign_add,wsign_add]; ringhave hz i : |Z i|≤1 := by unfold Z; rw [abs_mul,wsign_abs,one_mul]; exact hw _have hy i : |W i|≤1 := by unfold W; rw [abs_mul,wsign_abs,one_mul]; exact hu _simp_rw [hh]exact spark_walsh _ Z W hz hysimp only [he] at htchange |avg (pairW unif unif) F|≤_rw [ht]let hq := pairW_law (α:=Knobs p.g n) (β:=Knobs p.g n) unif_law unif_lawexact (abs_avg_le hq.nz).trans (hq.avg_le fun x => hi x.1 x.2)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import OAI.Combinatorics.HadwigerCounterexample.OppositeEndpointFormsnamespace OAI/-! # Bilinear Block Correlation -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset LinearMap Module Matrix Functionopen scoped BigOperatorsvariable {p : Shape} {I J A : Type} [Fintype I] [Fintype J] [Fintype A]variable {n : ℕ}def spring (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)(y : Knobs p.g n) := point p s (lit f l y)theorem spring_update (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)(y : Knobs p.g n) (B) (h : f.keeps l B) (z : Vec (Fin n)) :spring p l s f (update y B z)= spring p l s f (update y B 0)+blockRay p n s B *ᵥ z := byclassicalhave he : baseV (lit f l (update y B z))=baseV (lit f l (update y B 0))+blockA p n B *ᵥ z := byfunext arcases a with _|⟨d,j⟩· simp [baseV,blockA,mulVec,dotProduct,embedMat]by_cases hk : d=B· subst d; simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,h]simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,hk]unfold spring point blockRayrw [he,map_add,←Matrix.mulVec_mulVec,labMat_act]private def dotLB (I : Type) [Fintype I] : Vec I →ₗ[F] Vec I→ₗ[F] F wheretoFun := dotLmap_add' p q := LinearMap.ext fun i => add_dotProduct p q imap_smul' a p := LinearMap.ext fun i => bychange dotProduct (a • p) i=a*dotProduct p irw [smul_dotProduct]; rfltheorem spark_walsh [DecidableEq I] [DecidableEq J] (M : Mat I J) (p : Wgt (Vec I)) (q : Wgt (Vec J))(hp : ∀ i, |p i|≤1) (hq : ∀ i, |q i|≤1) :|avg (pairW unif unif) (fun i => wsign (evmat M i.1 i.2)*(p i.1*q i.2))| ≤bp (-(M.rank:ℝ)/2) := byclassicallet Q := dotLB Ilet L := Q ∘ₗ M.mulVecLinhave he (i j) : evmat M i j=L j i := dotProduct_comm ..have hh : Injective Q := fun x y h => funext (fun i => byhave hg := LinearMap.congr_fun h (Pi.single i 1)change dotProduct x (Pi.single i 1)=dotProduct y (Pi.single i 1) at hgsimpa using hg)have ht : rk L=M.rank := byhave h : LinearMap.ker L=LinearMap.ker M.mulVecLin := byext x; change Q (M.mulVecLin x)=0 ↔ M.mulVecLin x=0rw [← map_zero Q,hh.eq_iff]have hv := L.finrank_range_add_finrank_kerrw [h, ← M.mulVecLin.finrank_range_add_finrank_ker] at hvexact Nat.add_right_cancel hvrw [pairW_avg]have hz (x : Vec I) (y : Vec J) : wsign (evmat M x y)*(p x*q y)=p x*(q y*wsign (L y x)) := byrw [he]; ringsimp_rw [hz,avg_mul']rw [←ht]exact walsh_bound _ q p hq hpset_option maxHeartbeats 800000 intheorem spark_uncap (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i| ≤ 1) (hu : ∀ i,|u i|≤1) :let Q i z := evmat M (spring p l s f i) (spring p j t g z)|avg (pairW unif unif) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤bp (-(blockRank B s t M:ℝ)/2) := byclassicalintro Qlet F (x : Knobs p.g n × _) := wsign (Q x.1 x.2)*(w x.1*u x.2)let K := Wgt (Vec (Fin n))let v : Block p.g→ K := fun _ => unifhave ht := update2_avg v v B F unif_law unif_lawhave he : prodW v=unif := draws_unif.symmlet R := blockRay p n s B; let S:=blockRay p n t Blet H := pullM R S Mhave hi (x y : Knobs p.g n) :|avg (pairW (v B) (v B)) (fun i => F (update x B i.1,update y B i.2))|≤bp (-(blockRank B s t M:ℝ)/2) := bylet X := spring p l s f (update x B 0); let Y := spring p j t g (update y B 0)let A i := evmat M (R *ᵥ i) Y; let D j := evmat M X (S *ᵥ j)+evmat M X Ylet Z i := wsign (A i)*w (update x B i); let W j := wsign (D j)*u (update y B j)have hp i j' :Q (update x B i) (update y B j')= evmat H i j'+(A i+D j') := byunfold Q; rw [spring_update _ _ _ _ _ _ hB,spring_update _ _ _ _ _ _ hB']unfold H A D X Y; rw [evmat_pull]simp only [evmat,mulVec_add,add_dotProduct,dotProduct_add,R,S]; ac_rflhave hh i j : F (update x B i,update y B j)=wsign (evmat H i j)*(Z i*W j) := byunfold F Z W; dsimp only; rw [hp,wsign_add,wsign_add]; ringhave hz i : |Z i|≤1 := by unfold Z; rw [abs_mul,wsign_abs,one_mul]; exact hw _have hy i : |W i|≤1 := by unfold W; rw [abs_mul,wsign_abs,one_mul]; exact hu _simp_rw [hh]exact spark_walsh _ Z W hz hysimp only [he] at htchange |avg (pairW unif unif) F|≤_rw [ht]let hq := pairW_law (α:=Knobs p.g n) (β:=Knobs p.g n) unif_law unif_lawexact (abs_avg_le hq.nz).trans (hq.avg_le fun x => hi x.1 x.2)end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126import OAI.Combinatorics.HadwigerCounterexample.PrimalSpaceCompressionnamespace OAI/-! # Bilinear Compression -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Submodule Module Finsetopen scoped BigOperatorsvariable {p : Shape} {n : ℕ} {I J : Type} [Fintype I] [Fintype J]def dqBound (p : Shape) (T H R : ℕ) := 2*(drow p T R+H)private theorem pullM_fix (A : Mat I I) (P : Mat I I)(h : ∀ x ∈ colSp P,Aᵀ *ᵥ x=x) (h' : ∀ x∈colSp Pᵀ,Aᵀ *ᵥ x=x) :pullM A A P=P := byrw [pullM_def,mat_mul_fix h]have he := congrArg Matrix.transpose (mat_mul_fix h')simpa only [Matrix.transpose_mul,Matrix.transpose_transpose] using heprivate def dualSpace (M : Profile p n) (z : Place p) :=colSp (if z.2 then M z.1 else (M z.1)ᵀ)private theorem dualSpace_dim (M : Profile p n) (z : Place p) :dim (dualSpace M z)=(M z.1).rank := bycases z with| mk i b =>cases b; exact Matrix.rank_transpose _; rflprivate def jointShrink (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))(z : Place p) :=∑ i : Bool,(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+liftM (IH p n i) (IH p n i) (B z i))private theorem joint_ip (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))(z : Place p) (i : Bool) :jointShrink A B z * IP p n i = IP p n i * rowShrink p (A i) := byclassicalsimp only [jointShrink,Fintype.sum_bool,liftM_def,Matrix.add_mul,Matrix.mul_assoc,IH_IP,Matrix.mul_zero,add_zero]cases i <;> simp only [IP_self,IP_cross (show true≠false by decide),IP_cross (show false≠true by decide),Matrix.mul_zero,Matrix.mul_one,add_zero,zero_add]set_option maxHeartbeats 800000 intheorem shrink_pure {f : Plan p n} {M : Individual p n} {P : PureForms p n}(T H R : ℕ) (ht : ∀ z i,dim (sPin f z i)≤T) (hh : ∀ z i,dim (hPin f z i)≤H)(hr : ∀ i e,(M i e).rank≤R)(hp : P∈pureSpace p f) (he : obsPair p P=obsI p M) :∃ Q∈pureSpace p f,obsPair p Q=obsPair p P ∧ ∀ e,(Q e).rank≤dqBound p T H R := byclassicalchoose A hA hL hT using fun i => shrink_both (fun z => sPin f z i) (dualSpace (M i)) T R(fun z => ht z i) (fun z => by rw [dualSpace_dim]; exact hr i z.1)choose B hB using fun z i => proj_exists (hPin f z i) ⊥ disjoint_bot_rightlet D := jointShrink A Bhave hf (z : Place p) (x : Dir p n) (hx : x∈f z) : D z *ᵥ x=x := byhave h1 (i : Bool) : rowShrink p (A i) *ᵥ ((IP p n i)ᵀ *ᵥ x)=(IP p n i)ᵀ *ᵥ x :=hA i z _ ⟨_,hx,rfl⟩have h2 (i : Bool) : B z i *ᵥ ((IH p n i)ᵀ *ᵥ x)=(IH p n i)ᵀ *ᵥ x :=(hB z i).fixes _ ⟨_,hx,rfl⟩unfold D jointShrinksimp only [Matrix.sum_mulVec,Matrix.add_mulVec,liftM_def,← Matrix.mulVec_mulVec,h1,h2]exact ip_decomp xhave hR (z : Place p) : (D z).rank ≤ dqBound p T H R := byapply le_trans (mrk_sum_le ..)have hx i :(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+liftM (IH p n i) (IH p n i) (B z i)).rank ≤ drow p T R+H :=(mrk_add_le ..).trans (add_le_add((rank_lift_le ..).trans (hT i)) ((rank_lift_le ..).trans((rank_maps (hPin f z i) (hB z i).onto).trans (hh z i))))rw [Fintype.sum_bool,dqBound,two_mul]; exact add_le_add (hx _) (hx _)let Q (e : Comp p.g) := pullM (D (e,true)) (D (e,false)) (P e)have hG (i : Bool) (e : Comp p.g) : pullM (rowShrink p (A i)) (rowShrink p (A i)) (M i e)=M i e := pullM_fix _ _ (hL i (e,true)) (hL i (e,false))have hY (i : Bool) (e : Comp p.g) : eachF p Q i e=pullM (rowShrink p (A i)) (rowShrink p (A i)) (eachF p P i e) := bychange pullM _ _ (Q e)=pullM _ _ (pullM _ _ _)let G := IP p n ihave hw {I J K U V W : Type} [Fintype U] [Fintype V] [Fintype W] [Fintype I][Fintype J] [Fintype K] (L : Mat U I) (R : Mat V J)(L' : Mat I K) (R' : Mat J W) (P : Mat U V) :pullM L' R' (pullM L R P) = pullM (L*L') (R*R') P := byunfold pullMrw [liftM_comp,Matrix.transpose_mul,Matrix.transpose_mul]unfold Qrw [hw,hw]have h (b) := joint_ip A B (e,b) irw [show D (e,true)*IP p n i=_ from h true, show D (e,false)*IP p n i=_ from h false]refine ⟨Q,?_,?_,fun e => ?_⟩· refine (pureSpace_mem _).mpr fun e => ?_obtain ⟨h1,h2⟩ := box_kill.mp ((pureSpace_mem _).mp hp e)unfold Q; rw [box_kill,pullM_def]; constructor· intro x hxsimp only [transpose_mul,transpose_transpose,←Matrix.mulVec_mulVec,hf (e,true) x hx,h1 x hx,mulVec_zero]intro x hxrw [← mulVec_mulVec,hf (e,false) x hx]rw [← mulVec_mulVec,h2 x hx,mulVec_zero]· rw [he,obsPair_each]rw [obsPair_each] at hechange combineF p _=combineF p _change combineF p _=combineF p _ at hehave he := (combineF_same ..).mp heapply (combineF_same ..).mprintro i x hxlet y : Profile p n := fun e => liftM (rowShrink p (A i)) (rowShrink p (A i)) (x e)rw [repF_rep,repF_rep]have hv := he i y (shrink_X (A i) x hx)rw [repF_rep,repF_rep] at hvhave hu (F : Individual p n) : (∑ e,mpair (F i e) (y e))=∑ e,mpair (pullM (rowShrink p (A i)) (rowShrink p (A i)) (F i e)) (x e) :=Finset.sum_congr rfl fun e _ => mpair_liftM ..rw [hu,hu] at hvsimp_rw [← hY,hG] at hvexact hvunfold Q; rw [pullM_def]exact ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans(by rw [Matrix.rank_transpose]; exact hR _)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126import OAI.Combinatorics.HadwigerCounterexample.PrimalSpaceCompressionnamespace OAI/-! # Bilinear Compression -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Submodule Module Finsetopen scoped BigOperatorsvariable {p : Shape} {n : ℕ} {I J : Type} [Fintype I] [Fintype J]def dqBound (p : Shape) (T H R : ℕ) := 2*(drow p T R+H)private theorem pullM_fix (A : Mat I I) (P : Mat I I)(h : ∀ x ∈ colSp P,Aᵀ *ᵥ x=x) (h' : ∀ x∈colSp Pᵀ,Aᵀ *ᵥ x=x) :pullM A A P=P := byrw [pullM_def,mat_mul_fix h]have he := congrArg Matrix.transpose (mat_mul_fix h')simpa only [Matrix.transpose_mul,Matrix.transpose_transpose] using heprivate def dualSpace (M : Profile p n) (z : Place p) :=colSp (if z.2 then M z.1 else (M z.1)ᵀ)private theorem dualSpace_dim (M : Profile p n) (z : Place p) :dim (dualSpace M z)=(M z.1).rank := bycases z with| mk i b =>cases b; exact Matrix.rank_transpose _; rflprivate def jointShrink (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))(z : Place p) :=∑ i : Bool,(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+liftM (IH p n i) (IH p n i) (B z i))private theorem joint_ip (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))(z : Place p) (i : Bool) :jointShrink A B z * IP p n i = IP p n i * rowShrink p (A i) := byclassicalsimp only [jointShrink,Fintype.sum_bool,liftM_def,Matrix.add_mul,Matrix.mul_assoc,IH_IP,Matrix.mul_zero,add_zero]cases i <;> simp only [IP_self,IP_cross (show true≠false by decide),IP_cross (show false≠true by decide),Matrix.mul_zero,Matrix.mul_one,add_zero,zero_add]set_option maxHeartbeats 800000 intheorem shrink_pure {f : Plan p n} {M : Individual p n} {P : PureForms p n}(T H R : ℕ) (ht : ∀ z i,dim (sPin f z i)≤T) (hh : ∀ z i,dim (hPin f z i)≤H)(hr : ∀ i e,(M i e).rank≤R)(hp : P∈pureSpace p f) (he : obsPair p P=obsI p M) :∃ Q∈pureSpace p f,obsPair p Q=obsPair p P ∧ ∀ e,(Q e).rank≤dqBound p T H R := byclassicalchoose A hA hL hT using fun i => shrink_both (fun z => sPin f z i) (dualSpace (M i)) T R(fun z => ht z i) (fun z => by rw [dualSpace_dim]; exact hr i z.1)choose B hB using fun z i => proj_exists (hPin f z i) ⊥ disjoint_bot_rightlet D := jointShrink A Bhave hf (z : Place p) (x : Dir p n) (hx : x∈f z) : D z *ᵥ x=x := byhave h1 (i : Bool) : rowShrink p (A i) *ᵥ ((IP p n i)ᵀ *ᵥ x)=(IP p n i)ᵀ *ᵥ x :=hA i z _ ⟨_,hx,rfl⟩have h2 (i : Bool) : B z i *ᵥ ((IH p n i)ᵀ *ᵥ x)=(IH p n i)ᵀ *ᵥ x :=(hB z i).fixes _ ⟨_,hx,rfl⟩unfold D jointShrinksimp only [Matrix.sum_mulVec,Matrix.add_mulVec,liftM_def,← Matrix.mulVec_mulVec,h1,h2]exact ip_decomp xhave hR (z : Place p) : (D z).rank ≤ dqBound p T H R := byapply le_trans (mrk_sum_le ..)have hx i :(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+liftM (IH p n i) (IH p n i) (B z i)).rank ≤ drow p T R+H :=(mrk_add_le ..).trans (add_le_add((rank_lift_le ..).trans (hT i)) ((rank_lift_le ..).trans((rank_maps (hPin f z i) (hB z i).onto).trans (hh z i))))rw [Fintype.sum_bool,dqBound,two_mul]; exact add_le_add (hx _) (hx _)let Q (e : Comp p.g) := pullM (D (e,true)) (D (e,false)) (P e)have hG (i : Bool) (e : Comp p.g) : pullM (rowShrink p (A i)) (rowShrink p (A i)) (M i e)=M i e := pullM_fix _ _ (hL i (e,true)) (hL i (e,false))have hY (i : Bool) (e : Comp p.g) : eachF p Q i e=pullM (rowShrink p (A i)) (rowShrink p (A i)) (eachF p P i e) := bychange pullM _ _ (Q e)=pullM _ _ (pullM _ _ _)let G := IP p n ihave hw {I J K U V W : Type} [Fintype U] [Fintype V] [Fintype W] [Fintype I][Fintype J] [Fintype K] (L : Mat U I) (R : Mat V J)(L' : Mat I K) (R' : Mat J W) (P : Mat U V) :pullM L' R' (pullM L R P) = pullM (L*L') (R*R') P := byunfold pullMrw [liftM_comp,Matrix.transpose_mul,Matrix.transpose_mul]unfold Qrw [hw,hw]have h (b) := joint_ip A B (e,b) irw [show D (e,true)*IP p n i=_ from h true, show D (e,false)*IP p n i=_ from h false]refine ⟨Q,?_,?_,fun e => ?_⟩· refine (pureSpace_mem _).mpr fun e => ?_obtain ⟨h1,h2⟩ := box_kill.mp ((pureSpace_mem _).mp hp e)unfold Q; rw [box_kill,pullM_def]; constructor· intro x hxsimp only [transpose_mul,transpose_transpose,←Matrix.mulVec_mulVec,hf (e,true) x hx,h1 x hx,mulVec_zero]intro x hxrw [← mulVec_mulVec,hf (e,false) x hx]rw [← mulVec_mulVec,h2 x hx,mulVec_zero]· rw [he,obsPair_each]rw [obsPair_each] at hechange combineF p _=combineF p _change combineF p _=combineF p _ at hehave he := (combineF_same ..).mp heapply (combineF_same ..).mprintro i x hxlet y : Profile p n := fun e => liftM (rowShrink p (A i)) (rowShrink p (A i)) (x e)rw [repF_rep,repF_rep]have hv := he i y (shrink_X (A i) x hx)rw [repF_rep,repF_rep] at hvhave hu (F : Individual p n) : (∑ e,mpair (F i e) (y e))=∑ e,mpair (pullM (rowShrink p (A i)) (rowShrink p (A i)) (F i e)) (x e) :=Finset.sum_congr rfl fun e _ => mpair_liftM ..rw [hu,hu] at hvsimp_rw [← hY,hG] at hvexact hvunfold Q; rw [pullM_def]exact ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans(by rw [Matrix.rank_transpose]; exact hR _)end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174import OAI.Combinatorics.HadwigerCounterexample.MixerConditionsnamespace OAI/-! # Binary Evaluation Forms -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrixvariable {p : Shape} {n : ℕ}theorem pullT {I J V U : Type} [Fintype V] [Fintype U](A : Mat V U) (P : Mat U I) (Q : Mat V J) :pullM P Q Aᵀ = (pullM Q P A)ᵀ := byrw [pullM_def,pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc]theorem indexed_linear {c : Vec (MBits p)} {D D' : Draw p n} :indexedSum (drawn (p:=p) (D+D')) c =indexedSum (drawn D) c + indexedSum (drawn D') c := byhave h (i : MBits p) :eitherM i.2 (orderedM (drawn (p:=p) (D+D')) i.1) =eitherM i.2 (orderedM (drawn D) i.1) + eitherM i.2 (orderedM (drawn D') i.1) := byrcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rflunfold indexedSumsimp_rw [h,smul_add,Finset.sum_add_distrib]def obsZ (p : Shape) (n : ℕ) (s t : Label p.b) (c : Vec (MBits p)) :Draw p n →ₗ[F] Mat (Fin n) (Fin n) wheretoFun D := pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (indexedSum (drawn D) c)map_add' _ _ := by rw [indexed_linear,map_add]map_smul' a x := byhave h (i : MBits p) :eitherM i.2 (orderedM (drawn (p:=p) (a•x)) i.1)=a • eitherM i.2 (orderedM (drawn x) i.1) := byrcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rflsimp only [indexedSum,h,map_sum,map_smul,RingHom.id_apply,Finset.smul_sum]exact Finset.sum_congr rfl fun i _ => smul_comm _ _ _theorem obsZ_self (s t : Label p.b) (f : Vec Bool) (m : Mixer p n) :pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (selfSum m f) = 0 := byrw [selfSum,Fintype.sum_bool,map_add,map_smul,map_smul]change _ • pullM _ _ (selfM p n m.mixM) + _ • pullM _ _ (selfM p n m.mixM)ᵀ = 0rw [pullT,pull_self_Z,pull_self_Z]simpprivate theorem two_eval (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t)(x : Bool → Mat (Fin n) (Fin n)) :∃ A : Moment p n, ∀ b, pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)(eitherM b A) = x b := bylet P := blockRay p n s Block.Zlet Q := blockRay p n t Block.Zhave hh : Function.Injective (fromCols P Q).mulVec := joined_block_inj hj hs _obtain ⟨L,hL⟩ := prescribe_between hh hh(fromBlocks (0:Mat (Fin n) (Fin n)) (x true) (x false)ᵀ (0:Mat (Fin n) (Fin n)))rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hLhave hx : pullM P Q L = x true := congrArg Matrix.toBlocks₁₂ hLhave hy : pullM Q P L = (x false)ᵀ := congrArg Matrix.toBlocks₂₁ hLrefine ⟨L,fun b => ?_⟩cases b· change pullM P Q Lᵀ=x falserw [pullT,hy,transpose_transpose]· exact hxtheorem obsZ_surj (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t){c : Vec (MBits p)} (hc : c ≠ 0) : Function.Surjective (obsZ p n s t c) := byclassicalsimp only [ne_eq,funext_iff,Pi.zero_apply,not_forall] at hcobtain ⟨i,hi⟩ := hcintro Mlet y (j : MBits p) := if j=i then M else 0choose A hA using fun j : MOne p => two_eval s t hj hs (fun b => y (j,b))let D : Draw p n := (fun j => A (j,true), fun j => A (j,false), 0)have he (j : MBits p) :pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)(eitherM j.2 (orderedM (drawn D) j.1)) = y j := byrcases j with ⟨⟨j,_|_⟩,x⟩· exact hA _ _· exact hA _ _refine ⟨D,?_⟩simp only [obsZ,indexedSum,map_sum,map_smul,he,LinearMap.coe_mk,AddHom.coe_mk]rw [Finset.sum_eq_single i]· simp [y,(bit_cases (c i)).resolve_left hi]· intro j _ hj; simp [y,hj]simpdef selfPartial (s t : Label p.b) (f : Vec Bool) (D : Draw p n) : Mat (Fin n) (Fin n) :=let A := ∑ a, (s a+t a) • D.2.2 af true • A+f false • Aᵀtheorem pull_selfPart (s t : Label p.b) (hj : 1 ≤ p.j) (f : Vec Bool) (D : Draw p n) :pullM (blockRay p n s Block.sharp) (blockRay p n t Block.sharp) (selfSum (drawn D) f) =selfPartial (p:=p) s t f D := byrw [selfSum, Fintype.sum_bool,map_add,map_smul,map_smul]change _ • pullM _ _ (selfM p n D.2.2) + _ • pullM _ _ (selfM p n D.2.2)ᵀ = _rw [pullT,pull_self_sharp _ _ _ hj,pull_self_sharp _ _ _ hj]unfold selfPartialcongr 2simp only [add_comm]def obsHalf (p : Shape) (s t : Label p.b) (f : Vec Bool) (n : ℕ)(l r : Fin (n/2)→Fin n) : Draw p n →ₗ[F] Mat (Fin (n/2)) (Fin (n/2)) wheretoFun D := (selfPartial (p:=p) s t f D).submatrix l rmap_add' _ _ := bysimp only [selfPartial, Prod.snd_add, Pi.add_apply, smul_add, Finset.sum_add_distrib,transpose_add, Matrix.submatrix_add]abelmap_smul' a D := bysimp only [selfPartial,Prod.smul_snd,Pi.smul_apply,RingHom.id_apply]let F (D : Draw p n) := ∑ i, (s i+t i) • D.2.2 ihave h :∑ i, (s i+t i) • (a • D.2.2 i) = a • F D := byunfold F; rw [Finset.smul_sum]; exact Finset.sum_congr rfl fun _ _ => smul_comm _ _ _rw [h,Matrix.transpose_smul]rw [smul_comm (f true),smul_comm (f false) a, ← smul_add]rfl/-- Uniform off-diagonal block even in transpose-character case. -/theorem obsHalf_surj (s t : Label p.b) (hs : s≠t) {f : Vec Bool} (hf : f≠0) (n : ℕ){l r : Fin (n/2)→Fin n} (hl : Function.Injective l) (hr : Function.Injective r)(h : ∀ i j,l i≠r j) : Function.Surjective (obsHalf p s t f n l r) := byclassicalintro Mobtain ⟨a,ha⟩ : ∃ a,s a+t a=1 := byobtain ⟨a,ha⟩ := Function.ne_iff.mp hsexact ⟨a,(bit_cases _).resolve_left (fun h => ha(add_right_cancel (h.trans (char_two _).symm)))⟩let m := n/2let P := embedMat llet Q := embedMat rhave hi : Function.Injective (fromCols P Q).mulVec := byhave he : fromCols P Q = embedMat (Sum.elim l r) := by ext i j; cases j <;> rflrw [he]; apply embedMat_injrintro (x|x) (y|y) g· rw [hl g]· exact (h _ _ g).elim· exact (h _ _ g.symm).elim· rw [hr g]have hv (x y : Mat (Fin m) (Fin m)) :∃ A : Mat (Fin n) (Fin n), A.submatrix l r=x ∧ Aᵀ.submatrix l r=y := byobtain ⟨A,hA⟩ := prescribe_between hi hi (fromBlocks (0:Mat (Fin m) (Fin m)) x yᵀ(0:Mat (Fin m) (Fin m)))rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hAhave h1 : Pᵀ*A*Q=x := congrArg Matrix.toBlocks₁₂ hAhave h2 : Qᵀ*A*P=yᵀ := congrArg Matrix.toBlocks₂₁ hAunfold P Q at *rw [embedMat_mul,mul_embedMat] at h1 h2exact ⟨A,h1,congrArg Matrix.transpose h2⟩obtain ⟨x,y,hx⟩ : ∃ x y : Mat (Fin m) (Fin m), f true • x+f false • y=M := byrcases bit_cases (f true) with g|g· have hg : f false≠0 := fun hg => hf (funext fun i => by cases i <;> assumption)exact ⟨0,M,by rw [(bit_cases _).resolve_left hg]; simp⟩· exact ⟨M,0,by rw [g]; simp⟩obtain ⟨A,h1,h2⟩ := hv x ylet D : Draw p n := (0,0,Pi.single a A)have hE :∑ i,(s i+t i) • D.2.2 i=A := byrw [Finset.sum_eq_single a]· simp [D,ha]· intro i _ hi; simp [D,Pi.single_eq_of_ne hi]simprefine ⟨D,?_⟩change (selfPartial (p:=p) s t f D).submatrix l r=Munfold selfPartialrw [hE]change (f true • A + f false • Aᵀ).submatrix l r = _change f true • A.submatrix l r + f false • Aᵀ.submatrix l r = Mrw [h1,h2,hx]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174import OAI.Combinatorics.HadwigerCounterexample.MixerConditionsnamespace OAI/-! # Binary Evaluation Forms -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrixvariable {p : Shape} {n : ℕ}theorem pullT {I J V U : Type} [Fintype V] [Fintype U](A : Mat V U) (P : Mat U I) (Q : Mat V J) :pullM P Q Aᵀ = (pullM Q P A)ᵀ := byrw [pullM_def,pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc]theorem indexed_linear {c : Vec (MBits p)} {D D' : Draw p n} :indexedSum (drawn (p:=p) (D+D')) c =indexedSum (drawn D) c + indexedSum (drawn D') c := byhave h (i : MBits p) :eitherM i.2 (orderedM (drawn (p:=p) (D+D')) i.1) =eitherM i.2 (orderedM (drawn D) i.1) + eitherM i.2 (orderedM (drawn D') i.1) := byrcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rflunfold indexedSumsimp_rw [h,smul_add,Finset.sum_add_distrib]def obsZ (p : Shape) (n : ℕ) (s t : Label p.b) (c : Vec (MBits p)) :Draw p n →ₗ[F] Mat (Fin n) (Fin n) wheretoFun D := pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (indexedSum (drawn D) c)map_add' _ _ := by rw [indexed_linear,map_add]map_smul' a x := byhave h (i : MBits p) :eitherM i.2 (orderedM (drawn (p:=p) (a•x)) i.1)=a • eitherM i.2 (orderedM (drawn x) i.1) := byrcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rflsimp only [indexedSum,h,map_sum,map_smul,RingHom.id_apply,Finset.smul_sum]exact Finset.sum_congr rfl fun i _ => smul_comm _ _ _theorem obsZ_self (s t : Label p.b) (f : Vec Bool) (m : Mixer p n) :pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (selfSum m f) = 0 := byrw [selfSum,Fintype.sum_bool,map_add,map_smul,map_smul]change _ • pullM _ _ (selfM p n m.mixM) + _ • pullM _ _ (selfM p n m.mixM)ᵀ = 0rw [pullT,pull_self_Z,pull_self_Z]simpprivate theorem two_eval (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t)(x : Bool → Mat (Fin n) (Fin n)) :∃ A : Moment p n, ∀ b, pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)(eitherM b A) = x b := bylet P := blockRay p n s Block.Zlet Q := blockRay p n t Block.Zhave hh : Function.Injective (fromCols P Q).mulVec := joined_block_inj hj hs _obtain ⟨L,hL⟩ := prescribe_between hh hh(fromBlocks (0:Mat (Fin n) (Fin n)) (x true) (x false)ᵀ (0:Mat (Fin n) (Fin n)))rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hLhave hx : pullM P Q L = x true := congrArg Matrix.toBlocks₁₂ hLhave hy : pullM Q P L = (x false)ᵀ := congrArg Matrix.toBlocks₂₁ hLrefine ⟨L,fun b => ?_⟩cases b· change pullM P Q Lᵀ=x falserw [pullT,hy,transpose_transpose]· exact hxtheorem obsZ_surj (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t){c : Vec (MBits p)} (hc : c ≠ 0) : Function.Surjective (obsZ p n s t c) := byclassicalsimp only [ne_eq,funext_iff,Pi.zero_apply,not_forall] at hcobtain ⟨i,hi⟩ := hcintro Mlet y (j : MBits p) := if j=i then M else 0choose A hA using fun j : MOne p => two_eval s t hj hs (fun b => y (j,b))let D : Draw p n := (fun j => A (j,true), fun j => A (j,false), 0)have he (j : MBits p) :pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)(eitherM j.2 (orderedM (drawn D) j.1)) = y j := byrcases j with ⟨⟨j,_|_⟩,x⟩· exact hA _ _· exact hA _ _refine ⟨D,?_⟩simp only [obsZ,indexedSum,map_sum,map_smul,he,LinearMap.coe_mk,AddHom.coe_mk]rw [Finset.sum_eq_single i]· simp [y,(bit_cases (c i)).resolve_left hi]· intro j _ hj; simp [y,hj]simpdef selfPartial (s t : Label p.b) (f : Vec Bool) (D : Draw p n) : Mat (Fin n) (Fin n) :=let A := ∑ a, (s a+t a) • D.2.2 af true • A+f false • Aᵀtheorem pull_selfPart (s t : Label p.b) (hj : 1 ≤ p.j) (f : Vec Bool) (D : Draw p n) :pullM (blockRay p n s Block.sharp) (blockRay p n t Block.sharp) (selfSum (drawn D) f) =selfPartial (p:=p) s t f D := byrw [selfSum, Fintype.sum_bool,map_add,map_smul,map_smul]change _ • pullM _ _ (selfM p n D.2.2) + _ • pullM _ _ (selfM p n D.2.2)ᵀ = _rw [pullT,pull_self_sharp _ _ _ hj,pull_self_sharp _ _ _ hj]unfold selfPartialcongr 2simp only [add_comm]def obsHalf (p : Shape) (s t : Label p.b) (f : Vec Bool) (n : ℕ)(l r : Fin (n/2)→Fin n) : Draw p n →ₗ[F] Mat (Fin (n/2)) (Fin (n/2)) wheretoFun D := (selfPartial (p:=p) s t f D).submatrix l rmap_add' _ _ := bysimp only [selfPartial, Prod.snd_add, Pi.add_apply, smul_add, Finset.sum_add_distrib,transpose_add, Matrix.submatrix_add]abelmap_smul' a D := bysimp only [selfPartial,Prod.smul_snd,Pi.smul_apply,RingHom.id_apply]let F (D : Draw p n) := ∑ i, (s i+t i) • D.2.2 ihave h :∑ i, (s i+t i) • (a • D.2.2 i) = a • F D := byunfold F; rw [Finset.smul_sum]; exact Finset.sum_congr rfl fun _ _ => smul_comm _ _ _rw [h,Matrix.transpose_smul]rw [smul_comm (f true),smul_comm (f false) a, ← smul_add]rfl/-- Uniform off-diagonal block even in transpose-character case. -/theorem obsHalf_surj (s t : Label p.b) (hs : s≠t) {f : Vec Bool} (hf : f≠0) (n : ℕ){l r : Fin (n/2)→Fin n} (hl : Function.Injective l) (hr : Function.Injective r)(h : ∀ i j,l i≠r j) : Function.Surjective (obsHalf p s t f n l r) := byclassicalintro Mobtain ⟨a,ha⟩ : ∃ a,s a+t a=1 := byobtain ⟨a,ha⟩ := Function.ne_iff.mp hsexact ⟨a,(bit_cases _).resolve_left (fun h => ha(add_right_cancel (h.trans (char_two _).symm)))⟩let m := n/2let P := embedMat llet Q := embedMat rhave hi : Function.Injective (fromCols P Q).mulVec := byhave he : fromCols P Q = embedMat (Sum.elim l r) := by ext i j; cases j <;> rflrw [he]; apply embedMat_injrintro (x|x) (y|y) g· rw [hl g]· exact (h _ _ g).elim· exact (h _ _ g.symm).elim· rw [hr g]have hv (x y : Mat (Fin m) (Fin m)) :∃ A : Mat (Fin n) (Fin n), A.submatrix l r=x ∧ Aᵀ.submatrix l r=y := byobtain ⟨A,hA⟩ := prescribe_between hi hi (fromBlocks (0:Mat (Fin m) (Fin m)) x yᵀ(0:Mat (Fin m) (Fin m)))rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hAhave h1 : Pᵀ*A*Q=x := congrArg Matrix.toBlocks₁₂ hAhave h2 : Qᵀ*A*P=yᵀ := congrArg Matrix.toBlocks₂₁ hAunfold P Q at *rw [embedMat_mul,mul_embedMat] at h1 h2exact ⟨A,h1,congrArg Matrix.transpose h2⟩obtain ⟨x,y,hx⟩ : ∃ x y : Mat (Fin m) (Fin m), f true • x+f false • y=M := byrcases bit_cases (f true) with g|g· have hg : f false≠0 := fun hg => hf (funext fun i => by cases i <;> assumption)exact ⟨0,M,by rw [(bit_cases _).resolve_left hg]; simp⟩· exact ⟨M,0,by rw [g]; simp⟩obtain ⟨A,h1,h2⟩ := hv x ylet D : Draw p n := (0,0,Pi.single a A)have hE :∑ i,(s i+t i) • D.2.2 i=A := byrw [Finset.sum_eq_single a]· simp [D,ha]· intro i _ hi; simp [D,Pi.single_eq_of_ne hi]simprefine ⟨D,?_⟩change (selfPartial (p:=p) s t f D).submatrix l r=Munfold selfPartialrw [hE]change (f true • A + f false • Aᵀ).submatrix l r = _change f true • A.submatrix l r + f false • Aᵀ.submatrix l r = Mrw [h1,h2,hx]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import Mathlib.Algebra.Field.ZModimport Mathlib.LinearAlgebra.Matrix.Rankimport Mathlib.LinearAlgebra.Matrix.Traceimport Mathlib.FieldTheory.Finitenessimport Mathlib.Tactic.Ringnamespace OAI/-! # Binary Matrices -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrixabbrev F := ZMod 2abbrev Vec (I : Type) := I → Fabbrev Mat (I J : Type) := Matrix I J Fabbrev Space (V : Type) [AddCommGroup V] [Module F V] := Submodule F Vtheorem bit_cases (x : F) : x = 0 ∨ x = 1 :=(by decide : ∀ x : ZMod 2, x = 0 ∨ x = 1) xtheorem bit_sq (x : F) : x*x = x := by rcases bit_cases x with e|e <;> rw [e] <;> simptheorem char_two {V : Type*} [AddCommGroup V] [Module F V] (x : V) : x+x=0 :=ZModModule.add_self xtheorem odd_smul_bit {n : ℕ} (hn : Odd n) (x : F) : n • x = x := byobtain ⟨m,rfl⟩ := hnrw [add_smul, one_smul, mul_smul, two_smul,char_two,zero_add]section Linearvariable {I J K L R S : Type} [Fintype I] [Fintype J]def evmat (M : Mat I J) (x : Vec I) (y : Vec J) := dotProduct x (M *ᵥ y)def mpair (M : Mat I J) : Mat I J →ₗ[F] F wheretoFun A := ∑ i, ∑ j, M i j * A i jmap_add' A B := by simp only [Matrix.add_apply,mul_add,Finset.sum_add_distrib]map_smul' b A := bysimp only [Matrix.smul_apply, smul_eq_mul,RingHom.id_apply,Finset.mul_sum,mul_left_comm b]theorem mpair_comm (M A : Mat I J) : mpair M A = mpair A M := bydsimp [mpair]simp only [mul_comm]theorem mpair_outer (M : Mat I J) (x : Vec I) (y : Vec J) :mpair M (vecMulVec x y) = evmat M x y := bydsimp [mpair,evmat,mulVec,dotProduct,vecMulVec]simp only [Finset.mul_sum,mul_left_comm]/-- Apply frame maps to the two factors of every tensor. -/def liftM (P : Mat K I) (Q : Mat L J) : Mat I J →ₗ[F] Mat K L wheretoFun A := P*A*Qᵀmap_add' A B := by rw [Matrix.mul_add,Matrix.add_mul]map_smul' b A := by simp only [Matrix.mul_smul, Matrix.smul_mul,RingHom.id_apply]theorem liftM_def (P : Mat K I) (Q : Mat L J) (A : Mat I J) :liftM P Q A = P*A*Qᵀ := rfltheorem liftM_outer (P : Mat K I) (Q : Mat L J) (x : Vec I) (y : Vec J) :liftM P Q (vecMulVec x y) = vecMulVec (P *ᵥ x) (Q *ᵥ y) := byrw [liftM_def,mul_vecMulVec,vecMulVec_mul,vecMul_transpose]variable [Fintype K] [Fintype L]theorem liftM_comp (P : Mat K I) (Q : Mat L J) (P' : Mat R K) (Q' : Mat S L)(A : Mat I J) :liftM P' Q' (liftM P Q A) = liftM (P'*P) (Q'*Q) A := bysimp only [liftM_def, Matrix.transpose_mul,Matrix.mul_assoc]theorem mpair_liftM (P : Mat K I) (Q : Mat L J) (M : Mat K L) (A : Mat I J) :mpair M (liftM P Q A) = mpair (liftM Pᵀ Qᵀ M) A := bysimp only [liftM_def, mpair, transpose_transpose, LinearMap.coe_mk,AddHom.coe_mk,Matrix.mul_apply, Finset.sum_mul, Finset.mul_sum, transpose_apply]conv_lhs =>arg 2intro krw [Finset.sum_comm]rw [Finset.sum_comm]conv_rhs => rw [Finset.sum_comm]refine Finset.sum_congr rfl fun j _ => ?_conv_lhs =>arg 2intro krw [Finset.sum_comm]rw [Finset.sum_comm]refine Finset.sum_congr rfl fun i _ => ?_rw [Finset.sum_comm]refine Finset.sum_congr rfl fun l _ => Finset.sum_congr rfl fun k _ => ?_ringtheorem mat_left_inv [DecidableEq I] {P : Mat K I} (hp : Function.Injective P.mulVec) :∃ Q : Mat I K, Q*P = 1 := byclassicalhave hp' : Function.Injective (P.mulVecLin) := hpobtain ⟨f,hf⟩ := P.mulVecLin.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hp')refine ⟨LinearMap.toMatrix' f, ?_⟩apply Matrix.toLin'.injectiverw [Matrix.toLin'_mul]simp only [Matrix.toLin'_one]change ((LinearMap.toMatrix').symm _) ∘ₗ _ = _rw [LinearEquiv.symm_apply_apply]exact hftheorem liftM_inj {P : Mat K I} {Q : Mat L J} (hp : Function.Injective P.mulVec)(hq : Function.Injective Q.mulVec) : Function.Injective (liftM P Q) := byclassicalobtain ⟨P', hP⟩ := mat_left_inv hpobtain ⟨Q', hQ⟩ := mat_left_inv hqintro A B habhave hh := congrArg (liftM P' Q') habrw [liftM_comp,liftM_comp,hP,hQ] at hhsimpa only [liftM_def, Matrix.one_mul, Matrix.transpose_one,Matrix.mul_one] using hhend Linearend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import Mathlib.Algebra.Field.ZModimport Mathlib.LinearAlgebra.Matrix.Rankimport Mathlib.LinearAlgebra.Matrix.Traceimport Mathlib.FieldTheory.Finitenessimport Mathlib.Tactic.Ringnamespace OAI/-! # Binary Matrices -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrixabbrev F := ZMod 2abbrev Vec (I : Type) := I → Fabbrev Mat (I J : Type) := Matrix I J Fabbrev Space (V : Type) [AddCommGroup V] [Module F V] := Submodule F Vtheorem bit_cases (x : F) : x = 0 ∨ x = 1 :=(by decide : ∀ x : ZMod 2, x = 0 ∨ x = 1) xtheorem bit_sq (x : F) : x*x = x := by rcases bit_cases x with e|e <;> rw [e] <;> simptheorem char_two {V : Type*} [AddCommGroup V] [Module F V] (x : V) : x+x=0 :=ZModModule.add_self xtheorem odd_smul_bit {n : ℕ} (hn : Odd n) (x : F) : n • x = x := byobtain ⟨m,rfl⟩ := hnrw [add_smul, one_smul, mul_smul, two_smul,char_two,zero_add]section Linearvariable {I J K L R S : Type} [Fintype I] [Fintype J]def evmat (M : Mat I J) (x : Vec I) (y : Vec J) := dotProduct x (M *ᵥ y)def mpair (M : Mat I J) : Mat I J →ₗ[F] F wheretoFun A := ∑ i, ∑ j, M i j * A i jmap_add' A B := by simp only [Matrix.add_apply,mul_add,Finset.sum_add_distrib]map_smul' b A := bysimp only [Matrix.smul_apply, smul_eq_mul,RingHom.id_apply,Finset.mul_sum,mul_left_comm b]theorem mpair_comm (M A : Mat I J) : mpair M A = mpair A M := bydsimp [mpair]simp only [mul_comm]theorem mpair_outer (M : Mat I J) (x : Vec I) (y : Vec J) :mpair M (vecMulVec x y) = evmat M x y := bydsimp [mpair,evmat,mulVec,dotProduct,vecMulVec]simp only [Finset.mul_sum,mul_left_comm]/-- Apply frame maps to the two factors of every tensor. -/def liftM (P : Mat K I) (Q : Mat L J) : Mat I J →ₗ[F] Mat K L wheretoFun A := P*A*Qᵀmap_add' A B := by rw [Matrix.mul_add,Matrix.add_mul]map_smul' b A := by simp only [Matrix.mul_smul, Matrix.smul_mul,RingHom.id_apply]theorem liftM_def (P : Mat K I) (Q : Mat L J) (A : Mat I J) :liftM P Q A = P*A*Qᵀ := rfltheorem liftM_outer (P : Mat K I) (Q : Mat L J) (x : Vec I) (y : Vec J) :liftM P Q (vecMulVec x y) = vecMulVec (P *ᵥ x) (Q *ᵥ y) := byrw [liftM_def,mul_vecMulVec,vecMulVec_mul,vecMul_transpose]variable [Fintype K] [Fintype L]theorem liftM_comp (P : Mat K I) (Q : Mat L J) (P' : Mat R K) (Q' : Mat S L)(A : Mat I J) :liftM P' Q' (liftM P Q A) = liftM (P'*P) (Q'*Q) A := bysimp only [liftM_def, Matrix.transpose_mul,Matrix.mul_assoc]theorem mpair_liftM (P : Mat K I) (Q : Mat L J) (M : Mat K L) (A : Mat I J) :mpair M (liftM P Q A) = mpair (liftM Pᵀ Qᵀ M) A := bysimp only [liftM_def, mpair, transpose_transpose, LinearMap.coe_mk,AddHom.coe_mk,Matrix.mul_apply, Finset.sum_mul, Finset.mul_sum, transpose_apply]conv_lhs =>arg 2intro krw [Finset.sum_comm]rw [Finset.sum_comm]conv_rhs => rw [Finset.sum_comm]refine Finset.sum_congr rfl fun j _ => ?_conv_lhs =>arg 2intro krw [Finset.sum_comm]rw [Finset.sum_comm]refine Finset.sum_congr rfl fun i _ => ?_rw [Finset.sum_comm]refine Finset.sum_congr rfl fun l _ => Finset.sum_congr rfl fun k _ => ?_ringtheorem mat_left_inv [DecidableEq I] {P : Mat K I} (hp : Function.Injective P.mulVec) :∃ Q : Mat I K, Q*P = 1 := byclassicalhave hp' : Function.Injective (P.mulVecLin) := hpobtain ⟨f,hf⟩ := P.mulVecLin.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hp')refine ⟨LinearMap.toMatrix' f, ?_⟩apply Matrix.toLin'.injectiverw [Matrix.toLin'_mul]simp only [Matrix.toLin'_one]change ((LinearMap.toMatrix').symm _) ∘ₗ _ = _rw [LinearEquiv.symm_apply_apply]exact hftheorem liftM_inj {P : Mat K I} {Q : Mat L J} (hp : Function.Injective P.mulVec)(hq : Function.Injective Q.mulVec) : Function.Injective (liftM P Q) := byclassicalobtain ⟨P', hP⟩ := mat_left_inv hpobtain ⟨Q', hQ⟩ := mat_left_inv hqintro A B habhave hh := congrArg (liftM P' Q') habrw [liftM_comp,liftM_comp,hP,hQ] at hhsimpa only [liftM_def, Matrix.one_mul, Matrix.transpose_one,Matrix.mul_one] using hhend Linearend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import OAI.Combinatorics.HadwigerCounterexample.KeyTestCorrespondencenamespace OAI/-! # Binary Mixing Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Filter Matrix Functionopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]namespace Templatevariable (v : Template p I)def kappa := wavelength v.Abbeyomit [DecidableEq I] intheorem kappa_pos : 0<v.kappa := wavelength_pos _def diffsel (v : Template p I) := ∀ i j, i≠j → v.aim i=v.aim j → v.s i≠ v.s jomit [DecidableEq I] intheorem choral_live (v : Template p I) (m : Mixer p n) (hm : binaryGood m)(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)(i : v.Chorus) (c : Vec (v.Abbey i)) (hc : c≠0) :let j := v.choral.first i; let l := v.choral.nextP i∃ B, (v.f j).keeps (v.t j) B ∧ (v.f l).keeps (v.t l) B ∧n≤5*blockRank B (v.s j) (v.s l) (v.chorusM m x i c) := byclassicalrcases i with i|i· intro j llet a : Vec (MBits p) := fun y => c (.inl y)let b : Vec Bool := fun y => c (.inr y)have hh : v.s j≠v.s l := hv j l (v.choral.diff (.inl i)) i.property.1by_cases h : a=0· refine ⟨Block.sharp,Flavor.keepSharp ..,Flavor.keepSharp ..,?_⟩have he : indexedSum m a=0 := by simp [h,indexedSum]rw [chorus_same]change n ≤ 5*blockRank _ _ _ (indexedSum m a+selfSum m b)rw [he,zero_add]have hz : b≠0 := byintro hb; apply hc; funext ycases ynext l => exact congr_fun h lnext l => exact congr_fun hb lexact (hm _ _ hh).2 b hzrefine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩rw [chorus_same]; exact (hm _ _ hh).1 a b hintro j l; refine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩obtain ⟨w,hw,hh⟩ := chorus_cross v m x i c hcrw [hh]; exact hx _ _ w hwtheorem resonant (v : Template p I) (m : Mixer p n) (hm : binaryGood m)(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)(w : I → Wgt (Knobs p.g n)) (hw : ∀ i,IsLaw (w i))(C : ℝ) (hC : 0 < C) (hc : ∀ i j,w i j ≤ C*unif j)(s : Script p I) :∀ u : I → Wgt (Knobs p.g n),(∀ i x, |u i x|≤1) →|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -v.kappa * ∏ i:I,avg (w i) (u i)|≤ C^2*bp (-(n:ℝ)/10) := byclassicalrefine hear_band v.choral (v.chime m x) (v.lyrics s) w hw _(mul_nonneg (sq_nonneg _) (bp_pos _).le) ?_intro i c hc' p q hp hqobtain ⟨b,hb,hb',hz⟩ := v.choral_live m hm x hx hv i c hc'simp_rw [vectorPhase,v.chime_seq]exact spark_condition _ (v.chorusM m x i c) _ _ _ _ _ _ b hb hb' p q hp hq_ _ (hw _) (hw _) C hC (hc _) (hc _) hztheorem resonance_calendar (v : Template p I) (M : ℕ) (hM : 4≤ M) (C L : ℝ) (hL : 0<L) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ m : Mixer p n, binaryGood m →v.diffsel → 2*num (Full p n)<N → ∀ ρ : Wgt (UnitType p n N),(∀ i,ρ i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →pr ρ (fun i=>¬litFire p i) ≤ bp (-(n:ℝ)*n/8) ∧∀ x : UnitType p n N,litFire p x →∀ w : I → Wgt (Knobs p.g n),(∀ i,IsLaw (w i)) →(∀ i j,w i j≤ L*unif j) →∀ (s : Script p I) (u : I→ Wgt (Knobs p.g n)),(∀ i j,|u i j|≤1) →|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -v.kappa*∏ i:I,avg (w i) (u i)| ≤ bp (-(1/20:ℝ)*n) := byfilter_upwards [litFire_calendar p C M hM,pay_nat (a:=1/10) (b:=1/20) (L^2) (by norm_num)]with n hn ha N m hm hv hN ρ hρrefine ⟨hn m hN ρ hρ,fun x hx w hw hh s u hu => ?_⟩exact (resonant v m hm x hx hv w hw L hL hh s u hu).trans(by rw [show -(↑n:ℝ)/10 = -(1/10:ℝ)*n by ring]; exact ha)end Templatetheorem scanCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : Digest p.g)(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : z.feasible l f) :∀ x,scopedScan p n l f z x≤(scanPrice p)⁻¹*unif x := byintro xrefine (on_mon (spins_law p n).nz (scanPrice_pos p) (scan_fraction l f z hr hn h)x).trans_eq ?_rw [spins,← draws_unif]theorem dialCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : F)(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : canDial p l f z) :∀ x,scopedBit p n l f z x≤(scanPrice p)⁻¹*unif x := byintro xrefine (on_mon (spins_law p n).nz (scanPrice_pos p) (dial_fraction p n _ _ _ hr hn h)x).trans_eq ?_rw [spins,← draws_unif]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import OAI.Combinatorics.HadwigerCounterexample.KeyTestCorrespondencenamespace OAI/-! # Binary Mixing Bounds -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Filter Matrix Functionopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]namespace Templatevariable (v : Template p I)def kappa := wavelength v.Abbeyomit [DecidableEq I] intheorem kappa_pos : 0<v.kappa := wavelength_pos _def diffsel (v : Template p I) := ∀ i j, i≠j → v.aim i=v.aim j → v.s i≠ v.s jomit [DecidableEq I] intheorem choral_live (v : Template p I) (m : Mixer p n) (hm : binaryGood m)(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)(i : v.Chorus) (c : Vec (v.Abbey i)) (hc : c≠0) :let j := v.choral.first i; let l := v.choral.nextP i∃ B, (v.f j).keeps (v.t j) B ∧ (v.f l).keeps (v.t l) B ∧n≤5*blockRank B (v.s j) (v.s l) (v.chorusM m x i c) := byclassicalrcases i with i|i· intro j llet a : Vec (MBits p) := fun y => c (.inl y)let b : Vec Bool := fun y => c (.inr y)have hh : v.s j≠v.s l := hv j l (v.choral.diff (.inl i)) i.property.1by_cases h : a=0· refine ⟨Block.sharp,Flavor.keepSharp ..,Flavor.keepSharp ..,?_⟩have he : indexedSum m a=0 := by simp [h,indexedSum]rw [chorus_same]change n ≤ 5*blockRank _ _ _ (indexedSum m a+selfSum m b)rw [he,zero_add]have hz : b≠0 := byintro hb; apply hc; funext ycases ynext l => exact congr_fun h lnext l => exact congr_fun hb lexact (hm _ _ hh).2 b hzrefine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩rw [chorus_same]; exact (hm _ _ hh).1 a b hintro j l; refine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩obtain ⟨w,hw,hh⟩ := chorus_cross v m x i c hcrw [hh]; exact hx _ _ w hwtheorem resonant (v : Template p I) (m : Mixer p n) (hm : binaryGood m)(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)(w : I → Wgt (Knobs p.g n)) (hw : ∀ i,IsLaw (w i))(C : ℝ) (hC : 0 < C) (hc : ∀ i j,w i j ≤ C*unif j)(s : Script p I) :∀ u : I → Wgt (Knobs p.g n),(∀ i x, |u i x|≤1) →|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -v.kappa * ∏ i:I,avg (w i) (u i)|≤ C^2*bp (-(n:ℝ)/10) := byclassicalrefine hear_band v.choral (v.chime m x) (v.lyrics s) w hw _(mul_nonneg (sq_nonneg _) (bp_pos _).le) ?_intro i c hc' p q hp hqobtain ⟨b,hb,hb',hz⟩ := v.choral_live m hm x hx hv i c hc'simp_rw [vectorPhase,v.chime_seq]exact spark_condition _ (v.chorusM m x i c) _ _ _ _ _ _ b hb hb' p q hp hq_ _ (hw _) (hw _) C hC (hc _) (hc _) hztheorem resonance_calendar (v : Template p I) (M : ℕ) (hM : 4≤ M) (C L : ℝ) (hL : 0<L) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ m : Mixer p n, binaryGood m →v.diffsel → 2*num (Full p n)<N → ∀ ρ : Wgt (UnitType p n N),(∀ i,ρ i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →pr ρ (fun i=>¬litFire p i) ≤ bp (-(n:ℝ)*n/8) ∧∀ x : UnitType p n N,litFire p x →∀ w : I → Wgt (Knobs p.g n),(∀ i,IsLaw (w i)) →(∀ i j,w i j≤ L*unif j) →∀ (s : Script p I) (u : I→ Wgt (Knobs p.g n)),(∀ i j,|u i j|≤1) →|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -v.kappa*∏ i:I,avg (w i) (u i)| ≤ bp (-(1/20:ℝ)*n) := byfilter_upwards [litFire_calendar p C M hM,pay_nat (a:=1/10) (b:=1/20) (L^2) (by norm_num)]with n hn ha N m hm hv hN ρ hρrefine ⟨hn m hN ρ hρ,fun x hx w hw hh s u hu => ?_⟩exact (resonant v m hm x hx hv w hw L hL hh s u hu).trans(by rw [show -(↑n:ℝ)/10 = -(1/10:ℝ)*n by ring]; exact ha)end Templatetheorem scanCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : Digest p.g)(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : z.feasible l f) :∀ x,scopedScan p n l f z x≤(scanPrice p)⁻¹*unif x := byintro xrefine (on_mon (spins_law p n).nz (scanPrice_pos p) (scan_fraction l f z hr hn h)x).trans_eq ?_rw [spins,← draws_unif]theorem dialCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : F)(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : canDial p l f z) :∀ x,scopedBit p n l f z x≤(scanPrice p)⁻¹*unif x := byintro xrefine (on_mon (spins_law p n).nz (scanPrice_pos p) (dial_fraction p n _ _ _ hr hn h)x).trans_eq ?_rw [spins,← draws_unif]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265import OAI.Combinatorics.HadwigerCounterexample.RealizationConditionsimport OAI.Combinatorics.HadwigerCounterexample.MixerConditionsnamespace OAI/-! # Binary Prescriptions -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Finsetvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]/-- list for a cross edge -/def aiming (a b : I → Bool) (i j : Bool) :=Finset.univ.filter (fun x => a x=i ∧ b x=j)/-- within-endpoint L/R bit tests. Read only a x=a y, x≠y.(tests between ordered points; no double counting since L,R andboth orientations are in the mixer hypothesis). -/abbrev Script (p : Shape) (I : Type) := I → I → Vec (MOne p)namespace Volleyvariable (v : Volley p n I)def reads (s : Script p I) (m : Mixer p n) :=∀ x y : I,x≠y → v.obj x=v.obj y →∀ i : MOne p, s x y i = evmat (orderedM m i) (v.rayAt x) (v.rayAt y)end Volleydef prescribedB (p : Shape) (t : Tagging p I) (s : Script p I) (x y : I) :=∑ i : Fin p.J,∑ e : Comp p.g, ∑ f : Comp p.g, if inc e (t x) ∧ inc f (t y) thens x y ((i,e,f),true)*s x y ((i,e,f),false) else 0noncomputable def prescribedT (p : Shape) (t : Tagging p I) (d : Vec I)(h : Mat I I) (s : Script p I) (x y : I) : F :=@ite _ (x=y) (Classical.propDecidable _) (d x)(h x y+(prescribedB p t s x y+prescribedB p t s y x))def fulfills (p : Shape) (t : Tagging p I) (d f : Vec I) (u : Mat I I)(s : Script p I) (a b : I → Bool) :=∀ (x : I) (j : Bool),d x+ (∑ i∈aiming a b (a x) j, prescribedT p t d u s i x) =if j=b x then 0 else f xnamespace Volleyvariable {v : Volley p n I}omit [Fintype I] inprivate theorem B1_eval {s : Script p I} (t : Tagging p I) (m : Mixer p n)(ha : v.reads s m) {x y : I} (hg : x ≠ y) (hh : v.obj x=v.obj y) :B1 m (v.atomAt t x) (v.atomAt t y)=prescribedB p t s x y := byclassicalchange ∑ i : Fin p.J, _ = _refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun e _ =>Finset.sum_congr rfl fun f _ => ?_by_cases he : inc e (t x)· by_cases hf : inc f (t y)· rw [ite_eq_left ⟨he,hf⟩,ha x y hg hh,ha x y hg hh]simp only [atomAt,atom_def,he,hf,ite_true,mom,liftM_outer,pair_outers]rflrw [ite_eq_right (show ¬ (_ ∧ _) from fun h => hf h.2)]simp only [atomAt,atom_def,hf,ite_false,map_zero]rw [ite_eq_right (show ¬ (_ ∧ _) from fun h => he h.1)]simp only [atomAt,atom_def,he,ite_false]rw [mpair_comm,map_zero]theorem grads_by_script (t : Tagging p I) (m : Mixer p n) (w : Volley p n I)(y : UnitType p n N) {d f : Vec I} {u : Mat I I} {s : Script p I}(h : fulfills p t d f u s v.obj w.obj) (hs : v.reads s m)(hd : ∀ x,role p n (v.atomAt t x)=d x)(hf : ∀ x,innerP p y (w.obj x) (w.atomAt t x)=f x)(hu : ∀ x y : I,T0 p n (v.atomAt t x) (v.atomAt t y)=u x y) :v.attackGrad w t m y := byclassicalintro x jrw [grad_val,hd,hf,sumAt,map_sum,LinearMap.sum_apply]rw [← h x j]; congr 1refine Finset.sum_congr rfl fun i hi => ?_unfold prescribedTsplit· rename_i hesubst xrw [T_diag,hd]rename_i hehave hx := (Finset.mem_filter.mp hi).2.1rw [Tsym_val,hu, B1_eval t m hs he hx,B1_eval t m hs (Ne.symm he) hx.symm]end Volley/-- Solve symmetric row sums at one endpoint. Couple via oppositesame-target pmiss/role sum equality. Only the resulting necessary(common d+f sum) is used as input here. -/private theorem binary_plan (a b : I→Bool) (i : Bool) (d f : Vec I)(h : (∑ j∈aiming a b i true,(d j+f j))=∑ j∈aiming a b i false,(d j+f j))(h' : ∀ j,(aiming a b i j).Nonempty) :∃ M : Mat I I, Mᵀ=M ∧ (∀ x,M x x=d x) ∧ ∀ j : Bool,∀ x∈Finset.univ.filter (fun l => a l=i),(∑ l∈aiming a b i j,M l x) = d x+(if j=b x then 0 else f x) := byclassicallet S := aiming a b ilet X : Mat I Bool := Matrix.of (fun i j => if i∈S j then 1 else 0)let V : Mat I Bool := Matrix.of (fun x j => d x + (if j=b x then 0 else f x))let D := Matrix.diagonal dlet Y := V+D*Xobtain ⟨L,hL⟩ := mat_left_inv (P:=X) (byintro x y hefunext jobtain ⟨v,hv⟩ := h' jhave ha := (Finset.mem_filter.mp hv).2have heq (x) : (X *ᵥ x) v=x j := byunfold X Matrix.mulVec dotProductrw [Finset.sum_eq_single j]· simp [hv,S]· intro k _ hk; simp [S,aiming,ha,hk.symm]simprw [← heq x,← heq y,he])let B := Xᵀ*Yhave hg (j k : Bool) : B j k=if j=k then 0 else (∑ l∈S j,(d l+f l)) := byhave hi {l : I} (hh : l∈S j) : a l=i ∧ b l=j := (Finset.mem_filter.mp hh).2have hy {l : I} (hL : l∈S j) :Y l k= (if j=k then 0 else d l+f l) := byunfold Y V X; rw [Matrix.add_apply,Matrix.of_apply,Matrix.diagonal_mul,Matrix.of_apply]by_cases h : j=k· subst ksimp only [(hi hL).2,hL,ite_true,add_zero,mul_one,char_two]have hv : l∉S k := fun hw => h ((hi hL).2.symm.trans (Finset.mem_filter.mp hw).2.2)simp [h,Ne.symm h,(hi hL).2,hv]have ht (l : I) : X l j*Y l k= if l∈S j then Y l k else 0 := byby_cases hv : l∈S j <;> simp [X,hv]unfold B; rw [Matrix.mul_apply]simp_rw [Matrix.transpose_apply,ht,← Finset.sum_filter]rw [show Finset.univ.filter (fun x => x∈S j)=S j from (by simp)]by_cases g : j=k· rw [ite_eq_left g]exact Finset.sum_eq_zero fun l hl => (hy hl).trans (ite_eq_left g)rw [ite_eq_right g]exact Finset.sum_congr rfl fun l hl => (hy hl).trans (ite_eq_right g)have ha (j : Bool) : B j j=0 := by rw [hg,ite_eq_left rfl]have hB : Bᵀ=B := byext j krw [Matrix.transpose_apply,hg,hg]cases j <;> cases kall_goals simp· exact hexact h.symmlet W := Lᵀ*B*Lhave hW : Wᵀ=W := by unfold W; simp only [transpose_mul,transpose_transpose,hB,Matrix.mul_assoc]have hw (x : I) : W x x=0 := byunfold Whave hf : B false true=B true false := congr_fun (congr_fun hB true) falsesimp only [Matrix.mul_apply,Fintype.sum_bool,Matrix.transpose_apply,ha,mul_zero,zero_add,add_zero,hf]rw [mul_right_comm (L false x), show L true x * B true false * L false x=L false x * L true x * B true false from (by ring),char_two]let Z := Y*L+(Y*L)ᵀ + Whave he : (D+Z)*X=V := byhave he : (Y*L)ᵀ*X=W*X := byunfold Whave hh : Yᵀ * X=B := byhave ht : Bᵀ=Yᵀ*X := by unfold B; rw [Matrix.transpose_mul,transpose_transpose]rw [← ht,hB]rw [Matrix.transpose_mul,Matrix.mul_assoc Lᵀ Yᵀ X,hh,Matrix.mul_assoc _ L X,hL,Matrix.mul_one]unfold Zrw [Matrix.add_mul,Matrix.add_mul,Matrix.add_mul,Matrix.mul_assoc Y L X,hL,Matrix.mul_one,he,add_assoc Y,char_two,add_zero]unfold Yrw [add_left_comm,char_two,add_zero]refine ⟨D+Z,?_,?_,fun j x hx => ?_⟩· unfold Z Dsimp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]ac_rfl· intro xunfold D Zsimp only [Matrix.add_apply,Matrix.diagonal_apply_eq,Matrix.transpose_apply,hw,char_two,add_zero]let Q := D+Zhave hq : Qᵀ=Q := byunfold Q Z Dsimp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]ac_rflhave h1 : (Q * X) x j= _ := congr_fun (congr_fun he x) jrw [Matrix.mul_apply] at h1have hy : ∑ l∈S j, Q l x =∑ l, Q x l * X l j := byconv_rhs => unfold Xsimp only [Matrix.of_apply,mul_ite,mul_one,mul_zero, ←Finset.sum_filter]rw [show Finset.univ.filter (fun x => x∈ S j)=S j from (by simp)]exact Finset.sum_congr rfl fun l _ => congr_fun (congr_fun hq x) lexact hy.trans h1omit [Fintype I] inprivate theorem scripted (p : Shape) (t : Tagging p I) (g : I→I→F)(h : 2≤p.g) (hJ : 1 ≤ p.J) :∃ s : Script p I,∀ x y,prescribedB p t s x y=g x y := byclassicalhave hh (x : I) : ∃ i : Comp p.g,inc i (t x) := byhave he := card_star (t x)have hi : Nonempty (TagStar (t x)) := Fintype.card_pos_iff.mp (by omega)obtain ⟨⟨i,h⟩⟩ := hiexact ⟨i,h⟩choose q hq using hhlet i0 : Fin p.J := ⟨0,hJ⟩let s : Script p I := fun x y i =>if i.1=(i0,q x,q y) then if i.2 then g x y else 1 else 0refine ⟨s,fun x y => ?_⟩unfold prescribedBrw [Finset.sum_eq_single i0]· rw [Finset.sum_eq_single (q x)]· rw [Finset.sum_eq_single (q y)]· simp [s,hq]· intro i _ hi; simp [s,hi]simp· intro i _ hi; simp [s,hi]simp· intro i _ hi; simp [s,hi]simpset_option maxHeartbeats 600000 intheorem choose_script (p : Shape) (t : Tagging p I) (a b : I→Bool)(d : Vec I)(f : Vec I)(d' : Vec I)(h : ∀ i : Bool,(∑ x∈aiming a b i true,(d' x+f x)) =∑ x∈aiming a b i false,(d' x+f x))(ha : ∀ i j : Bool, ∑ x∈aiming a b i j,(d x+d' x)=1)(hc : ∀ i j : Bool,(aiming a b i j).Nonempty)(u : Mat I I) (hu : uᵀ=u)(hg : 2≤p.g) (hi : 1≤p.J) :∃ s : Script p I, fulfills p t d f u s a b := byclassicalhave hh (i j : Bool) :(∑ x∈aiming a b i j,(d x+f x))=1+ ∑ x∈aiming a b i j,(d' x+f x) := byrw [←ha,← Finset.sum_add_distrib]refine Finset.sum_congr rfl fun x _ => ?_rw [add_assoc,←add_assoc (d' x),char_two,zero_add]choose M hM hD hA using fun i : Bool => binary_plan a b i d f (by rw [hh,hh,h]) (hc i)let F' := Fintype.equivFin Ilet g (x y : I) := if F' x < F' y then M (a x) x y+u x y else 0obtain ⟨s,hs⟩ := scripted p t g hg hihave hf (x y : I) (h : a x=a y) : prescribedT p t d u s x y=M (a x) x y := byunfold prescribedTsplit· rename_i hesubst yexact (hD _ _).symmrename_i herw [hs x y, hs y x]rcases lt_or_gt_of_ne (show F' x ≠ F' y from fun h => he (F'.injective h)) with e|e· simp only [g, ite_eq_left e,ite_eq_right (not_lt.mpr e.le),add_zero]rw [add_left_comm,char_two,add_zero]simp only [g,ite_eq_left e,ite_eq_right (not_lt.mpr e.le),zero_add]rw [←h,show u y x=u x y from congr_fun (congr_fun hu x) y,show M (a x) y x=M (a x) x y from congr_fun (congr_fun (hM (a x)) x) y]rw [add_left_comm,char_two,add_zero]refine ⟨s,fun x j => ?_⟩let S := aiming a b (a x) jhave he : ∑ i∈S,prescribedT p t d u s i x=∑ i∈S,M (a x) i x :=Finset.sum_congr rfl fun i hi => byhave hm : a i=a x := (Finset.mem_filter.mp hi).2.1rw [hf i x hm,hm]rw [he,hA (a x) j x (by simp), ← add_assoc, char_two,zero_add]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265import OAI.Combinatorics.HadwigerCounterexample.RealizationConditionsimport OAI.Combinatorics.HadwigerCounterexample.MixerConditionsnamespace OAI/-! # Binary Prescriptions -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Finsetvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]/-- list for a cross edge -/def aiming (a b : I → Bool) (i j : Bool) :=Finset.univ.filter (fun x => a x=i ∧ b x=j)/-- within-endpoint L/R bit tests. Read only a x=a y, x≠y.(tests between ordered points; no double counting since L,R andboth orientations are in the mixer hypothesis). -/abbrev Script (p : Shape) (I : Type) := I → I → Vec (MOne p)namespace Volleyvariable (v : Volley p n I)def reads (s : Script p I) (m : Mixer p n) :=∀ x y : I,x≠y → v.obj x=v.obj y →∀ i : MOne p, s x y i = evmat (orderedM m i) (v.rayAt x) (v.rayAt y)end Volleydef prescribedB (p : Shape) (t : Tagging p I) (s : Script p I) (x y : I) :=∑ i : Fin p.J,∑ e : Comp p.g, ∑ f : Comp p.g, if inc e (t x) ∧ inc f (t y) thens x y ((i,e,f),true)*s x y ((i,e,f),false) else 0noncomputable def prescribedT (p : Shape) (t : Tagging p I) (d : Vec I)(h : Mat I I) (s : Script p I) (x y : I) : F :=@ite _ (x=y) (Classical.propDecidable _) (d x)(h x y+(prescribedB p t s x y+prescribedB p t s y x))def fulfills (p : Shape) (t : Tagging p I) (d f : Vec I) (u : Mat I I)(s : Script p I) (a b : I → Bool) :=∀ (x : I) (j : Bool),d x+ (∑ i∈aiming a b (a x) j, prescribedT p t d u s i x) =if j=b x then 0 else f xnamespace Volleyvariable {v : Volley p n I}omit [Fintype I] inprivate theorem B1_eval {s : Script p I} (t : Tagging p I) (m : Mixer p n)(ha : v.reads s m) {x y : I} (hg : x ≠ y) (hh : v.obj x=v.obj y) :B1 m (v.atomAt t x) (v.atomAt t y)=prescribedB p t s x y := byclassicalchange ∑ i : Fin p.J, _ = _refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun e _ =>Finset.sum_congr rfl fun f _ => ?_by_cases he : inc e (t x)· by_cases hf : inc f (t y)· rw [ite_eq_left ⟨he,hf⟩,ha x y hg hh,ha x y hg hh]simp only [atomAt,atom_def,he,hf,ite_true,mom,liftM_outer,pair_outers]rflrw [ite_eq_right (show ¬ (_ ∧ _) from fun h => hf h.2)]simp only [atomAt,atom_def,hf,ite_false,map_zero]rw [ite_eq_right (show ¬ (_ ∧ _) from fun h => he h.1)]simp only [atomAt,atom_def,he,ite_false]rw [mpair_comm,map_zero]theorem grads_by_script (t : Tagging p I) (m : Mixer p n) (w : Volley p n I)(y : UnitType p n N) {d f : Vec I} {u : Mat I I} {s : Script p I}(h : fulfills p t d f u s v.obj w.obj) (hs : v.reads s m)(hd : ∀ x,role p n (v.atomAt t x)=d x)(hf : ∀ x,innerP p y (w.obj x) (w.atomAt t x)=f x)(hu : ∀ x y : I,T0 p n (v.atomAt t x) (v.atomAt t y)=u x y) :v.attackGrad w t m y := byclassicalintro x jrw [grad_val,hd,hf,sumAt,map_sum,LinearMap.sum_apply]rw [← h x j]; congr 1refine Finset.sum_congr rfl fun i hi => ?_unfold prescribedTsplit· rename_i hesubst xrw [T_diag,hd]rename_i hehave hx := (Finset.mem_filter.mp hi).2.1rw [Tsym_val,hu, B1_eval t m hs he hx,B1_eval t m hs (Ne.symm he) hx.symm]end Volley/-- Solve symmetric row sums at one endpoint. Couple via oppositesame-target pmiss/role sum equality. Only the resulting necessary(common d+f sum) is used as input here. -/private theorem binary_plan (a b : I→Bool) (i : Bool) (d f : Vec I)(h : (∑ j∈aiming a b i true,(d j+f j))=∑ j∈aiming a b i false,(d j+f j))(h' : ∀ j,(aiming a b i j).Nonempty) :∃ M : Mat I I, Mᵀ=M ∧ (∀ x,M x x=d x) ∧ ∀ j : Bool,∀ x∈Finset.univ.filter (fun l => a l=i),(∑ l∈aiming a b i j,M l x) = d x+(if j=b x then 0 else f x) := byclassicallet S := aiming a b ilet X : Mat I Bool := Matrix.of (fun i j => if i∈S j then 1 else 0)let V : Mat I Bool := Matrix.of (fun x j => d x + (if j=b x then 0 else f x))let D := Matrix.diagonal dlet Y := V+D*Xobtain ⟨L,hL⟩ := mat_left_inv (P:=X) (byintro x y hefunext jobtain ⟨v,hv⟩ := h' jhave ha := (Finset.mem_filter.mp hv).2have heq (x) : (X *ᵥ x) v=x j := byunfold X Matrix.mulVec dotProductrw [Finset.sum_eq_single j]· simp [hv,S]· intro k _ hk; simp [S,aiming,ha,hk.symm]simprw [← heq x,← heq y,he])let B := Xᵀ*Yhave hg (j k : Bool) : B j k=if j=k then 0 else (∑ l∈S j,(d l+f l)) := byhave hi {l : I} (hh : l∈S j) : a l=i ∧ b l=j := (Finset.mem_filter.mp hh).2have hy {l : I} (hL : l∈S j) :Y l k= (if j=k then 0 else d l+f l) := byunfold Y V X; rw [Matrix.add_apply,Matrix.of_apply,Matrix.diagonal_mul,Matrix.of_apply]by_cases h : j=k· subst ksimp only [(hi hL).2,hL,ite_true,add_zero,mul_one,char_two]have hv : l∉S k := fun hw => h ((hi hL).2.symm.trans (Finset.mem_filter.mp hw).2.2)simp [h,Ne.symm h,(hi hL).2,hv]have ht (l : I) : X l j*Y l k= if l∈S j then Y l k else 0 := byby_cases hv : l∈S j <;> simp [X,hv]unfold B; rw [Matrix.mul_apply]simp_rw [Matrix.transpose_apply,ht,← Finset.sum_filter]rw [show Finset.univ.filter (fun x => x∈S j)=S j from (by simp)]by_cases g : j=k· rw [ite_eq_left g]exact Finset.sum_eq_zero fun l hl => (hy hl).trans (ite_eq_left g)rw [ite_eq_right g]exact Finset.sum_congr rfl fun l hl => (hy hl).trans (ite_eq_right g)have ha (j : Bool) : B j j=0 := by rw [hg,ite_eq_left rfl]have hB : Bᵀ=B := byext j krw [Matrix.transpose_apply,hg,hg]cases j <;> cases kall_goals simp· exact hexact h.symmlet W := Lᵀ*B*Lhave hW : Wᵀ=W := by unfold W; simp only [transpose_mul,transpose_transpose,hB,Matrix.mul_assoc]have hw (x : I) : W x x=0 := byunfold Whave hf : B false true=B true false := congr_fun (congr_fun hB true) falsesimp only [Matrix.mul_apply,Fintype.sum_bool,Matrix.transpose_apply,ha,mul_zero,zero_add,add_zero,hf]rw [mul_right_comm (L false x), show L true x * B true false * L false x=L false x * L true x * B true false from (by ring),char_two]let Z := Y*L+(Y*L)ᵀ + Whave he : (D+Z)*X=V := byhave he : (Y*L)ᵀ*X=W*X := byunfold Whave hh : Yᵀ * X=B := byhave ht : Bᵀ=Yᵀ*X := by unfold B; rw [Matrix.transpose_mul,transpose_transpose]rw [← ht,hB]rw [Matrix.transpose_mul,Matrix.mul_assoc Lᵀ Yᵀ X,hh,Matrix.mul_assoc _ L X,hL,Matrix.mul_one]unfold Zrw [Matrix.add_mul,Matrix.add_mul,Matrix.add_mul,Matrix.mul_assoc Y L X,hL,Matrix.mul_one,he,add_assoc Y,char_two,add_zero]unfold Yrw [add_left_comm,char_two,add_zero]refine ⟨D+Z,?_,?_,fun j x hx => ?_⟩· unfold Z Dsimp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]ac_rfl· intro xunfold D Zsimp only [Matrix.add_apply,Matrix.diagonal_apply_eq,Matrix.transpose_apply,hw,char_two,add_zero]let Q := D+Zhave hq : Qᵀ=Q := byunfold Q Z Dsimp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]ac_rflhave h1 : (Q * X) x j= _ := congr_fun (congr_fun he x) jrw [Matrix.mul_apply] at h1have hy : ∑ l∈S j, Q l x =∑ l, Q x l * X l j := byconv_rhs => unfold Xsimp only [Matrix.of_apply,mul_ite,mul_one,mul_zero, ←Finset.sum_filter]rw [show Finset.univ.filter (fun x => x∈ S j)=S j from (by simp)]exact Finset.sum_congr rfl fun l _ => congr_fun (congr_fun hq x) lexact hy.trans h1omit [Fintype I] inprivate theorem scripted (p : Shape) (t : Tagging p I) (g : I→I→F)(h : 2≤p.g) (hJ : 1 ≤ p.J) :∃ s : Script p I,∀ x y,prescribedB p t s x y=g x y := byclassicalhave hh (x : I) : ∃ i : Comp p.g,inc i (t x) := byhave he := card_star (t x)have hi : Nonempty (TagStar (t x)) := Fintype.card_pos_iff.mp (by omega)obtain ⟨⟨i,h⟩⟩ := hiexact ⟨i,h⟩choose q hq using hhlet i0 : Fin p.J := ⟨0,hJ⟩let s : Script p I := fun x y i =>if i.1=(i0,q x,q y) then if i.2 then g x y else 1 else 0refine ⟨s,fun x y => ?_⟩unfold prescribedBrw [Finset.sum_eq_single i0]· rw [Finset.sum_eq_single (q x)]· rw [Finset.sum_eq_single (q y)]· simp [s,hq]· intro i _ hi; simp [s,hi]simp· intro i _ hi; simp [s,hi]simp· intro i _ hi; simp [s,hi]simpset_option maxHeartbeats 600000 intheorem choose_script (p : Shape) (t : Tagging p I) (a b : I→Bool)(d : Vec I)(f : Vec I)(d' : Vec I)(h : ∀ i : Bool,(∑ x∈aiming a b i true,(d' x+f x)) =∑ x∈aiming a b i false,(d' x+f x))(ha : ∀ i j : Bool, ∑ x∈aiming a b i j,(d x+d' x)=1)(hc : ∀ i j : Bool,(aiming a b i j).Nonempty)(u : Mat I I) (hu : uᵀ=u)(hg : 2≤p.g) (hi : 1≤p.J) :∃ s : Script p I, fulfills p t d f u s a b := byclassicalhave hh (i j : Bool) :(∑ x∈aiming a b i j,(d x+f x))=1+ ∑ x∈aiming a b i j,(d' x+f x) := byrw [←ha,← Finset.sum_add_distrib]refine Finset.sum_congr rfl fun x _ => ?_rw [add_assoc,←add_assoc (d' x),char_two,zero_add]choose M hM hD hA using fun i : Bool => binary_plan a b i d f (by rw [hh,hh,h]) (hc i)let F' := Fintype.equivFin Ilet g (x y : I) := if F' x < F' y then M (a x) x y+u x y else 0obtain ⟨s,hs⟩ := scripted p t g hg hihave hf (x y : I) (h : a x=a y) : prescribedT p t d u s x y=M (a x) x y := byunfold prescribedTsplit· rename_i hesubst yexact (hD _ _).symmrename_i herw [hs x y, hs y x]rcases lt_or_gt_of_ne (show F' x ≠ F' y from fun h => he (F'.injective h)) with e|e· simp only [g, ite_eq_left e,ite_eq_right (not_lt.mpr e.le),add_zero]rw [add_left_comm,char_two,add_zero]simp only [g,ite_eq_left e,ite_eq_right (not_lt.mpr e.le),zero_add]rw [←h,show u y x=u x y from congr_fun (congr_fun hu x) y,show M (a x) y x=M (a x) x y from congr_fun (congr_fun (hM (a x)) x) y]rw [add_left_comm,char_two,add_zero]refine ⟨s,fun x j => ?_⟩let S := aiming a b (a x) jhave he : ∑ i∈S,prescribedT p t d u s i x=∑ i∈S,M (a x) i x :=Finset.sum_congr rfl fun i hi => byhave hm : a i=a x := (Finset.mem_filter.mp hi).2.1rw [hf i x hm,hm]rw [he,hA (a x) j x (by simp), ← add_assoc, char_two,zero_add]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import OAI.Combinatorics.HadwigerCounterexample.FiniteOptionLabelsnamespace OAI/-! # Binary Status Comparison -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Filter Function Submodule Module LinearMapopen scoped BigOperatorsvariable {A B J H : Type} [Fintype A] [Fintype B] [Fintype J]theorem disagreement_bound (w : Wgt A) (hw : ∀ x,0 ≤ w x) (f g h:A→ H) :pr w (fun i=> f i≠ h i) ≤ pr w (fun i=>f i≠ g i) + pr w (fun i=>g i≠h i) :=let p (i:A) := f i≠g i∨g i≠h i((pr_mono hw fun i h=>show p i from Classical.byContradiction (fun hi => h (Eq.trans(not_not.mp (mt Or.inl hi)) (not_not.mp (mt Or.inr hi))))).trans (pr_or_le hw))def majority (w : Wgt A) (f : A→F) :=if 1/2≤ pr w (fun i=>f i=0) then (0:F) else 1theorem majority_bound (w : Wgt A) (hw:IsLaw w) (f : A→F) :1/2 ≤ pr w (fun i=> f i= majority w f) := byclassicalunfold majoritysplitnext h => exact hnext h =>have hi i : f i=1 ↔ ¬f i=0 :=⟨fun hh=>by rw [hh]; exact one_ne_zero,fun hh=>(bit_cases _).resolve_left hh⟩simp_rw [hi,pr_not,hw.total]exact le_of_lt (by linarith only [h])theorem majority_charge (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)(f:A→F) (g:B→F) :pr p (fun i=> f i≠majority q g)≤2 * pr (pairW p q) (fun i=> f i.1≠g i.2) := byclassicallet Q i:= g i=majority q g; let P i:= f i≠majority q glet v:= pairW p qhave hm (z:A×B) (h:P z.1∧Q z.2): f z.1≠g z.2 := h.2 ▸ h.1have hh : pr p P*pr q Q ≤ pr v (fun i=>f i.1≠g i.2) :=(pairW_pr ..).symm.le.trans (pr_mono (pairW_law hp hq).nz hm)have hx:=majority_bound q hq ghave hh' := mul_le_mul_of_nonneg_left hx (pr_nonneg (p:=P) hp.nz)change _* (1/2) ≤ _*pr q Q at hh'change pr p P≤2*pr v _linarith only [hh,hh']theorem reflect_cost (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)(f:A→H) (g:B→H) (k:H) :pr q (fun i=>g i≠k)≤ pr (pairW p q) (fun i=>f i.1≠g i.2)+pr p (fun i=>f i≠k) := bylet w:=pairW p qlet t i:= g i≠k; let s i:= f i≠khave hi : pr q t=pr w (fun i=> t i.2) := by simpa [hp.total] using(pairW_pr p q (fun _=>True) t).symmhave hj : pr p s=pr w (fun i=>s i.1) := by simpa [hq.total] using(pairW_pr p q s (fun _=>True)).symmlet P (i:A×B):= f i.1 ≠ g i.2rw [hi,hj]have hh (i:A×B) (h:t i.2): P i∨ s i.1 := byby_cases he:P i· exact Or.inl heexact Or.inr (fun hc=> h ((not_not.mp he).symm.trans hc))exact (pr_mono (pairW_law hp hq).nz hh).trans (pr_or_le (pairW_law hp hq).nz)namespace StatusAnalysisnamespace DualAnalysisvariable {p:Shape} {d e: Rates} {r K:ℕ}abbrev Pulsar (p:Shape) (r:ℕ):= Tag p.g → F → Fin r→Fvariable (u:Terrain p r) (s:Gazette p r d) (t:Gazette p r e)def shot (i:Nodes) (x:Appearance p) (a:RhymeSet (d i)) (f:Pulsar p r) :=avg (u x.l x.q) (fun j=>pr (s i x j) (fun v=> a.soot x v ≠f x.l x.q j))def praise (u:Terrain p r) (s:Gazette p r d) (i:Nodes)(A:Finset (Label p.b)) (a:RhymeSet (d i)) (f:Pulsar p r) (ε:ℝ) :=∀ x:Appearance p,x.s∉A →x.apt → shot u s i x a f≤εdef counsel (i:Grid) (A B:Finset (Label p.b))(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ) :=∀ x:Zodiac p,x.common → x.s true∉A →x.s false∉ B →charge u x s t i a b≤εdef amazes (p:Shape) (z:Label p.b) (l: Tag p.g) (q:F):Appearance p:=⟨l,z,Flavor.full,q⟩def amends (p:Shape) (x y:Appearance p): Zodiac p :={l:=x.lq:=x.qs i:=if i then x.s else y.sf i:=if i then x.f else y.f}theorem amendsB (x y: Appearance p)(h:x.l=y.l)(ht:x.q=y.q):(amends p x y).aspect false=y := by cases x; cases y; simp_all [amends,Zodiac.aspect]theorem splitCounsel (i:Grid) (A B:Finset (Label p.b))(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ)(h:counsel u s t i A B a b ε) (x y:Appearance p)(hx:x.s∉A) (hy:y.s∉B) (he:x.apt) (hf:y.apt) (hg:x.l=y.l) (hk:x.q=y.q) :avg (u x.l x.q) (fun j=>pr (pairW (s i.1 x j) (t i.2 y j)) (fun k=>a.soot x k.1 ≠b.soot y k.2))≤ε := byclassicallet Z:=amends p x yhave hQ : Z.aspect false=y := amendsB _ _ hg hkhave hP : Z.aspect true=x := rflhave hm : Z.common := by intro i;cases i; rw [hQ];exact hf; rw [hP];exact hehave hi:= h Z hm hx hyunfold charge circlet pr couplePage at hirw [mixW_avg,hQ,hP] at hiexact hiset_option maxHeartbeats 800000 intheorem paeans {β δ:ℝ} (hu:origami p r u δ)(hs:reports p r u s β δ)(ht:reports p r u t β δ)(i:Grid) (A B:Finset (Label p.b)) (hx:A.card<Fintype.card (Label p.b))(hy:B.card<Fintype.card (Label p.b)) (hg:3≤p.g)(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε:ℝ) (he:0≤ε)(h:counsel u s t i A B a b ε) :∃ f:Pulsar p r, praise u s i.1 A a f (3*ε) ∧ praise u t i.2 B b f (3*ε) := byclassicalobtain ⟨x,hx⟩:=any_label A hxobtain ⟨y,hy⟩:=any_label B hylet Z:= amazes p ylet f l q j:= majority (t i.2 (Z l q) j) (b.soot (Z l q))have hl:praise u s i.1 A a f (2*ε) := byintro z hz hhqlet w:= Z z.l z.qhave ht' := generic_apt p hg w rflhave hh := splitCounsel u s t i A B a b ε h z w hz hy hhq ht' rfl rflrefine le_trans (avg_mono (hu.1 z.l z.q).nz (fun j=> majority_charge (s i.1 z j) (t i.2 w j)(hs.law _ _ hhq _) (ht.law _ _ ht' _) (a.soot z) (b.soot w))) ?_rw [avg_mul']exact mul_le_mul_of_nonneg_left hh (by norm_num)refine ⟨f,fun w hw hx=>(hl _ hw hx).trans (by linarith only [he]), fun w hw hv=>?_⟩let z:=amazes p x w.l w.qhave hf : z.apt:=generic_apt _ hg _ rflhave hx0:= splitCounsel u s t i A B a b ε h z w hx hw hf hv rfl rflhave hl0:=hl z hx hflet W:=u w.l w.qhave heq j:= reflect_cost (s i.1 z j) (t i.2 w j) (hs.law _ _ hf j) (ht.law _ _ hv j)(a.soot z) (b.soot w) (f w.l w.q j)apply (avg_mono (hu.1 w.l w.q).nz heq).transrw [avg_add]; exact (add_le_add hx0 hl0).trans_eq (by ring)end DualAnalysisend StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import OAI.Combinatorics.HadwigerCounterexample.FiniteOptionLabelsnamespace OAI/-! # Binary Status Comparison -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Filter Function Submodule Module LinearMapopen scoped BigOperatorsvariable {A B J H : Type} [Fintype A] [Fintype B] [Fintype J]theorem disagreement_bound (w : Wgt A) (hw : ∀ x,0 ≤ w x) (f g h:A→ H) :pr w (fun i=> f i≠ h i) ≤ pr w (fun i=>f i≠ g i) + pr w (fun i=>g i≠h i) :=let p (i:A) := f i≠g i∨g i≠h i((pr_mono hw fun i h=>show p i from Classical.byContradiction (fun hi => h (Eq.trans(not_not.mp (mt Or.inl hi)) (not_not.mp (mt Or.inr hi))))).trans (pr_or_le hw))def majority (w : Wgt A) (f : A→F) :=if 1/2≤ pr w (fun i=>f i=0) then (0:F) else 1theorem majority_bound (w : Wgt A) (hw:IsLaw w) (f : A→F) :1/2 ≤ pr w (fun i=> f i= majority w f) := byclassicalunfold majoritysplitnext h => exact hnext h =>have hi i : f i=1 ↔ ¬f i=0 :=⟨fun hh=>by rw [hh]; exact one_ne_zero,fun hh=>(bit_cases _).resolve_left hh⟩simp_rw [hi,pr_not,hw.total]exact le_of_lt (by linarith only [h])theorem majority_charge (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)(f:A→F) (g:B→F) :pr p (fun i=> f i≠majority q g)≤2 * pr (pairW p q) (fun i=> f i.1≠g i.2) := byclassicallet Q i:= g i=majority q g; let P i:= f i≠majority q glet v:= pairW p qhave hm (z:A×B) (h:P z.1∧Q z.2): f z.1≠g z.2 := h.2 ▸ h.1have hh : pr p P*pr q Q ≤ pr v (fun i=>f i.1≠g i.2) :=(pairW_pr ..).symm.le.trans (pr_mono (pairW_law hp hq).nz hm)have hx:=majority_bound q hq ghave hh' := mul_le_mul_of_nonneg_left hx (pr_nonneg (p:=P) hp.nz)change _* (1/2) ≤ _*pr q Q at hh'change pr p P≤2*pr v _linarith only [hh,hh']theorem reflect_cost (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)(f:A→H) (g:B→H) (k:H) :pr q (fun i=>g i≠k)≤ pr (pairW p q) (fun i=>f i.1≠g i.2)+pr p (fun i=>f i≠k) := bylet w:=pairW p qlet t i:= g i≠k; let s i:= f i≠khave hi : pr q t=pr w (fun i=> t i.2) := by simpa [hp.total] using(pairW_pr p q (fun _=>True) t).symmhave hj : pr p s=pr w (fun i=>s i.1) := by simpa [hq.total] using(pairW_pr p q s (fun _=>True)).symmlet P (i:A×B):= f i.1 ≠ g i.2rw [hi,hj]have hh (i:A×B) (h:t i.2): P i∨ s i.1 := byby_cases he:P i· exact Or.inl heexact Or.inr (fun hc=> h ((not_not.mp he).symm.trans hc))exact (pr_mono (pairW_law hp hq).nz hh).trans (pr_or_le (pairW_law hp hq).nz)namespace StatusAnalysisnamespace DualAnalysisvariable {p:Shape} {d e: Rates} {r K:ℕ}abbrev Pulsar (p:Shape) (r:ℕ):= Tag p.g → F → Fin r→Fvariable (u:Terrain p r) (s:Gazette p r d) (t:Gazette p r e)def shot (i:Nodes) (x:Appearance p) (a:RhymeSet (d i)) (f:Pulsar p r) :=avg (u x.l x.q) (fun j=>pr (s i x j) (fun v=> a.soot x v ≠f x.l x.q j))def praise (u:Terrain p r) (s:Gazette p r d) (i:Nodes)(A:Finset (Label p.b)) (a:RhymeSet (d i)) (f:Pulsar p r) (ε:ℝ) :=∀ x:Appearance p,x.s∉A →x.apt → shot u s i x a f≤εdef counsel (i:Grid) (A B:Finset (Label p.b))(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ) :=∀ x:Zodiac p,x.common → x.s true∉A →x.s false∉ B →charge u x s t i a b≤εdef amazes (p:Shape) (z:Label p.b) (l: Tag p.g) (q:F):Appearance p:=⟨l,z,Flavor.full,q⟩def amends (p:Shape) (x y:Appearance p): Zodiac p :={l:=x.lq:=x.qs i:=if i then x.s else y.sf i:=if i then x.f else y.f}theorem amendsB (x y: Appearance p)(h:x.l=y.l)(ht:x.q=y.q):(amends p x y).aspect false=y := by cases x; cases y; simp_all [amends,Zodiac.aspect]theorem splitCounsel (i:Grid) (A B:Finset (Label p.b))(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ)(h:counsel u s t i A B a b ε) (x y:Appearance p)(hx:x.s∉A) (hy:y.s∉B) (he:x.apt) (hf:y.apt) (hg:x.l=y.l) (hk:x.q=y.q) :avg (u x.l x.q) (fun j=>pr (pairW (s i.1 x j) (t i.2 y j)) (fun k=>a.soot x k.1 ≠b.soot y k.2))≤ε := byclassicallet Z:=amends p x yhave hQ : Z.aspect false=y := amendsB _ _ hg hkhave hP : Z.aspect true=x := rflhave hm : Z.common := by intro i;cases i; rw [hQ];exact hf; rw [hP];exact hehave hi:= h Z hm hx hyunfold charge circlet pr couplePage at hirw [mixW_avg,hQ,hP] at hiexact hiset_option maxHeartbeats 800000 intheorem paeans {β δ:ℝ} (hu:origami p r u δ)(hs:reports p r u s β δ)(ht:reports p r u t β δ)(i:Grid) (A B:Finset (Label p.b)) (hx:A.card<Fintype.card (Label p.b))(hy:B.card<Fintype.card (Label p.b)) (hg:3≤p.g)(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε:ℝ) (he:0≤ε)(h:counsel u s t i A B a b ε) :∃ f:Pulsar p r, praise u s i.1 A a f (3*ε) ∧ praise u t i.2 B b f (3*ε) := byclassicalobtain ⟨x,hx⟩:=any_label A hxobtain ⟨y,hy⟩:=any_label B hylet Z:= amazes p ylet f l q j:= majority (t i.2 (Z l q) j) (b.soot (Z l q))have hl:praise u s i.1 A a f (2*ε) := byintro z hz hhqlet w:= Z z.l z.qhave ht' := generic_apt p hg w rflhave hh := splitCounsel u s t i A B a b ε h z w hz hy hhq ht' rfl rflrefine le_trans (avg_mono (hu.1 z.l z.q).nz (fun j=> majority_charge (s i.1 z j) (t i.2 w j)(hs.law _ _ hhq _) (ht.law _ _ ht' _) (a.soot z) (b.soot w))) ?_rw [avg_mul']exact mul_le_mul_of_nonneg_left hh (by norm_num)refine ⟨f,fun w hw hx=>(hl _ hw hx).trans (by linarith only [he]), fun w hw hv=>?_⟩let z:=amazes p x w.l w.qhave hf : z.apt:=generic_apt _ hg _ rflhave hx0:= splitCounsel u s t i A B a b ε h z w hx hw hf hv rfl rflhave hl0:=hl z hx hflet W:=u w.l w.qhave heq j:= reflect_cost (s i.1 z j) (t i.2 w j) (hs.law _ _ hf j) (ht.law _ _ hv j)(a.soot z) (b.soot w) (f w.l w.q j)apply (avg_mono (hu.1 w.l w.q).nz heq).transrw [avg_add]; exact (add_le_add hx0 hl0).trans_eq (by ring)end DualAnalysisend StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151import OAI.Combinatorics.HadwigerCounterexample.MomentCoordinatesimport OAI.Combinatorics.HadwigerCounterexample.MatrixFactorizationnamespace OAI/-! # Boolean Labels -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Finsetvariable {b : ℕ}def monoBit (s : Label b) (S : Finset (Fin b)) := ∏ i ∈ S, s itheorem mono_insert (s : Label b) (S : Finset (Fin b)) (i) :monoBit s (insert i S) = s i * monoBit s S := byby_cases h : i∈S· rw [insert_eq_of_mem h]unfold monoBitrw [← Finset.mul_prod_erase _ _ h,← mul_assoc,bit_sq]· simp [monoBit,h]theorem mono_union (s : Label b) (S T : Finset (Fin b)) :monoBit s (S∪T)= monoBit s S*monoBit s T := byinduction S using Finset.induction with| empty => simp [monoBit]| insert i S h ih =>rw [insert_union,mono_insert,mono_insert,ih,mul_assoc]/-- Independence up to degree j for at most j+1 labels, in coefficient form. -/theorem selector_indep (L : Finset (Label b)) (c : Label b → F) (j : ℕ)(h : L.card ≤ j+1) (hf : ∀ S : Finset (Fin b), S.card ≤ j →∑ s ∈ L,c s*monoBit s S=0) : ∀ i∈L,c i=0 := byclassicalintro s hsinduction L using Finset.strongInductionOn generalizing c j with | _ L ihby_cases hL : ∃ i∈L,i≠s· obtain ⟨t,ht,hst⟩ := hLobtain ⟨i,hi⟩ : ∃ i : Fin b,t i≠s i := Function.ne_iff.mp hstlet d (u : Label b) := (u i-t i) * c uhave hg : j>0 := by have he := Finset.one_lt_card.mpr ⟨t,ht,s,hs,hst⟩; omegahave he : (L.erase t).card ≤ (j-1)+1 := byhave he := card_erase_add_one ht; omegahave hw (U : Finset (Fin b)) (hu : U.card ≤ j-1) :∑ s ∈ L.erase t,d s*monoBit s U=0 := byhave heq (s : Label b) :d s * monoBit s U = c s * monoBit s (insert i U) - t i*(c s*monoBit s U) := byunfold d; rw [mono_insert]; ringrw [show ∑ s ∈ L.erase t,d s*monoBit s U = ∑ s ∈ L,d s*monoBit s U byconv_rhs => rw [← Finset.add_sum_erase _ _ ht]simp [d]]simp_rw [heq, Finset.sum_sub_distrib,← Finset.mul_sum]have hj : (insert i U).card ≤ j := byby_cases hh : i∈U· rw [insert_eq_of_mem hh]; omega· rw [card_insert_of_notMem hh]; omegarw [hf _ hj, hf _ (by omega),mul_zero,sub_zero]have hu := ih (L.erase t) (erase_ssubset ht) d (j-1) he hw(Finset.mem_erase.mpr ⟨hst.symm,hs⟩)exact (mul_eq_zero.mp hu).resolve_left (sub_ne_zero.mpr hi.symm)· have he : L={s} := byext x; constructor· intro hx; exact mem_singleton.mpr (Classical.byContradiction fun h => hL ⟨x,hx,h⟩)intro hx; rwa [mem_singleton.mp hx]have hh := hf ∅ (by simp)simpa [he,monoBit] using hhvariable {p : Shape} {n : ℕ}def hankel (M : Moment p n) :=∀ (i k : AIdx p.g n) (a b c d : SelIdx p.b p.j),a.val ∪ b.val = c.val ∪ d.val → M (a,i) (b,k) = M (c,i) (d,k)def diagBase (M : Moment p n) :=∀ (i : AIdx p.g n) (a b : SelIdx p.b p.j), M (a,i) (b,i) = M (a,none) (b,i)theorem point_eval (p : Shape) (s : Label p.b) (z : Base p.g n)(r : SelIdx p.b p.j) (i : AIdx p.g n) : point p s z (r,i) = monoBit s r.val * baseV z i :=rfltheorem Wspace_hank {M : Moment p n} (h : M∈Wspace p n) : hankel M := byintro i k a b c d habunfold Wspace at hinduction h using Submodule.span_induction with| mem M hm =>obtain ⟨s,z,rfl⟩ := hmhave h (a b : SelIdx p.b p.j) :mom p s z (a,i) (b,k) = monoBit s (a.val ∪ b.val) * (baseV z i*baseV z k) := bysimp only [mom,vecMulVec_apply,point_eval,mono_union]; ringrw [h,h,hab]| zero => rfl| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]| smul v x _ hx => simp only [Matrix.smul_apply,hx]theorem Wspace_diag {M : Moment p n} (h : M∈Wspace p n) : diagBase M := byintro i a bunfold Wspace at hinduction h using Submodule.span_induction with| mem M hm =>obtain ⟨s,z,rfl⟩ := hmsimp only [mom,vecMulVec_apply,point_eval,baseV]rw [mul_mul_mul_comm,bit_sq]have hn : Option.elim' (1:F) z none = 1 := rflrw [hn]ring| zero => rfl| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]| smul v x _ hx => simp only [Matrix.smul_apply,hx]abbrev BaseMat (p : Shape) (n : ℕ) := Mat (AIdx p.g n) (AIdx p.g n)def labMat (p : Shape) (n) (s : Label p.b) :Mat (Row p n) (AIdx p.g n) :=Matrix.of (fun v i => if v.2=i then monoBit s v.1.val else 0)theorem labMat_act (s) (z : Vec (AIdx p.g n)) :labMat p n s *ᵥ z = putLab p n s z := byfunext isimp [Matrix.mulVec,dotProduct,labMat,putLab,monoBit,selV]def mput (p : Shape) (s : Label p.b) {n} :BaseMat p n →ₗ[F] Moment p n := liftM (labMat p n s) (labMat p n s)theorem mput_apply (s) (Z : BaseMat p n) (i j) : mput p s Z i j =monoBit s i.1.val*monoBit s j.1.val*Z i.2 j.2 := byclassicalsimp [mput,liftM_def,Matrix.mul_apply,transpose_apply,labMat, mul_comm,mul_left_comm,mul_assoc]theorem mput_hank (s) (Z : BaseMat p n) : hankel (mput p s Z) := byintro i j a b c d hrw [mput_apply,mput_apply]simp_rw [← mono_union,h]/-- Short label-tagged rays give a direct family of copies of the affine-vector space. -/theorem ray_indep (L : Finset (Label p.b)) (Z : Label p.b → Vec (AIdx p.g n))(hj : L.card ≤ p.j+1) (he : ∑ i∈L, putLab p n i (Z i) = 0) :∀ i∈L, Z i=0 := byhave hg (u : AIdx p.g n) (i : Label p.b) (hi : i ∈ L) :Z i u=0 := byrefine selector_indep L (fun i => Z i u) p.j hj ?_ i hiintro S hShave hh := congr_fun he ((⟨S,hS⟩ : SelIdx p.b p.j),u)simpa [putLab,Finset.sum_apply,monoBit,selV,mul_comm] using hhexact fun i hi => funext (fun u => hg u i hi)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151import OAI.Combinatorics.HadwigerCounterexample.MomentCoordinatesimport OAI.Combinatorics.HadwigerCounterexample.MatrixFactorizationnamespace OAI/-! # Boolean Labels -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Finsetvariable {b : ℕ}def monoBit (s : Label b) (S : Finset (Fin b)) := ∏ i ∈ S, s itheorem mono_insert (s : Label b) (S : Finset (Fin b)) (i) :monoBit s (insert i S) = s i * monoBit s S := byby_cases h : i∈S· rw [insert_eq_of_mem h]unfold monoBitrw [← Finset.mul_prod_erase _ _ h,← mul_assoc,bit_sq]· simp [monoBit,h]theorem mono_union (s : Label b) (S T : Finset (Fin b)) :monoBit s (S∪T)= monoBit s S*monoBit s T := byinduction S using Finset.induction with| empty => simp [monoBit]| insert i S h ih =>rw [insert_union,mono_insert,mono_insert,ih,mul_assoc]/-- Independence up to degree j for at most j+1 labels, in coefficient form. -/theorem selector_indep (L : Finset (Label b)) (c : Label b → F) (j : ℕ)(h : L.card ≤ j+1) (hf : ∀ S : Finset (Fin b), S.card ≤ j →∑ s ∈ L,c s*monoBit s S=0) : ∀ i∈L,c i=0 := byclassicalintro s hsinduction L using Finset.strongInductionOn generalizing c j with | _ L ihby_cases hL : ∃ i∈L,i≠s· obtain ⟨t,ht,hst⟩ := hLobtain ⟨i,hi⟩ : ∃ i : Fin b,t i≠s i := Function.ne_iff.mp hstlet d (u : Label b) := (u i-t i) * c uhave hg : j>0 := by have he := Finset.one_lt_card.mpr ⟨t,ht,s,hs,hst⟩; omegahave he : (L.erase t).card ≤ (j-1)+1 := byhave he := card_erase_add_one ht; omegahave hw (U : Finset (Fin b)) (hu : U.card ≤ j-1) :∑ s ∈ L.erase t,d s*monoBit s U=0 := byhave heq (s : Label b) :d s * monoBit s U = c s * monoBit s (insert i U) - t i*(c s*monoBit s U) := byunfold d; rw [mono_insert]; ringrw [show ∑ s ∈ L.erase t,d s*monoBit s U = ∑ s ∈ L,d s*monoBit s U byconv_rhs => rw [← Finset.add_sum_erase _ _ ht]simp [d]]simp_rw [heq, Finset.sum_sub_distrib,← Finset.mul_sum]have hj : (insert i U).card ≤ j := byby_cases hh : i∈U· rw [insert_eq_of_mem hh]; omega· rw [card_insert_of_notMem hh]; omegarw [hf _ hj, hf _ (by omega),mul_zero,sub_zero]have hu := ih (L.erase t) (erase_ssubset ht) d (j-1) he hw(Finset.mem_erase.mpr ⟨hst.symm,hs⟩)exact (mul_eq_zero.mp hu).resolve_left (sub_ne_zero.mpr hi.symm)· have he : L={s} := byext x; constructor· intro hx; exact mem_singleton.mpr (Classical.byContradiction fun h => hL ⟨x,hx,h⟩)intro hx; rwa [mem_singleton.mp hx]have hh := hf ∅ (by simp)simpa [he,monoBit] using hhvariable {p : Shape} {n : ℕ}def hankel (M : Moment p n) :=∀ (i k : AIdx p.g n) (a b c d : SelIdx p.b p.j),a.val ∪ b.val = c.val ∪ d.val → M (a,i) (b,k) = M (c,i) (d,k)def diagBase (M : Moment p n) :=∀ (i : AIdx p.g n) (a b : SelIdx p.b p.j), M (a,i) (b,i) = M (a,none) (b,i)theorem point_eval (p : Shape) (s : Label p.b) (z : Base p.g n)(r : SelIdx p.b p.j) (i : AIdx p.g n) : point p s z (r,i) = monoBit s r.val * baseV z i :=rfltheorem Wspace_hank {M : Moment p n} (h : M∈Wspace p n) : hankel M := byintro i k a b c d habunfold Wspace at hinduction h using Submodule.span_induction with| mem M hm =>obtain ⟨s,z,rfl⟩ := hmhave h (a b : SelIdx p.b p.j) :mom p s z (a,i) (b,k) = monoBit s (a.val ∪ b.val) * (baseV z i*baseV z k) := bysimp only [mom,vecMulVec_apply,point_eval,mono_union]; ringrw [h,h,hab]| zero => rfl| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]| smul v x _ hx => simp only [Matrix.smul_apply,hx]theorem Wspace_diag {M : Moment p n} (h : M∈Wspace p n) : diagBase M := byintro i a bunfold Wspace at hinduction h using Submodule.span_induction with| mem M hm =>obtain ⟨s,z,rfl⟩ := hmsimp only [mom,vecMulVec_apply,point_eval,baseV]rw [mul_mul_mul_comm,bit_sq]have hn : Option.elim' (1:F) z none = 1 := rflrw [hn]ring| zero => rfl| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]| smul v x _ hx => simp only [Matrix.smul_apply,hx]abbrev BaseMat (p : Shape) (n : ℕ) := Mat (AIdx p.g n) (AIdx p.g n)def labMat (p : Shape) (n) (s : Label p.b) :Mat (Row p n) (AIdx p.g n) :=Matrix.of (fun v i => if v.2=i then monoBit s v.1.val else 0)theorem labMat_act (s) (z : Vec (AIdx p.g n)) :labMat p n s *ᵥ z = putLab p n s z := byfunext isimp [Matrix.mulVec,dotProduct,labMat,putLab,monoBit,selV]def mput (p : Shape) (s : Label p.b) {n} :BaseMat p n →ₗ[F] Moment p n := liftM (labMat p n s) (labMat p n s)theorem mput_apply (s) (Z : BaseMat p n) (i j) : mput p s Z i j =monoBit s i.1.val*monoBit s j.1.val*Z i.2 j.2 := byclassicalsimp [mput,liftM_def,Matrix.mul_apply,transpose_apply,labMat, mul_comm,mul_left_comm,mul_assoc]theorem mput_hank (s) (Z : BaseMat p n) : hankel (mput p s Z) := byintro i j a b c d hrw [mput_apply,mput_apply]simp_rw [← mono_union,h]/-- Short label-tagged rays give a direct family of copies of the affine-vector space. -/theorem ray_indep (L : Finset (Label p.b)) (Z : Label p.b → Vec (AIdx p.g n))(hj : L.card ≤ p.j+1) (he : ∑ i∈L, putLab p n i (Z i) = 0) :∀ i∈L, Z i=0 := byhave hg (u : AIdx p.g n) (i : Label p.b) (hi : i ∈ L) :Z i u=0 := byrefine selector_indep L (fun i => Z i u) p.j hj ?_ i hiintro S hShave hh := congr_fun he ((⟨S,hS⟩ : SelIdx p.b p.j),u)simpa [putLab,Finset.sum_apply,monoBit,selV,mul_comm] using hhexact fun i hi => funext (fun u => hg u i hi)end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134import OAI.Combinatorics.HadwigerCounterexample.IndependentColumnBatchesimport OAI.Combinatorics.HadwigerCounterexample.CollisionInequalitynamespace OAI/-! # Bounded Query Templates -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Module LinearMap Functionvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]structure Template (p : Shape) (I : Type) whereaim : I→Boolt : Tagging p Is : I→Label p.bf : I→Flavor p.gabbrev Inputs (p : Shape) (n : ℕ) (I : Type) := I → Knobs p.g nnamespace Templatevariable (v : Template p I)def draw (y : Inputs p n I) : Volley p n I whereobj := v.aimsel := v.spar i := lit (v.f i) (v.t i) (y i)def state (q : I→F) (n : ℕ) : Wgt (Inputs p n I) :=prodW (fun i : I => scopedBit p n (v.t i) (v.f i) (q i))omit [Fintype I] [DecidableEq I] intheorem draw_legal (y : Inputs p n I) : (v.draw y).legal v.t :=fun _ => lit_allows _ _ _end Templateabbrev KeySlots (p : Shape) (t : Tagging p I) := Σ i, TagStar (t i)def scatter (t : Tagging p I) (N : ℕ) : Keys (p:=p) t N ≃ Rack (KeySlots p t) N wheretoFun x := (Matrix.of (fun j i => x i.1 i.2 true j),Matrix.of (fun j i => x i.1 i.2 false j))invFun x := fun i j b => if b then x.1.col ⟨i,j⟩ else x.2.col ⟨i,j⟩left_inv x := by funext i j b; cases b <;> rflright_inv x := by apply Prod.ext <;> rfldef globPort (p : Shape) (t : Tagging p I) (q : I→Bool) :Route (KeySlots p t) (Ports p) :=fun x => (q x.1,x.2.val)def nomAsk (t : Tagging p I) (v : Volley p n I) :NomQuery p n (globPort p t v.obj) :=fun _ => Matrix.of (fun i j => v.rayAt j.val.1 i)omit [Fintype I] [DecidableEq I] intheorem peek_keys (t : Tagging p I) (v : Volley p n I) (x : UnitType p n N) :peekR p (globPort p t v.obj) (nomAsk t v) (nomAsk t v) (mergeR p x) =scatter t N (v.keys t x) := byapply Prod.ext· ext i j; rfl· ext i j; rfltheorem raw_keys (t : Tagging p I) (v : Volley p n I) (m : Mixer p n) {N : ℕ}(hN : 2*num (Full p n)<N) (ha : ∀ i, Injective (nomAsk t v i).mulVec) :let r := raw m NmapW (pairW r r) ((scatter t N) ∘ v.keys t) = rackStation (database m (nomAsk t v) (nomAsk t v)) N := byclassicallet g := globPort p t v.objlet A := nomAsk t vhave hh := law_peekR m hN ha harw [← law_mergeR m N, mapW_nested] at hhrefine Eq.trans ?_ hhcongr 1def ownPort (t : Tagging p I) : Route (KeySlots p t) (Comp p.g) := fun x => x.2.valdef ownMap (t : Tagging p I) (q : I→F) : GeoM (ownPort (p:=p) t) :=fun _ => Matrix.diagonal (fun i => q i.val.1)def ownPart (t : Tagging p I) (q : I→F) {N : ℕ}(x : Keys (p:=p) t N) :=gramPart (ownMap (p:=p) t q) (scatter t N x)def lawNu (p : Shape) (N : ℕ) (t : Tagging p I) (q : I→F) :Wgt (Keys (p:=p) t N) := unifOn (ownPart (p:=p) t q)theorem lawNu_rack (t : Tagging p I) (q : I→F) :mapW (lawNu p N t q) (scatter t N) = rackWave (ownMap t q) N :=on_equiv ..def ownOne (p : Shape) {N : ℕ} (l : Tag p.g) (q : F) (x : AtomKey (p:=p) l N) :=∀ i,dotProduct (x i true) (x i false) = qdef lawOmega (p : Shape) (N : ℕ) (l : Tag p.g) (q : F) :Wgt (AtomKey (p:=p) l N) := unifOn (ownOne p l q)omit [Fintype I] intheorem ownPart_def (t : Tagging p I) (q : I→F) {N : ℕ} (x : Keys (p:=p) t N) :ownPart (p:=p) t q x ↔(∀ i, ownOne p (t i) (q i) (x i)) ∧∀ (i j : I) (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)), i≠j →dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false)=0 := byclassicallet Q := ownPort (p:=p) tunfold ownPartrw [part_scores]have he i j (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)) :let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩scoreR (scatter t N x) a b=dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false) := rflconstructor· intro hconstructor· rintro i ⟨e,hi⟩let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩exact (he i i e hi hi).symm.trans ((h e a a).trans (Matrix.diagonal_apply_eq ..))intro i j e hi hj heqlet a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩have hh : a≠b := fun h => heq (congrArg (fun x:Port Q e => x.val.1) h)exact (he i j e hi hj).symm.trans ((h e a b).trans (Matrix.diagonal_apply_ne _ hh))· rintro ⟨h,h'⟩ e ⟨⟨i,v⟩,ha⟩ ⟨⟨j,w⟩,hb⟩rcases v with ⟨v,hv⟩; rcases w with ⟨w,hw⟩change v = e at ha; change w=e at hbsubst v; subst wlet a : Port Q e := ⟨⟨i,⟨e,hv⟩⟩,rfl⟩let b : Port Q e := ⟨⟨j,⟨e,hw⟩⟩,rfl⟩by_cases he : i=j· subst jrefine (show scoreR (scatter t N x) a.val a.val=_ from h i ��e,hv⟩).trans ?_exact (Matrix.diagonal_apply_eq (fun j : Port Q e => q j.val.1) a).symmhave hh : a≠b := fun h => he (congrArg (fun x:Port Q e => x.val.1) h)refine Eq.trans (h' i j e hv hw he) ?_exact (Matrix.diagonal_apply_ne (fun j : Port Q e => q j.val.1) hh).symmend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134import OAI.Combinatorics.HadwigerCounterexample.IndependentColumnBatchesimport OAI.Combinatorics.HadwigerCounterexample.CollisionInequalitynamespace OAI/-! # Bounded Query Templates -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Module LinearMap Functionvariable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]structure Template (p : Shape) (I : Type) whereaim : I→Boolt : Tagging p Is : I→Label p.bf : I→Flavor p.gabbrev Inputs (p : Shape) (n : ℕ) (I : Type) := I → Knobs p.g nnamespace Templatevariable (v : Template p I)def draw (y : Inputs p n I) : Volley p n I whereobj := v.aimsel := v.spar i := lit (v.f i) (v.t i) (y i)def state (q : I→F) (n : ℕ) : Wgt (Inputs p n I) :=prodW (fun i : I => scopedBit p n (v.t i) (v.f i) (q i))omit [Fintype I] [DecidableEq I] intheorem draw_legal (y : Inputs p n I) : (v.draw y).legal v.t :=fun _ => lit_allows _ _ _end Templateabbrev KeySlots (p : Shape) (t : Tagging p I) := Σ i, TagStar (t i)def scatter (t : Tagging p I) (N : ℕ) : Keys (p:=p) t N ≃ Rack (KeySlots p t) N wheretoFun x := (Matrix.of (fun j i => x i.1 i.2 true j),Matrix.of (fun j i => x i.1 i.2 false j))invFun x := fun i j b => if b then x.1.col ⟨i,j⟩ else x.2.col ⟨i,j⟩left_inv x := by funext i j b; cases b <;> rflright_inv x := by apply Prod.ext <;> rfldef globPort (p : Shape) (t : Tagging p I) (q : I→Bool) :Route (KeySlots p t) (Ports p) :=fun x => (q x.1,x.2.val)def nomAsk (t : Tagging p I) (v : Volley p n I) :NomQuery p n (globPort p t v.obj) :=fun _ => Matrix.of (fun i j => v.rayAt j.val.1 i)omit [Fintype I] [DecidableEq I] intheorem peek_keys (t : Tagging p I) (v : Volley p n I) (x : UnitType p n N) :peekR p (globPort p t v.obj) (nomAsk t v) (nomAsk t v) (mergeR p x) =scatter t N (v.keys t x) := byapply Prod.ext· ext i j; rfl· ext i j; rfltheorem raw_keys (t : Tagging p I) (v : Volley p n I) (m : Mixer p n) {N : ℕ}(hN : 2*num (Full p n)<N) (ha : ∀ i, Injective (nomAsk t v i).mulVec) :let r := raw m NmapW (pairW r r) ((scatter t N) ∘ v.keys t) = rackStation (database m (nomAsk t v) (nomAsk t v)) N := byclassicallet g := globPort p t v.objlet A := nomAsk t vhave hh := law_peekR m hN ha harw [← law_mergeR m N, mapW_nested] at hhrefine Eq.trans ?_ hhcongr 1def ownPort (t : Tagging p I) : Route (KeySlots p t) (Comp p.g) := fun x => x.2.valdef ownMap (t : Tagging p I) (q : I→F) : GeoM (ownPort (p:=p) t) :=fun _ => Matrix.diagonal (fun i => q i.val.1)def ownPart (t : Tagging p I) (q : I→F) {N : ℕ}(x : Keys (p:=p) t N) :=gramPart (ownMap (p:=p) t q) (scatter t N x)def lawNu (p : Shape) (N : ℕ) (t : Tagging p I) (q : I→F) :Wgt (Keys (p:=p) t N) := unifOn (ownPart (p:=p) t q)theorem lawNu_rack (t : Tagging p I) (q : I→F) :mapW (lawNu p N t q) (scatter t N) = rackWave (ownMap t q) N :=on_equiv ..def ownOne (p : Shape) {N : ℕ} (l : Tag p.g) (q : F) (x : AtomKey (p:=p) l N) :=∀ i,dotProduct (x i true) (x i false) = qdef lawOmega (p : Shape) (N : ℕ) (l : Tag p.g) (q : F) :Wgt (AtomKey (p:=p) l N) := unifOn (ownOne p l q)omit [Fintype I] intheorem ownPart_def (t : Tagging p I) (q : I→F) {N : ℕ} (x : Keys (p:=p) t N) :ownPart (p:=p) t q x ↔(∀ i, ownOne p (t i) (q i) (x i)) ∧∀ (i j : I) (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)), i≠j →dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false)=0 := byclassicallet Q := ownPort (p:=p) tunfold ownPartrw [part_scores]have he i j (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)) :let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩scoreR (scatter t N x) a b=dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false) := rflconstructor· intro hconstructor· rintro i ⟨e,hi⟩let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩exact (he i i e hi hi).symm.trans ((h e a a).trans (Matrix.diagonal_apply_eq ..))intro i j e hi hj heqlet a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩have hh : a≠b := fun h => heq (congrArg (fun x:Port Q e => x.val.1) h)exact (he i j e hi hj).symm.trans ((h e a b).trans (Matrix.diagonal_apply_ne _ hh))· rintro ⟨h,h'⟩ e ⟨⟨i,v⟩,ha⟩ ⟨⟨j,w⟩,hb⟩rcases v with ⟨v,hv⟩; rcases w with ⟨w,hw⟩change v = e at ha; change w=e at hbsubst v; subst wlet a : Port Q e := ⟨⟨i,⟨e,hv⟩⟩,rfl⟩let b : Port Q e := ⟨⟨j,⟨e,hw⟩⟩,rfl⟩by_cases he : i=j· subst jrefine (show scoreR (scatter t N x) a.val a.val=_ from h i ⟨e,hv⟩).trans ?_exact (Matrix.diagonal_apply_eq (fun j : Port Q e => q j.val.1) a).symmhave hh : a≠b := fun h => he (congrArg (fun x:Port Q e => x.val.1) h)refine Eq.trans (h' i j e hv hw he) ?_exact (Matrix.diagonal_apply_ne (fun j : Port Q e => q j.val.1) hh).symmend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177import OAI.Combinatorics.HadwigerCounterexample.SurrogateStatusLawsnamespace OAI/-! # Cell Positivity Scales -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix Functionopen scoped BigOperators Topologyvariable {p:Shape} {n N K M r : ℕ}namespace StatusAnalysisopen Templatevariable {b : PreparationParameters}namespace Appearancevariable (x : Appearance p) {s0 : ℕ}theorem readCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)(ε : ℝ) (hε : 0<ε) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →∀ Y : Silhouette p N r,pr (raw m N) (fun o=> x.apt∧¬ x.close Y o ε)≤bp (-(1/16:ℝ)*n) := byclassicalhave hp:=h.enter.firstby_cases ha : x.apt· let δ : ℝ := ε/(r+1:ℝ)have hδ : 0<δ:=by unfold δ; positivityfilter_upwards [flat_recital x.trot M hp.hM hp.hJ δ hδ,eventually_ge_atTop (2*p.r),pay_nat (a:=1/8) (b:=1/16) (num (Fin r)) (by norm_num)] with n hn ht hB N m hN Ylet w:= x.wit n; let v:= raw m Nhave hw : IsLaw w:= witLaw ha hp.hR htlet P (i : Fin r) (o : Orient p n N):=δ≤ |x.empirical Y o i - x.reference Y i|have hk (i : Fin r) : pr v (P i) ≤ bp (-(1/8:ℝ)*n) := bylet S (z) := ind (Y x.l x.q z=i)have hf z : |S z|≤1 := by unfold S; rw [abs_of_nonneg (ind_nonneg _)]; exact ind_le_one _refine hn m w x.q hw (normW_carried (subW_carried _ _))(scopedZ_bit p n _ _ _ hw) hN S hfhave he (o : Orient p n N) (h : x.apt∧¬x.close Y o ε) : ∃ i,P i o := byby_contra! hhapply h.2unfold close varOnecalc _ ≤ ∑ i : Fin r,δ:= Finset.sum_le_sum fun i _=>le_trans (abs_sub_comm ..).le(le_of_not_ge (hh i))_ ≤ ε := bysimp; unfold δcalc _ ≤ ((r:ℝ)+1)* (ε/(r+1:ℝ)) := mul_le_mul_of_nonneg_right (by linarith) hδ.le_ = ε := by field_simphave hv : IsLaw v:= raw_law m hNexact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz P)).trans(((Finset.sum_le_sum fun i _=>hk i).trans_eq (by simp [num])).trans hB)filter_upwards with n N m hN Ysimp_rw [show (x.apt)=False from eq_false ha,false_and,pr_false]; exact (bp_pos _).ledef foil (x : Appearance p) (Y : Silhouette p N r) (o : Orient p n N)(m : Mixer p n) (K : ℕ) (δ : ℝ) :=∀ (z:Digest p.g) (i:Fin r), z.feasible x.l x.f → z.sumBit=x.q →δ ≤ x.reference Y i → Template.patrol x.trot m (scopedScan p n x.l x.f z)(fun y => Y x.l x.q y=i) K x.q otheorem foilCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)(δ:ℝ) (hδ:0<δ) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,pr (raw m N) (fun i=>¬x.foil Y i m b.pins δ)≤bp (-(1/18:ℝ)*n) := byclassicalhave ht:=h.enter.firstlet A:= Digest p.g × Fin rlet Q n (m:Mixer p n) (Y:Silhouette p (M*n) r) (a : A) (o : Orient p n (M*n)) :=a.1.feasible x.l x.f ∧ a.1.sumBit=x.q ∧ δ≤x.reference Y a.2 ∧¬Template.patrol x.trot m (scopedScan p n x.l x.f a.1)(fun y=>Y x.l x.q y=a.2) b.pins x.q ohave hg (a:A) :∀ᶠ n:ℕ in atTop,let N:=M*n;∀ m:Mixer p n,2*num (Full p n)<(N:ℝ) →unaryGood m b.pins s0→∀ Y:Silhouette p N r,pr (raw m N) (Q n m Y a) ≤ bp (-(1/16:ℝ)*n) := byby_cases hf : a.1.feasible x.l x.f ∧ a.1.sumBit=x.q· filter_upwards [patrolled x.trot M ht.hM ht.hg ht.hJ a.1 hf.1 ht.hR δ hδ h.profilesh.gleaming] with n hn N m hN hM Yby_cases he : δ ≤ x.reference Y a.2· let S : AtomKey (p:=p) (x.trot.t ()) (M*n) →Prop := fun i=>Y x.l x.q i=a.2let v:=scopedScan p n (x.trot.t ()) (x.trot.f ()) a.1have hx : δ ≤ pr (lawOmega p (M*n) (x.trot.t ()) a.1.sumBit) S := byrw [hf.2]; exact hehave hh (i:Orient p n (M*n)) (h:Q n m Y a i) :¬Template.patrol x.trot m v S b.pins a.1.sumBit i := hf.2 ▸ h.2.2.2exact (pr_mono (raw_law m hN).nz hh).trans (hn m hM hN S hx)have hg : Q n m Y a=fun _=> False :=funext fun i=> eq_false (fun h=>he h.2.2.1)change pr (raw m (M*n)) (Q n m Y a) ≤ _rw [hg,pr_false]; exact (bp_pos _).lefilter_upwards with n N m hN hg Yhave hh : Q n m Y a=fun _=> False :=funext fun i=> eq_false (fun h=> hf ⟨h.1,h.2.1⟩)change pr (raw m (M*n)) (Q n m Y a) ≤ _rw [hh,pr_false]; exact (bp_pos _).lefilter_upwards [eventually_all.mpr hg,pay_nat (a:=1/16) (b:=1/18) (num A) (by norm_num)]with n hn hB N m hN hM Yhave he o (h : ¬x.foil Y o m b.pins δ) : ∃ i, Q n m Y i o := byunfold foil at hpush Not at hobtain ⟨z,i,h⟩:=hexact ⟨(z,i),h⟩let v:=raw m Nhave hv : IsLaw v:=raw_law m hNexact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz _)).trans(((Finset.sum_le_sum fun i _=>hn i m hN hM Y).trans_eq (by simp [num])).trans hB)end Appearancedef smoothSilk (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)(m:Mixer p n) (K:ℕ) (o:Orient p n N) :=∀ x : Appearance p,(x.apt → x.close Y o ε) ∧ x.foil Y o m K δvariable {s0 : ℕ}def gauze (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)(m:Mixer p n) (K:ℕ) (o:UnitType p n N) :=∀ i,smoothSilk p ε δ Y m K (onSide o i)private theorem silken (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)(ε δ : ℝ) (he:0<ε) (hd:0<δ) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,pr (raw m N) (fun i=>¬smoothSilk p ε δ Y m b.pins i)≤bp (-(1/20:ℝ)*n) := byclassicallet A:= Appearance pfilter_upwards [eventually_all.mpr (fun x:A=>x.foilCap r M h δ hd),eventually_all.mpr (fun x:A=>x.readCap r M h ε he),pay_nat (a:=1/18) (b:=1/20) (num A*2) (by norm_num)] with n hn ht hB N m hN hM Ylet v:=raw m Nhave hv : IsLaw v:=raw_law m hNlet P (x:A) (o:Orient p n N) :=(x.apt ∧ ¬x.close Y o ε)∨ ¬x.foil Y o m b.pins δhave hk x : pr v (P x) ≤ 2*bp (-(1/18:ℝ)*n) := byrw [two_mul]; apply (pr_or_le hv.nz).transrefine add_le_add ((ht x m hN Y).trans (bp_le ?_)) (hn x m hN hM Y)linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]have hi o (h : ¬smoothSilk p ε δ Y m b.pins o) : ∃ i, P i o := byunfold smoothSilk at hobtain ⟨i,h⟩:= Classical.not_forall.mp hexact ⟨i,by unfold P; tauto⟩refine ((pr_mono hv.nz hi).trans (pr_exists_le hv.nz _)).trans(((Finset.sum_le_sum fun i _=>hk i).trans_eq ?_).trans hB)simp [num,mul_assoc]theorem gauzeCalendar (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)(ε δ:ℝ) (he:0<ε) (hd:0<δ) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,∀ u : Wgt (UnitType p n N),PreparationParameters.Align b s0 p M n m u → ∀ Y: Silhouette p N r,pr u (fun i=>¬gauze p ε δ Y m b.pins i)≤bp (-(1/100:ℝ)*n) := byclassicalfilter_upwards [silken p r M h ε δ he hd,pay_nat (a:=1/20-1/32) (b:=1/100) 2(by norm_num)] with n hn ht N m u hu Ylet P (o:Orient p n N) := ¬smoothSilk p ε δ Y m b.pins olet Q (i:Bool) (o:UnitType p n N):=P (onSide o i)have hc : bySide p u m (bp ((1/32:ℝ)*n)) := fun i=> byhave hh:= hu.draincases i; exact hh.2.2.1; exact hh.2.1have hf : ∀ i,pr u (Q i) ≤bp (-((1/20:ℝ)-1/32)*n) := byintro ilet x := fun o:UnitType p n N=>onSide o ichange pr u (fun i=>P (x i)) ≤_rw [←mapW_pr]exact (pr_cap (hc i) P).trans ((mul_le_mul_of_nonneg_left(hn m hu.cols hu.hymn Y) (bp_pos _).le).trans_eq (by rw [←bp_add]; congr 1; ring))have he o (h : ¬gauze p ε δ Y m b.pins o) : ∃ i,Q i o := Classical.not_forall.mp hhave hv : IsLaw u:=hu.drain.1rw [two_mul] at htrefine ((pr_mono hv.nz he).trans ((pr_exists_le hv.nz _).trans ?_))rw [Fintype.sum_bool]; exact (add_le_add (hf _) (hf _)).trans htend StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177import OAI.Combinatorics.HadwigerCounterexample.SurrogateStatusLawsnamespace OAI/-! # Cell Positivity Scales -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix Functionopen scoped BigOperators Topologyvariable {p:Shape} {n N K M r : ℕ}namespace StatusAnalysisopen Templatevariable {b : PreparationParameters}namespace Appearancevariable (x : Appearance p) {s0 : ℕ}theorem readCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)(ε : ℝ) (hε : 0<ε) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →∀ Y : Silhouette p N r,pr (raw m N) (fun o=> x.apt∧¬ x.close Y o ε)≤bp (-(1/16:ℝ)*n) := byclassicalhave hp:=h.enter.firstby_cases ha : x.apt· let δ : ℝ := ε/(r+1:ℝ)have hδ : 0<δ:=by unfold δ; positivityfilter_upwards [flat_recital x.trot M hp.hM hp.hJ δ hδ,eventually_ge_atTop (2*p.r),pay_nat (a:=1/8) (b:=1/16) (num (Fin r)) (by norm_num)] with n hn ht hB N m hN Ylet w:= x.wit n; let v:= raw m Nhave hw : IsLaw w:= witLaw ha hp.hR htlet P (i : Fin r) (o : Orient p n N):=δ≤ |x.empirical Y o i - x.reference Y i|have hk (i : Fin r) : pr v (P i) ≤ bp (-(1/8:ℝ)*n) := bylet S (z) := ind (Y x.l x.q z=i)have hf z : |S z|≤1 := by unfold S; rw [abs_of_nonneg (ind_nonneg _)]; exact ind_le_one _refine hn m w x.q hw (normW_carried (subW_carried _ _))(scopedZ_bit p n _ _ _ hw) hN S hfhave he (o : Orient p n N) (h : x.apt∧¬x.close Y o ε) : ∃ i,P i o := byby_contra! hhapply h.2unfold close varOnecalc _ ≤ ∑ i : Fin r,δ:= Finset.sum_le_sum fun i _=>le_trans (abs_sub_comm ..).le(le_of_not_ge (hh i))_ ≤ ε := bysimp; unfold δcalc _ ≤ ((r:ℝ)+1)* (ε/(r+1:ℝ)) := mul_le_mul_of_nonneg_right (by linarith) hδ.le_ = ε := by field_simphave hv : IsLaw v:= raw_law m hNexact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz P)).trans(((Finset.sum_le_sum fun i _=>hk i).trans_eq (by simp [num])).trans hB)filter_upwards with n N m hN Ysimp_rw [show (x.apt)=False from eq_false ha,false_and,pr_false]; exact (bp_pos _).ledef foil (x : Appearance p) (Y : Silhouette p N r) (o : Orient p n N)(m : Mixer p n) (K : ℕ) (δ : ℝ) :=∀ (z:Digest p.g) (i:Fin r), z.feasible x.l x.f → z.sumBit=x.q →δ ≤ x.reference Y i → Template.patrol x.trot m (scopedScan p n x.l x.f z)(fun y => Y x.l x.q y=i) K x.q otheorem foilCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)(δ:ℝ) (hδ:0<δ) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,pr (raw m N) (fun i=>¬x.foil Y i m b.pins δ)≤bp (-(1/18:ℝ)*n) := byclassicalhave ht:=h.enter.firstlet A:= Digest p.g × Fin rlet Q n (m:Mixer p n) (Y:Silhouette p (M*n) r) (a : A) (o : Orient p n (M*n)) :=a.1.feasible x.l x.f ∧ a.1.sumBit=x.q ∧ δ≤x.reference Y a.2 ∧¬Template.patrol x.trot m (scopedScan p n x.l x.f a.1)(fun y=>Y x.l x.q y=a.2) b.pins x.q ohave hg (a:A) :∀ᶠ n:ℕ in atTop,let N:=M*n;∀ m:Mixer p n,2*num (Full p n)<(N:ℝ) →unaryGood m b.pins s0→∀ Y:Silhouette p N r,pr (raw m N) (Q n m Y a) ≤ bp (-(1/16:ℝ)*n) := byby_cases hf : a.1.feasible x.l x.f ∧ a.1.sumBit=x.q· filter_upwards [patrolled x.trot M ht.hM ht.hg ht.hJ a.1 hf.1 ht.hR δ hδ h.profilesh.gleaming] with n hn N m hN hM Yby_cases he : δ ≤ x.reference Y a.2· let S : AtomKey (p:=p) (x.trot.t ()) (M*n) →Prop := fun i=>Y x.l x.q i=a.2let v:=scopedScan p n (x.trot.t ()) (x.trot.f ()) a.1have hx : δ ≤ pr (lawOmega p (M*n) (x.trot.t ()) a.1.sumBit) S := byrw [hf.2]; exact hehave hh (i:Orient p n (M*n)) (h:Q n m Y a i) :¬Template.patrol x.trot m v S b.pins a.1.sumBit i := hf.2 ▸ h.2.2.2exact (pr_mono (raw_law m hN).nz hh).trans (hn m hM hN S hx)have hg : Q n m Y a=fun _=> False :=funext fun i=> eq_false (fun h=>he h.2.2.1)change pr (raw m (M*n)) (Q n m Y a) ≤ _rw [hg,pr_false]; exact (bp_pos _).lefilter_upwards with n N m hN hg Yhave hh : Q n m Y a=fun _=> False :=funext fun i=> eq_false (fun h=> hf ⟨h.1,h.2.1⟩)change pr (raw m (M*n)) (Q n m Y a) ≤ _rw [hh,pr_false]; exact (bp_pos _).lefilter_upwards [eventually_all.mpr hg,pay_nat (a:=1/16) (b:=1/18) (num A) (by norm_num)]with n hn hB N m hN hM Yhave he o (h : ¬x.foil Y o m b.pins δ) : ∃ i, Q n m Y i o := byunfold foil at hpush Not at hobtain ⟨z,i,h⟩:=hexact ⟨(z,i),h⟩let v:=raw m Nhave hv : IsLaw v:=raw_law m hNexact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz _)).trans(((Finset.sum_le_sum fun i _=>hn i m hN hM Y).trans_eq (by simp [num])).trans hB)end Appearancedef smoothSilk (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)(m:Mixer p n) (K:ℕ) (o:Orient p n N) :=∀ x : Appearance p,(x.apt → x.close Y o ε) ∧ x.foil Y o m K δvariable {s0 : ℕ}def gauze (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)(m:Mixer p n) (K:ℕ) (o:UnitType p n N) :=∀ i,smoothSilk p ε δ Y m K (onSide o i)private theorem silken (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)(ε δ : ℝ) (he:0<ε) (hd:0<δ) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,pr (raw m N) (fun i=>¬smoothSilk p ε δ Y m b.pins i)≤bp (-(1/20:ℝ)*n) := byclassicallet A:= Appearance pfilter_upwards [eventually_all.mpr (fun x:A=>x.foilCap r M h δ hd),eventually_all.mpr (fun x:A=>x.readCap r M h ε he),pay_nat (a:=1/18) (b:=1/20) (num A*2) (by norm_num)] with n hn ht hB N m hN hM Ylet v:=raw m Nhave hv : IsLaw v:=raw_law m hNlet P (x:A) (o:Orient p n N) :=(x.apt ∧ ¬x.close Y o ε)∨ ¬x.foil Y o m b.pins δhave hk x : pr v (P x) ≤ 2*bp (-(1/18:ℝ)*n) := byrw [two_mul]; apply (pr_or_le hv.nz).transrefine add_le_add ((ht x m hN Y).trans (bp_le ?_)) (hn x m hN hM Y)linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]have hi o (h : ¬smoothSilk p ε δ Y m b.pins o) : ∃ i, P i o := byunfold smoothSilk at hobtain ⟨i,h⟩:= Classical.not_forall.mp hexact ⟨i,by unfold P; tauto⟩refine ((pr_mono hv.nz hi).trans (pr_exists_le hv.nz _)).trans(((Finset.sum_le_sum fun i _=>hk i).trans_eq ?_).trans hB)simp [num,mul_assoc]theorem gauzeCalendar (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)(ε δ:ℝ) (he:0<ε) (hd:0<δ) :∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,∀ u : Wgt (UnitType p n N),PreparationParameters.Align b s0 p M n m u → ∀ Y: Silhouette p N r,pr u (fun i=>¬gauze p ε δ Y m b.pins i)≤bp (-(1/100:ℝ)*n) := byclassicalfilter_upwards [silken p r M h ε δ he hd,pay_nat (a:=1/20-1/32) (b:=1/100) 2(by norm_num)] with n hn ht N m u hu Ylet P (o:Orient p n N) := ¬smoothSilk p ε δ Y m b.pins olet Q (i:Bool) (o:UnitType p n N):=P (onSide o i)have hc : bySide p u m (bp ((1/32:ℝ)*n)) := fun i=> byhave hh:= hu.draincases i; exact hh.2.2.1; exact hh.2.1have hf : ∀ i,pr u (Q i) ≤bp (-((1/20:ℝ)-1/32)*n) := byintro ilet x := fun o:UnitType p n N=>onSide o ichange pr u (fun i=>P (x i)) ≤_rw [←mapW_pr]exact (pr_cap (hc i) P).trans ((mul_le_mul_of_nonneg_left(hn m hu.cols hu.hymn Y) (bp_pos _).le).trans_eq (by rw [←bp_add]; congr 1; ring))have he o (h : ¬gauze p ε δ Y m b.pins o) : ∃ i,Q i o := Classical.not_forall.mp hhave hv : IsLaw u:=hu.drain.1rw [two_mul] at htrefine ((pr_mono hv.nz he).trans ((pr_exists_le hv.nz _).trans ?_))rw [Fintype.sum_bool]; exact (add_le_add (hf _) (hf _)).trans htend StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioningimport OAI.Combinatorics.HadwigerCounterexample.ConditionalProductLawsnamespace OAI/-! # Cell Pruning -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Finsetvariable {A B I J : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J]theorem sum_pr_tag (w : Wgt A) (P : A → Prop) (f : A→I) :∑ i:I,pr w (fun x => P x ∧ f x=i) = pr w P := byclassicalunfold prrw [← avg_sum]refine avg_congr fun x _ => ?_simp only [ind_and, ← Finset.mul_sum]rw [Finset.sum_eq_single (f x)]· rw [ind_one rfl,mul_one]· intro j _ hj; exact ind_zero hj.symmsimp/-- implication needed only almost surely for finite measures. -/theorem pr_on_mono {w : Wgt A} (hw : ∀ x,0≤w x) {P Q : A→Prop}(h : ∀ x,w x≠0→ P x→ Q x) : pr w P ≤ pr w Q :=Finset.sum_le_sum (fun x _ => byby_cases he : w x=0· simp [he]exact mul_le_mul_of_nonneg_left (ind_mono (h x he)) (hw x))theorem sum_pr_cells (w : Wgt (A × B)) (P : A × B → Prop) (f : A→I) (g : B→J) :∑ i:I,∑ j:J,pr w (fun x => P x ∧ f x.1=i ∧ g x.2=j) = pr w P := byclassicalrw [← sum_pr_tag w P (fun x => (f x.1,g x.2)), Fintype.sum_prod_type]simp only [Prod.mk.injEq]/-- restore the full pair-event probability in a specified cell. -/theorem pair_restore (u : Wgt A) (v : Wgt B) (P : A → Prop) (Q : B → Prop)(hP : 0 < pr u P) (hQ : 0 < pr v Q)(c : A × B → Prop) :pr (pairW u v) (fun x => P x.1 ∧ Q x.2 ∧ c x)=pr u P * pr v Q * pr (pairW (onW u P) (onW v Q)) c := byclassicallet D := pr u P * pr v Qlet d := pairW (onW u P) (onW v Q)change avg _ _ = D*avg d _unfold avgrw [Finset.mul_sum]refine Finset.sum_congr rfl fun i _ => ?_simp only [pairW,d,onW_val,D,ind_and]field_simpdef memberC (p : A→Prop) (f : A→I) (i : I) (x : A) := p x ∧ f x=i/-- heavy cells criterion. Loss charged to τ times opposite massrather than τ alone (key q fixed). -/theorem prune_pairs (w : Wgt A) (v : Wgt B) (hw : SubLaw w) (hv : SubLaw v)(P : A → Prop) (Q : B→Prop) (f : A→I) (g : B→J)(C : A×B→Prop) (H T : ℝ) (hH : 0≤H) (hT : 0<T){L : ℝ} (hi : (Fintype.card I : ℝ) ≤ L)(hj : (Fintype.card J : ℝ) ≤ L)(h : ∀ i j,T ≤ pr w (memberC P f i) → T ≤ pr v (memberC Q g j) →H≤ pr (pairW (onW w (memberC P f i)) (onW v (memberC Q g j))) C) :H * (pr w P * pr v Q) ≤ pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) +(H*T*L)*(pr w P+pr v Q) := byclassicallet a (i:I) := pr w (memberC P f i)let b (i:J) := pr v (memberC Q g i)let d (i:I) (j:J) := pr (pairW w v) (fun x => memberC P f i x.1 ∧ memberC Q g j x.2 ∧ C x)have ha i : 0≤a i := pr_nonneg hw.nzhave hb i : 0≤b i := pr_nonneg hv.nzhave he i j : H*(a i*b j) ≤ d i j+ H*T*b j + H*T*a i := byhave hz : 0≤ d i j := pr_nonneg (subLaw_pair hw hv).nzhave ha' := mul_nonneg (mul_nonneg hH hT.le) (ha i)have hb' := mul_nonneg (mul_nonneg hH hT.le) (hb j)by_cases ht : T ≤ a i· by_cases hh : T ≤ b j· have hc := mul_le_mul_of_nonneg_right (h i j ht hh) (mul_nonneg (ha i) (hb j))have h1 := pair_restore w v _ _ (lt_of_lt_of_le hT ht) (lt_of_lt_of_le hT hh) Crefine hc.trans ?_rw [mul_comm (pr _ C)]change _ ≤ d i j + _ + _unfold drw [h1]change _ ≤ a i*b j * _ + _+_linarith· have hg := mul_le_mul_of_nonneg_left (le_of_not_ge hh) (mul_nonneg hH (ha i))calc H*(a i*b j) ≤ H*T*a i := by linarith only [hg]_ ≤ _ := by linarith only [hb',hz]have hg := mul_le_mul_of_nonneg_left (le_of_not_ge ht) (mul_nonneg hH (hb j))calc H*(a i*b j) ≤ H*T*b j := by linarith only [hg]_ ≤ _ := by linarith only [ha',hz]have hA : pr w P=∑ i,a i := (sum_pr_tag w P f).symmhave hB : pr v Q=∑ j,b j := (sum_pr_tag v Q g).symmhave hC :pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) = ∑ i,∑ j,d i j := byrw [← sum_pr_cells (pairW w v) _ f g]refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_unfold d; congr 1; unfold memberC; ext; tautohave h1 : H * (pr w P * pr v Q)=∑ i,∑ j,H*(a i*b j) := byrw [hA,hB]simp only [Finset.sum_mul,Finset.mul_sum]exact Finset.sum_comm;have h2 : ∑ i:I,∑ j:J,H*T*b j=(Fintype.card I:ℝ)*(H*T*pr v Q) := bysimp only [← Finset.mul_sum,←hB,Finset.sum_const, Finset.card_univ, nsmul_eq_mul]ringhave h3 : ∑ i:I,∑ j:J,H*T*a i=(Fintype.card J:ℝ)*(H*T*pr w P) := byrw [Finset.sum_comm]simp only [← Finset.mul_sum,←hA,Finset.sum_const,Finset.card_univ,nsmul_eq_mul]ringrw [h1]refine (Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => he i j).trans ?_simp only [Finset.sum_add_distrib]rw [h2,h3,← hC]have hh := mul_le_mul_of_nonneg_right hj (show 0≤H*T*pr w P frommul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hw.nz))have hh' := mul_le_mul_of_nonneg_right hi (show 0≤H*T*pr v Q frommul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hv.nz))linarith only [hh,hh']end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioningimport OAI.Combinatorics.HadwigerCounterexample.ConditionalProductLawsnamespace OAI/-! # Cell Pruning -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Finsetvariable {A B I J : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J]theorem sum_pr_tag (w : Wgt A) (P : A → Prop) (f : A→I) :∑ i:I,pr w (fun x => P x ∧ f x=i) = pr w P := byclassicalunfold prrw [← avg_sum]refine avg_congr fun x _ => ?_simp only [ind_and, ← Finset.mul_sum]rw [Finset.sum_eq_single (f x)]· rw [ind_one rfl,mul_one]· intro j _ hj; exact ind_zero hj.symmsimp/-- implication needed only almost surely for finite measures. -/theorem pr_on_mono {w : Wgt A} (hw : ∀ x,0≤w x) {P Q : A→Prop}(h : ∀ x,w x≠0→ P x→ Q x) : pr w P ≤ pr w Q :=Finset.sum_le_sum (fun x _ => byby_cases he : w x=0· simp [he]exact mul_le_mul_of_nonneg_left (ind_mono (h x he)) (hw x))theorem sum_pr_cells (w : Wgt (A × B)) (P : A × B → Prop) (f : A→I) (g : B→J) :∑ i:I,∑ j:J,pr w (fun x => P x ∧ f x.1=i ∧ g x.2=j) = pr w P := byclassicalrw [← sum_pr_tag w P (fun x => (f x.1,g x.2)), Fintype.sum_prod_type]simp only [Prod.mk.injEq]/-- restore the full pair-event probability in a specified cell. -/theorem pair_restore (u : Wgt A) (v : Wgt B) (P : A → Prop) (Q : B → Prop)(hP : 0 < pr u P) (hQ : 0 < pr v Q)(c : A × B → Prop) :pr (pairW u v) (fun x => P x.1 ∧ Q x.2 ∧ c x)=pr u P * pr v Q * pr (pairW (onW u P) (onW v Q)) c := byclassicallet D := pr u P * pr v Qlet d := pairW (onW u P) (onW v Q)change avg _ _ = D*avg d _unfold avgrw [Finset.mul_sum]refine Finset.sum_congr rfl fun i _ => ?_simp only [pairW,d,onW_val,D,ind_and]field_simpdef memberC (p : A→Prop) (f : A→I) (i : I) (x : A) := p x ∧ f x=i/-- heavy cells criterion. Loss charged to τ times opposite massrather than τ alone (key q fixed). -/theorem prune_pairs (w : Wgt A) (v : Wgt B) (hw : SubLaw w) (hv : SubLaw v)(P : A → Prop) (Q : B→Prop) (f : A→I) (g : B→J)(C : A×B→Prop) (H T : ℝ) (hH : 0≤H) (hT : 0<T){L : ℝ} (hi : (Fintype.card I : ℝ) ≤ L)(hj : (Fintype.card J : ℝ) ≤ L)(h : ∀ i j,T ≤ pr w (memberC P f i) → T ≤ pr v (memberC Q g j) →H≤ pr (pairW (onW w (memberC P f i)) (onW v (memberC Q g j))) C) :H * (pr w P * pr v Q) ≤ pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) +(H*T*L)*(pr w P+pr v Q) := byclassicallet a (i:I) := pr w (memberC P f i)let b (i:J) := pr v (memberC Q g i)let d (i:I) (j:J) := pr (pairW w v) (fun x => memberC P f i x.1 ∧ memberC Q g j x.2 ∧ C x)have ha i : 0≤a i := pr_nonneg hw.nzhave hb i : 0≤b i := pr_nonneg hv.nzhave he i j : H*(a i*b j) ≤ d i j+ H*T*b j + H*T*a i := byhave hz : 0≤ d i j := pr_nonneg (subLaw_pair hw hv).nzhave ha' := mul_nonneg (mul_nonneg hH hT.le) (ha i)have hb' := mul_nonneg (mul_nonneg hH hT.le) (hb j)by_cases ht : T ≤ a i· by_cases hh : T ≤ b j· have hc := mul_le_mul_of_nonneg_right (h i j ht hh) (mul_nonneg (ha i) (hb j))have h1 := pair_restore w v _ _ (lt_of_lt_of_le hT ht) (lt_of_lt_of_le hT hh) Crefine hc.trans ?_rw [mul_comm (pr _ C)]change _ ≤ d i j + _ + _unfold drw [h1]change _ ≤ a i*b j * _ + _+_linarith· have hg := mul_le_mul_of_nonneg_left (le_of_not_ge hh) (mul_nonneg hH (ha i))calc H*(a i*b j) ≤ H*T*a i := by linarith only [hg]_ ≤ _ := by linarith only [hb',hz]have hg := mul_le_mul_of_nonneg_left (le_of_not_ge ht) (mul_nonneg hH (hb j))calc H*(a i*b j) ≤ H*T*b j := by linarith only [hg]_ ≤ _ := by linarith only [ha',hz]have hA : pr w P=∑ i,a i := (sum_pr_tag w P f).symmhave hB : pr v Q=∑ j,b j := (sum_pr_tag v Q g).symmhave hC :pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) = ∑ i,∑ j,d i j := byrw [← sum_pr_cells (pairW w v) _ f g]refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_unfold d; congr 1; unfold memberC; ext; tautohave h1 : H * (pr w P * pr v Q)=∑ i,∑ j,H*(a i*b j) := byrw [hA,hB]simp only [Finset.sum_mul,Finset.mul_sum]exact Finset.sum_comm;have h2 : ∑ i:I,∑ j:J,H*T*b j=(Fintype.card I:ℝ)*(H*T*pr v Q) := bysimp only [← Finset.mul_sum,←hB,Finset.sum_const, Finset.card_univ, nsmul_eq_mul]ringhave h3 : ∑ i:I,∑ j:J,H*T*a i=(Fintype.card J:ℝ)*(H*T*pr w P) := byrw [Finset.sum_comm]simp only [← Finset.mul_sum,←hA,Finset.sum_const,Finset.card_univ,nsmul_eq_mul]ringrw [h1]refine (Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => he i j).trans ?_simp only [Finset.sum_add_distrib]rw [h2,h3,← hC]have hh := mul_le_mul_of_nonneg_right hj (show 0≤H*T*pr w P frommul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hw.nz))have hh' := mul_le_mul_of_nonneg_right hi (show 0≤H*T*pr v Q frommul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hv.nz))linarith only [hh,hh']end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144import OAI.Combinatorics.HadwigerCounterexample.BilinearCompressionnamespace OAI/-! # Channel Factorization -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Submodule Moduleopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}variable {I J : Type} [Fintype I] [Fintype J]/-- Pairing rank after imposing orthogonality constraints. -/theorem biorth_exists (S T : Space (Vec I)) (r : ℕ)(h : r+dim S+dim T≤Fintype.card I) :∃ A B : Mat I (Fin r), colSp A≤ annih S ∧ colSp B≤ annih T ∧ Aᵀ*B=1 := byclassicallet V := annih Slet W := annih Tlet M := (pack V)ᵀ * pack Wlet t := M.rankhave ht : r≤t := byhave h1 := rank_ge_mul (pack V)ᵀ (pack W)rw [Matrix.rank_transpose,mrk_inj.mp (pack_inj V),mrk_inj.mp (pack_inj W),Fintype.card_fin,Fintype.card_fin] at h1have h2 : dim S+dim V=Fintype.card I := annih_dim Shave h3 : dim T+dim W=Fintype.card I := annih_dim Thave he (a b c d t r e : ℕ) (h : r+a+b ≤ e) (hx : a+c=e) (hy : b+d=e) (ht : c+d≤t+e) :r≤t := by omegaexact he _ _ _ _ _ _ _ h h2 h3 h1obtain ⟨A,B,hA,hB,hM⟩ := rank_product Mobtain ⟨L,hL⟩ := mat_left_inv hAobtain ⟨R,hR⟩ := mat_left_inv (P:=Bᵀ) (transpose_surj_iff.mp (by rw [Matrix.transpose_transpose]; exact hB))let E := embedMat (Fin.castLE ht)refine ⟨pack V * (Lᵀ * E),pack W*(Rᵀ*E),?_,?_,?_⟩· rintro x ⟨x,rfl⟩rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]exact (pack_mem_iff ..).mpr ⟨_,rfl⟩· rintro x ⟨x,rfl⟩rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]exact (pack_mem_iff ..).mpr ⟨_,rfl⟩have he : L*M*Rᵀ=1 := byhave hg : B*Rᵀ=1 := bysimpa only [Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.transpose_one] usingcongrArg Matrix.transpose hRrefine (congrArg (fun X => L*X*Rᵀ) hM).symm.trans ?_rw [← Matrix.mul_assoc L,hL,Matrix.one_mul,hg]have heq : Eᵀ * E=1 := embedMat_self (Fin.castLE_injective ht)rw [Matrix.transpose_mul,Matrix.transpose_mul,Matrix.transpose_transpose]calc _ = Eᵀ*(L*M*Rᵀ)*E := by simp only [M,Matrix.mul_assoc]_ = _ := by rw [he,Matrix.mul_one,heq]/-- split desired respective bounded-rank bilinear form -/theorem pure_chan_split (M : Mat J J) (S T : Space (Vec I)) (X Y : Space (Vec J))(h : M∈box (annih X) (annih Y)) (ht : M.rank+dim S+dim T ≤ Fintype.card I) :∃ A ∈ box (annih S) (annih X),∃ B∈box (annih T) (annih Y), Aᵀ * B=M := byclassicalobtain ⟨P,Q,hP,hQ,hM⟩ := rank_product Mobtain ⟨A,B,hA,hB,he⟩ := biorth_exists S T M.rank htobtain ⟨hx,hy⟩ := box_kill.mp hrefine ⟨A * Pᵀ,?_,B*Q,?_,?_⟩· rw [box_kill]constructor· intro x hx; rw [Matrix.transpose_mul,← Matrix.mulVec_mulVec,(colSp_kill ..).mp hA x hx,Matrix.mulVec_zero]intro x hvhave hv' : Pᵀ *ᵥ x=0 := byhave hqi := (transpose_surj_iff (P:=Qᵀ)).mp (by rw [Matrix.transpose_transpose]; exact hQ)apply hqirw [Matrix.mulVec_mulVec,← Matrix.transpose_mul,hM,hx x hv,Matrix.mulVec_zero]rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]· rw [box_kill]constructor· intro x hv; rw [Matrix.transpose_mul,←Matrix.mulVec_mulVec,(colSp_kill ..).mp hB x hv,Matrix.mulVec_zero]intro y hvhave hv' : Q *ᵥ y=0 := byapply hPrw [Matrix.mulVec_mulVec,hM,hy y hv,mulVec_zero]rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]· rw [Matrix.transpose_mul,Matrix.transpose_transpose,← Matrix.mul_assoc _ B, Matrix.mul_assoc P,he,Matrix.mul_one,hM]/-- The final channel change for fixed B endpoint. -/theorem chan_factor {f b : Plan p n} {P : PureForms p n} {C : ChanOut p n} {j : Bool}(H T K : ℕ) (hc : outSmall H C) (hK : ∀ z,dim (hPin b z j)≤K)(hh : T+2*(K+2*H)≤p.h)(hP : P∈pureSpace p f) (ht : ∀ e,(P e).rank≤T) :∃ D∈deltaSpace p f b j,obsPair p (chanInner p (C+D) (C+D))=obsPair p (chanInner p C C)+obsPair p P := byclassicallet S (z : Place p) := hPin b (flipZ p z) j ⊔ priOut p C (flipZ p z)have h (z : Place p) : dim (S z) ≤ K+2*H :=(Submodule.finrank_add_le_finrank_add_finrank ..).trans(add_le_add (hK _) (dim_priOut hc _))choose A hA B hB hQ using fun e : Comp p.g =>pure_chan_split (P e) (S (e,true)) (S (e,false)) (f (e,true)) (f (e,false))((pureSpace_mem _).mp hP e) ((add_le_add(add_le_add (ht e) (h (e,true))) (h (e,false))).trans(byrw [Fintype.card_fin]rwa [two_mul, ← add_assoc] at hh))let D : ChanOut p n := fun z => if z.2 then A z.1 else B z.1have h1 (z : Place p) : D z∈box (annih (S z)) (annih (f z)) := bycases z with | mk e c => cases c; exact hB e; exact hA erefine ⟨D,(deltaSpace_mem _).mpr ?_,?_⟩· intro zrefine box_le ?_ le_rfl (h1 z)intro x hxrw [annih_mem]exact fun y hy => (annih_mem ..).mp hx y (Submodule.mem_sup_left hy)have hg : chanInner p D D=P := funext (fun e => hQ e)have he (z : Place p) (i l : Bool) (x y : Ray p n) :dotProduct ((C (flipZ p z)*IP p n i) *ᵥ x) ((D z*IP p n l)*ᵥ y)=0 := byhave hq : ((C (flipZ p z)*IP p n i) *ᵥ x) ∈ S z :=Submodule.mem_sup_right (le_priOut C _ i ⟨x,rfl⟩)have hl : ((D z * IP p n l)*ᵥ y) ∈ annih (S z) := byrw [←Matrix.mulVec_mulVec]exact ((box_mem ..).mp (h1 z)).1 ⟨_,rfl⟩rw [dotProduct_comm]exact (annih_mem ..).mp hl _ hqhave hd : obsPair p (chanDeriv p C D)=0 := byrw [←obsI_each]have hz : eachF p (chanDeriv p C D)=0 := byunfold chanDeriv; rw [map_add]funext i erw [Pi.add_apply,Pi.add_apply,each_chan_val,each_chan_val]refine evmat_ext fun x y => ?_rw [evmat_addM,ev_duom,ev_duom]have hh1 := he (e,false) i i x yhave hh2 := he (e,true) i i y xsimp only [flipZ,Bool.not_false,Bool.not_true] at hh1 hh2rw [hh1,dotProduct_comm ((D (e,true) * IP p n i) *ᵥ _),hh2]simp [evmat]rw [hz,map_zero]rw [obsPair_chan_change,hd,add_zero,hg]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144import OAI.Combinatorics.HadwigerCounterexample.BilinearCompressionnamespace OAI/-! # Channel Factorization -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Submodule Moduleopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}variable {I J : Type} [Fintype I] [Fintype J]/-- Pairing rank after imposing orthogonality constraints. -/theorem biorth_exists (S T : Space (Vec I)) (r : ℕ)(h : r+dim S+dim T≤Fintype.card I) :∃ A B : Mat I (Fin r), colSp A≤ annih S ∧ colSp B≤ annih T ∧ Aᵀ*B=1 := byclassicallet V := annih Slet W := annih Tlet M := (pack V)ᵀ * pack Wlet t := M.rankhave ht : r≤t := byhave h1 := rank_ge_mul (pack V)ᵀ (pack W)rw [Matrix.rank_transpose,mrk_inj.mp (pack_inj V),mrk_inj.mp (pack_inj W),Fintype.card_fin,Fintype.card_fin] at h1have h2 : dim S+dim V=Fintype.card I := annih_dim Shave h3 : dim T+dim W=Fintype.card I := annih_dim Thave he (a b c d t r e : ℕ) (h : r+a+b ≤ e) (hx : a+c=e) (hy : b+d=e) (ht : c+d≤t+e) :r≤t := by omegaexact he _ _ _ _ _ _ _ h h2 h3 h1obtain ⟨A,B,hA,hB,hM⟩ := rank_product Mobtain ⟨L,hL⟩ := mat_left_inv hAobtain ⟨R,hR⟩ := mat_left_inv (P:=Bᵀ) (transpose_surj_iff.mp (by rw [Matrix.transpose_transpose]; exact hB))let E := embedMat (Fin.castLE ht)refine ⟨pack V * (Lᵀ * E),pack W*(Rᵀ*E),?_,?_,?_⟩· rintro x ⟨x,rfl⟩rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]exact (pack_mem_iff ..).mpr ⟨_,rfl⟩· rintro x ⟨x,rfl⟩rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]exact (pack_mem_iff ..).mpr ⟨_,rfl⟩have he : L*M*Rᵀ=1 := byhave hg : B*Rᵀ=1 := bysimpa only [Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.transpose_one] usingcongrArg Matrix.transpose hRrefine (congrArg (fun X => L*X*Rᵀ) hM).symm.trans ?_rw [← Matrix.mul_assoc L,hL,Matrix.one_mul,hg]have heq : Eᵀ * E=1 := embedMat_self (Fin.castLE_injective ht)rw [Matrix.transpose_mul,Matrix.transpose_mul,Matrix.transpose_transpose]calc _ = Eᵀ*(L*M*Rᵀ)*E := by simp only [M,Matrix.mul_assoc]_ = _ := by rw [he,Matrix.mul_one,heq]/-- split desired respective bounded-rank bilinear form -/theorem pure_chan_split (M : Mat J J) (S T : Space (Vec I)) (X Y : Space (Vec J))(h : M∈box (annih X) (annih Y)) (ht : M.rank+dim S+dim T ≤ Fintype.card I) :∃ A ∈ box (annih S) (annih X),∃ B∈box (annih T) (annih Y), Aᵀ * B=M := byclassicalobtain ⟨P,Q,hP,hQ,hM⟩ := rank_product Mobtain ⟨A,B,hA,hB,he⟩ := biorth_exists S T M.rank htobtain ⟨hx,hy⟩ := box_kill.mp hrefine ⟨A * Pᵀ,?_,B*Q,?_,?_⟩· rw [box_kill]constructor· intro x hx; rw [Matrix.transpose_mul,← Matrix.mulVec_mulVec,(colSp_kill ..).mp hA x hx,Matrix.mulVec_zero]intro x hvhave hv' : Pᵀ *ᵥ x=0 := byhave hqi := (transpose_surj_iff (P:=Qᵀ)).mp (by rw [Matrix.transpose_transpose]; exact hQ)apply hqirw [Matrix.mulVec_mulVec,← Matrix.transpose_mul,hM,hx x hv,Matrix.mulVec_zero]rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]· rw [box_kill]constructor· intro x hv; rw [Matrix.transpose_mul,←Matrix.mulVec_mulVec,(colSp_kill ..).mp hB x hv,Matrix.mulVec_zero]intro y hvhave hv' : Q *ᵥ y=0 := byapply hPrw [Matrix.mulVec_mulVec,hM,hy y hv,mulVec_zero]rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]· rw [Matrix.transpose_mul,Matrix.transpose_transpose,← Matrix.mul_assoc _ B, Matrix.mul_assoc P,he,Matrix.mul_one,hM]/-- The final channel change for fixed B endpoint. -/theorem chan_factor {f b : Plan p n} {P : PureForms p n} {C : ChanOut p n} {j : Bool}(H T K : ℕ) (hc : outSmall H C) (hK : ∀ z,dim (hPin b z j)≤K)(hh : T+2*(K+2*H)≤p.h)(hP : P∈pureSpace p f) (ht : ∀ e,(P e).rank≤T) :∃ D∈deltaSpace p f b j,obsPair p (chanInner p (C+D) (C+D))=obsPair p (chanInner p C C)+obsPair p P := byclassicallet S (z : Place p) := hPin b (flipZ p z) j ⊔ priOut p C (flipZ p z)have h (z : Place p) : dim (S z) ≤ K+2*H :=(Submodule.finrank_add_le_finrank_add_finrank ..).trans(add_le_add (hK _) (dim_priOut hc _))choose A hA B hB hQ using fun e : Comp p.g =>pure_chan_split (P e) (S (e,true)) (S (e,false)) (f (e,true)) (f (e,false))((pureSpace_mem _).mp hP e) ((add_le_add(add_le_add (ht e) (h (e,true))) (h (e,false))).trans(byrw [Fintype.card_fin]rwa [two_mul, ← add_assoc] at hh))let D : ChanOut p n := fun z => if z.2 then A z.1 else B z.1have h1 (z : Place p) : D z∈box (annih (S z)) (annih (f z)) := bycases z with | mk e c => cases c; exact hB e; exact hA erefine ⟨D,(deltaSpace_mem _).mpr ?_,?_⟩· intro zrefine box_le ?_ le_rfl (h1 z)intro x hxrw [annih_mem]exact fun y hy => (annih_mem ..).mp hx y (Submodule.mem_sup_left hy)have hg : chanInner p D D=P := funext (fun e => hQ e)have he (z : Place p) (i l : Bool) (x y : Ray p n) :dotProduct ((C (flipZ p z)*IP p n i) *ᵥ x) ((D z*IP p n l)*ᵥ y)=0 := byhave hq : ((C (flipZ p z)*IP p n i) *ᵥ x) ∈ S z :=Submodule.mem_sup_right (le_priOut C _ i ⟨x,rfl⟩)have hl : ((D z * IP p n l)*ᵥ y) ∈ annih (S z) := byrw [←Matrix.mulVec_mulVec]exact ((box_mem ..).mp (h1 z)).1 ⟨_,rfl⟩rw [dotProduct_comm]exact (annih_mem ..).mp hl _ hqhave hd : obsPair p (chanDeriv p C D)=0 := byrw [←obsI_each]have hz : eachF p (chanDeriv p C D)=0 := byunfold chanDeriv; rw [map_add]funext i erw [Pi.add_apply,Pi.add_apply,each_chan_val,each_chan_val]refine evmat_ext fun x y => ?_rw [evmat_addM,ev_duom,ev_duom]have hh1 := he (e,false) i i x yhave hh2 := he (e,true) i i y xsimp only [flipZ,Bool.not_false,Bool.not_true] at hh1 hh2rw [hh1,dotProduct_comm ((D (e,true) * IP p n i) *ᵥ _),hh2]simp [evmat]rw [hz,map_zero]rw [obsPair_chan_change,hd,add_zero,hg]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186import OAI.Combinatorics.HadwigerCounterexample.SumRankBoundsnamespace OAI/-! # Channel Frame Laws -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Module Submodule Finset Functionopen scoped BigOperatorsvariable {A B : Type} [Fintype A] [Fintype B]theorem map_pair_law {C D : Type} [Fintype C] [Fintype D](w : Wgt A) (v : Wgt B) (f : A→C) (g : B→D) :mapW (pairW w v) (Prod.map f g)=pairW (mapW w f) (mapW v g) := byfunext xunfold mapW pairWsimp only [Prod.ext_iff]exact pairW_pr w v (fun y => f y=x.1) (fun y => g y=x.2)theorem mapW_nested {C : Type} (w : Wgt A) (f : A→B) (g : B→C) :mapW (mapW w f) g=mapW w (g ∘ f) :=funext fun _ => mapW_pr _ _ _omit [Fintype B] intheorem mapW_repeat {I : Type} [Fintype I] [DecidableEq I](w : I→ Wgt A) (f : I→ A→B) :mapW (prodW w) (fun x i => f i (x i))=prodW (fun i => mapW (w i) (f i)) := byfunext xunfold mapWsimp_rw [funext_iff]exact prodW_pr _ (fun i y => f i y=x i)omit [Fintype B] intheorem mapW_pr_eq (e : A≃A) (f : A→B) (u : B≃B) (h : ∀ x,f (e x)=u (f x))(w : Wgt A) (hw : ∀ x, w (e x)=w x) (x : B) : mapW w f (u x)=mapW w f x := byhave he := avg_bij e w (fun y => ind (f y=u x))simp_rw [hw,h,u.injective.eq_iff] at heexact he.symmprivate theorem pmax_test {x : A} (p : A → Prop) {w : Wgt A} (hw : SubLaw w)(h : ∀ y, p y → w y=w x) {m : ℝ} (hm : 0 < m)(hp : m ≤ pr unif p) [Nonempty A] :w x ≤ m⁻¹ * unif x := byhave hh : pr w p=w x*nbr p := bysimp only [pr,avg,nbr,tot,Finset.mul_sum]refine Finset.sum_congr rfl fun i _ => ?_by_cases he : p i· rw [h i he]rw [ind_zero he,mul_zero,mul_zero]have h1 := (pr_le_tot (p:=p) hw.nz).trans hw.totalrw [hh] at h1have hU : 0 < (Fintype.card A : ℝ) := by exact_mod_cast Fintype.card_posrw [pr_unif (A:=A)] at hphave hi := (le_div_iff₀ hU).mp hprw [unif_apply]field_simpnlinarith only [h1,hi,mul_le_mul_of_nonneg_left hi (hw.nz x)]theorem gram_norm_quarter {I J L : Type} [Fintype I] [Fintype J] [Fintype L][DecidableEq I] [DecidableEq J] [DecidableEq L] (G : Mat I J)(h : num I + num J-num L ≤ -1) :bp (-num I * num J)/4 ≤ pr unif (gramGood (U:=L) G) := byhave hn := (gram_norm G (by linarith : num I+num J≤num L)).2rw [pair_unif]refine le_trans ?_ hnhave he {x : ℝ} (hx : x ≤ -1) : (1/2 : ℝ)≤ 1-bp x := byhave ht := bp_le hxrw [bp_neg,bp_one] at htlinarith only [ht]let d := bp (-num I*num J)change d/4 ≤ d* _ * _have hk : 0 < d := bp_pos _have h1 := he (x:= num I-num L) (byhave hg : 0≤num J := Nat.cast_nonneg _linarith)calc d/4 = d*(1/2)*(1/2) := by ring_ ≤ _ := mul_le_mul (mul_le_mul_of_nonneg_left h1 hk.le) (he h) (by norm_num)(mul_nonneg hk.le (le_trans (by norm_num) h1))variable {I J U : Type} [Fintype I] [Fintype J] [Fintype U]variable [DecidableEq I] [DecidableEq J] [DecidableEq U]theorem gramObsCap {C : Mat (I⊕J) (I⊕J) → Prop}(hc : ∃ x : Mat U (I⊕J) × _, FramesAt C x)(T : Mat (I⊕J) J) (ht : Function.Injective T.mulVec)(hN : 2*num J-num U≤ -1) :let w := unifOn (FramesAt C)∀ x : Mat U J × Mat U J,mapW w (observe T T) x ≤ (4*bp (num J*num J))*pairW unif unif x := byclassicallet w := unifOn (FramesAt (U:=U) C)have hw := unifOn_law hclet f := observe T T (U:=U)let v := mapW w fhave hv : IsLaw v := mapW_law hw fhave hg :carried v (fun x : Mat U J × _ => Injective x.1.mulVec ∧ Injective x.2.mulVec) := byrefine mapW_carried (unifOn_carried _) (fun x hx => ?_)exact ⟨inj_comp_mat _ _ hx.2.1 ht,inj_comp_mat _ _ hx.2.2 ht⟩dsimp onlyintro xrw [← pair_unif]by_cases h : v x≠0· let G := (x.1ᵀ*x.2 : Mat J J)have hx : gramGood G x := ⟨rfl,Classical.byContradiction fun he => h (hg x he)⟩let m := bp (-num J*num J)/4have he (y : Mat U J × Mat U J) (hy : gramGood G y) : v y=v x := byobtain ⟨L,hL⟩ := move_exists G x y hx hylet e := L.perm (I⊕J) (I⊕J)have hl (y) : f (e y)=(L.perm J J) (f y) :=Prod.ext (Matrix.mul_assoc ..) (Matrix.mul_assoc ..)have hp y : w (e y)=w y := byunfold w; rw [unifOn_val, unifOn_val]congr 2exact propext (L.invar C y).symmexact hL ▸ mapW_pr_eq e f (L.perm J J) hl w hp xhave hi := pmax_test (gramGood (U:=U) G) hv.sub he (m:=m)(div_pos (bp_pos _) (by norm_num)) (gram_norm_quarter G (by linarith only [hN]))apply hi.transunfold m; rw [neg_mul,bp_neg]; field_simpexact le_rfl· change v x ≤ _rw [not_ne_iff.mp h]exact mul_nonneg (mul_nonneg (by norm_num) (bp_pos _).le) (unif_subLaw.nz _)variable {p : Shape} {n N : ℕ}abbrev HMat (p : Shape) (N : ℕ) := Mat (Fin N) (Chan p)abbrev HFrame (p : Shape) (N : ℕ) := HMat p N × HMat p Nabbrev HCube (p : Shape) (N : ℕ) := Comp p.g → HFrame p Ndef hchan (p : Shape) {n N} (x : Oframe p n N) : HFrame p N :=(channel x.1,channel x.2)def hcube (p : Shape) {n N} (x : Orient p n N) : HCube p N := fun z => hchan p (x z)def lawH (p : Shape) (N : ℕ) : Wgt (HCube p N) :=prodW (fun (_ : Comp p.g) => pairW unif unif)def intoChan (p : Shape) (n) : Mat (Full p n) (Chan p) := embedMat (.inr ·)theorem intoChan_inj : Injective (intoChan p n).mulVec :=embedMat_inj Sum.inr_injectivetheorem intoChan_val (p : Shape) {n N} (x : Mat (Fin N) (Full p n)) :x * intoChan p n=channel x := by rw [intoChan,mul_embedMat]; rfltheorem hchan_val (p : Shape) {n N} :hchan p (n:=n) (N:=N) = observe (intoChan p n) (intoChan p n) := byfunext xexact Prod.ext (intoChan_val ..).symm (intoChan_val ..).symmdef chanPrice (p : Shape) : ℝ :=(4*bp ((p.h:ℝ)*p.h))^(Fintype.card (Comp p.g))theorem hchan_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1) :let w := unifOn (FramesAt (U:=Fin N) (gramCond m))∀ x : HFrame p N,mapW w (hchan p) x≤(4*bp ((p.h:ℝ)*p.h))*pairW unif unif x := byclassicalhave he : 2*num (Full p n)-num (Fin N)≤ -1 := by simpa [num] using hNhave hh : ∃ x : Oframe p n N, FramesAt (gramCond m) x :=framesAt_exists (gramCond_exists m) (by linarith only [he])rw [hchan_val]have hr : num (Chan p) ≤ num (Full p n) := byhave hf : Fintype.card (Row p n) + Fintype.card (Chan p)=Fintype.card (Full p n) :=(Fintype.card_sum ..).symmexact_mod_cast (show Fintype.card (Chan p)≤Fintype.card (Full p n) by omega)have hk := gramObsCap hh (intoChan p n) intoChan_inj (by linarith only [he,hr])rw [show num (Chan p)=(p.h:ℝ) from (by simp [num,Chan])] at hkexact hktheorem hcube_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1)(x : HCube p N) : mapW (raw m N) (hcube p) x ≤ chanPrice p*lawH p N x := bylet w := unifOn (FramesAt (U:=Fin N) (gramCond m))have hh i := hchan_cap m hN (x i)change mapW (prodW (fun (_ : Comp p.g) => w)) _ x ≤ _unfold hcuberw [mapW_repeat (w:=fun (_:Comp p.g) => w) (f:=fun i => hchan p (n:=n) (N:=N))]refine le_trans (Finset.prod_le_prod₀ ?_ fun i _ => hh i) ?_· intro i _exact pr_nonneg (unifOn_sub _).nzrw [Finset.prod_mul_distrib]simp [chanPrice,lawH,prodW]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186import OAI.Combinatorics.HadwigerCounterexample.SumRankBoundsnamespace OAI/-! # Channel Frame Laws -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Module Submodule Finset Functionopen scoped BigOperatorsvariable {A B : Type} [Fintype A] [Fintype B]theorem map_pair_law {C D : Type} [Fintype C] [Fintype D](w : Wgt A) (v : Wgt B) (f : A→C) (g : B→D) :mapW (pairW w v) (Prod.map f g)=pairW (mapW w f) (mapW v g) := byfunext xunfold mapW pairWsimp only [Prod.ext_iff]exact pairW_pr w v (fun y => f y=x.1) (fun y => g y=x.2)theorem mapW_nested {C : Type} (w : Wgt A) (f : A→B) (g : B→C) :mapW (mapW w f) g=mapW w (g ∘ f) :=funext fun _ => mapW_pr _ _ _omit [Fintype B] intheorem mapW_repeat {I : Type} [Fintype I] [DecidableEq I](w : I→ Wgt A) (f : I→ A→B) :mapW (prodW w) (fun x i => f i (x i))=prodW (fun i => mapW (w i) (f i)) := byfunext xunfold mapWsimp_rw [funext_iff]exact prodW_pr _ (fun i y => f i y=x i)omit [Fintype B] intheorem mapW_pr_eq (e : A≃A) (f : A→B) (u : B≃B) (h : ∀ x,f (e x)=u (f x))(w : Wgt A) (hw : ∀ x, w (e x)=w x) (x : B) : mapW w f (u x)=mapW w f x := byhave he := avg_bij e w (fun y => ind (f y=u x))simp_rw [hw,h,u.injective.eq_iff] at heexact he.symmprivate theorem pmax_test {x : A} (p : A → Prop) {w : Wgt A} (hw : SubLaw w)(h : ∀ y, p y → w y=w x) {m : ℝ} (hm : 0 < m)(hp : m ≤ pr unif p) [Nonempty A] :w x ≤ m⁻¹ * unif x := byhave hh : pr w p=w x*nbr p := bysimp only [pr,avg,nbr,tot,Finset.mul_sum]refine Finset.sum_congr rfl fun i _ => ?_by_cases he : p i· rw [h i he]rw [ind_zero he,mul_zero,mul_zero]have h1 := (pr_le_tot (p:=p) hw.nz).trans hw.totalrw [hh] at h1have hU : 0 < (Fintype.card A : ℝ) := by exact_mod_cast Fintype.card_posrw [pr_unif (A:=A)] at hphave hi := (le_div_iff₀ hU).mp hprw [unif_apply]field_simpnlinarith only [h1,hi,mul_le_mul_of_nonneg_left hi (hw.nz x)]theorem gram_norm_quarter {I J L : Type} [Fintype I] [Fintype J] [Fintype L][DecidableEq I] [DecidableEq J] [DecidableEq L] (G : Mat I J)(h : num I + num J-num L ≤ -1) :bp (-num I * num J)/4 ≤ pr unif (gramGood (U:=L) G) := byhave hn := (gram_norm G (by linarith : num I+num J≤num L)).2rw [pair_unif]refine le_trans ?_ hnhave he {x : ℝ} (hx : x ≤ -1) : (1/2 : ℝ)≤ 1-bp x := byhave ht := bp_le hxrw [bp_neg,bp_one] at htlinarith only [ht]let d := bp (-num I*num J)change d/4 ≤ d* _ * _have hk : 0 < d := bp_pos _have h1 := he (x:= num I-num L) (byhave hg : 0≤num J := Nat.cast_nonneg _linarith)calc d/4 = d*(1/2)*(1/2) := by ring_ ≤ _ := mul_le_mul (mul_le_mul_of_nonneg_left h1 hk.le) (he h) (by norm_num)(mul_nonneg hk.le (le_trans (by norm_num) h1))variable {I J U : Type} [Fintype I] [Fintype J] [Fintype U]variable [DecidableEq I] [DecidableEq J] [DecidableEq U]theorem gramObsCap {C : Mat (I⊕J) (I⊕J) → Prop}(hc : ∃ x : Mat U (I⊕J) × _, FramesAt C x)(T : Mat (I⊕J) J) (ht : Function.Injective T.mulVec)(hN : 2*num J-num U≤ -1) :let w := unifOn (FramesAt C)∀ x : Mat U J × Mat U J,mapW w (observe T T) x ≤ (4*bp (num J*num J))*pairW unif unif x := byclassicallet w := unifOn (FramesAt (U:=U) C)have hw := unifOn_law hclet f := observe T T (U:=U)let v := mapW w fhave hv : IsLaw v := mapW_law hw fhave hg :carried v (fun x : Mat U J × _ => Injective x.1.mulVec ∧ Injective x.2.mulVec) := byrefine mapW_carried (unifOn_carried _) (fun x hx => ?_)exact ⟨inj_comp_mat _ _ hx.2.1 ht,inj_comp_mat _ _ hx.2.2 ht⟩dsimp onlyintro xrw [← pair_unif]by_cases h : v x≠0· let G := (x.1ᵀ*x.2 : Mat J J)have hx : gramGood G x := ⟨rfl,Classical.byContradiction fun he => h (hg x he)⟩let m := bp (-num J*num J)/4have he (y : Mat U J × Mat U J) (hy : gramGood G y) : v y=v x := byobtain ⟨L,hL⟩ := move_exists G x y hx hylet e := L.perm (I⊕J) (I⊕J)have hl (y) : f (e y)=(L.perm J J) (f y) :=Prod.ext (Matrix.mul_assoc ..) (Matrix.mul_assoc ..)have hp y : w (e y)=w y := byunfold w; rw [unifOn_val, unifOn_val]congr 2exact propext (L.invar C y).symmexact hL ▸ mapW_pr_eq e f (L.perm J J) hl w hp xhave hi := pmax_test (gramGood (U:=U) G) hv.sub he (m:=m)(div_pos (bp_pos _) (by norm_num)) (gram_norm_quarter G (by linarith only [hN]))apply hi.transunfold m; rw [neg_mul,bp_neg]; field_simpexact le_rfl· change v x ≤ _rw [not_ne_iff.mp h]exact mul_nonneg (mul_nonneg (by norm_num) (bp_pos _).le) (unif_subLaw.nz _)variable {p : Shape} {n N : ℕ}abbrev HMat (p : Shape) (N : ℕ) := Mat (Fin N) (Chan p)abbrev HFrame (p : Shape) (N : ℕ) := HMat p N × HMat p Nabbrev HCube (p : Shape) (N : ℕ) := Comp p.g → HFrame p Ndef hchan (p : Shape) {n N} (x : Oframe p n N) : HFrame p N :=(channel x.1,channel x.2)def hcube (p : Shape) {n N} (x : Orient p n N) : HCube p N := fun z => hchan p (x z)def lawH (p : Shape) (N : ℕ) : Wgt (HCube p N) :=prodW (fun (_ : Comp p.g) => pairW unif unif)def intoChan (p : Shape) (n) : Mat (Full p n) (Chan p) := embedMat (.inr ·)theorem intoChan_inj : Injective (intoChan p n).mulVec :=embedMat_inj Sum.inr_injectivetheorem intoChan_val (p : Shape) {n N} (x : Mat (Fin N) (Full p n)) :x * intoChan p n=channel x := by rw [intoChan,mul_embedMat]; rfltheorem hchan_val (p : Shape) {n N} :hchan p (n:=n) (N:=N) = observe (intoChan p n) (intoChan p n) := byfunext xexact Prod.ext (intoChan_val ..).symm (intoChan_val ..).symmdef chanPrice (p : Shape) : ℝ :=(4*bp ((p.h:ℝ)*p.h))^(Fintype.card (Comp p.g))theorem hchan_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1) :let w := unifOn (FramesAt (U:=Fin N) (gramCond m))∀ x : HFrame p N,mapW w (hchan p) x≤(4*bp ((p.h:ℝ)*p.h))*pairW unif unif x := byclassicalhave he : 2*num (Full p n)-num (Fin N)≤ -1 := by simpa [num] using hNhave hh : ∃ x : Oframe p n N, FramesAt (gramCond m) x :=framesAt_exists (gramCond_exists m) (by linarith only [he])rw [hchan_val]have hr : num (Chan p) ≤ num (Full p n) := byhave hf : Fintype.card (Row p n) + Fintype.card (Chan p)=Fintype.card (Full p n) :=(Fintype.card_sum ..).symmexact_mod_cast (show Fintype.card (Chan p)≤Fintype.card (Full p n) by omega)have hk := gramObsCap hh (intoChan p n) intoChan_inj (by linarith only [he,hr])rw [show num (Chan p)=(p.h:ℝ) from (by simp [num,Chan])] at hkexact hktheorem hcube_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1)(x : HCube p N) : mapW (raw m N) (hcube p) x ≤ chanPrice p*lawH p N x := bylet w := unifOn (FramesAt (U:=Fin N) (gramCond m))have hh i := hchan_cap m hN (x i)change mapW (prodW (fun (_ : Comp p.g) => w)) _ x ≤ _unfold hcuberw [mapW_repeat (w:=fun (_:Comp p.g) => w) (f:=fun i => hchan p (n:=n) (N:=N))]refine le_trans (Finset.prod_le_prod₀ ?_ fun i _ => hh i) ?_· intro i _exact pr_nonneg (unifOn_sub _).nzrw [Finset.prod_mul_distrib]simp [chanPrice,lawH,prodW]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204import OAI.Combinatorics.HadwigerCounterexample.UnaryRecordsimport OAI.Combinatorics.HadwigerCounterexample.ConstructionScalesnamespace OAI/-! # Collision Inequality -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module Finset Filteropen scoped BigOperatorsvariable {p : Shape} {n N : ℕ}variable {I A B : Type} [Fintype I] [Fintype A] [Fintype B]def density (v w : Wgt I) := fun x => w x/v xdef overlap (v a b : Wgt I) :=avg v (fun x => density v a x*density v b x)theorem overlap_count (P : I→Prop) (p q : Wgt I) (h : ∀ x, 0 ≤ p x) (h' : ∀ x, 0≤ q x) :overlap (unifOn P) p q ≤ (Fintype.card I:ℝ) * (∑ i, p i*q i) := byclassicalsimp only [overlap,density, avg,Finset.mul_sum]refine Finset.sum_le_sum fun i _ => ?_have hg := mul_nonneg (h i) (h' i)have hw : 0 ≤ (↑(Fintype.card I) : ℝ) := Nat.cast_nonneg _by_cases he : P i· have hh : 0 < nbr P := byhave hpos : 0 < Fintype.card {x//P x} := Fintype.card_pos_iff.mpr ⟨⟨i,he⟩⟩rw [nbr_eq_card]; exact_mod_cast hposhave hd : unifOn P i * (p i/unifOn P i * (q i / unifOn P i))=nbr P*(p i*q i) := byrw [unifOn_val,ind_one he]field_simprw [hd]apply mul_le_mul_of_nonneg_right _ hgrw [nbr_eq_card]exact_mod_cast Fintype.card_le_of_injective _ (@Subtype.val_injective _ P)rw [unifOn_carried P i he,zero_mul]exact mul_nonneg hw hgnamespace Volley/-- law of accepted keys as an unnormalized histogram -/def hist (v : A → Volley p n I) (t : Tagging p I)(μ : Wgt (UnitType p n N)) (rho' : Wgt A) (U : A → UnitType p n N → Prop) :Wgt (Keys (p:=p) t N) :=fun u => avg rho' (fun a => pr μ (fun x => U a x ∧ (v a).keys t x=u))set_option maxHeartbeats 800000 inprivate theorem record_sum (v w : Volley p n I) {t : Tagging p I} (m : Mixer p n){a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}(U V : UnitType p n N → Prop)(ha : ∀ x, U x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))(hb : ∀ x, V x → b.agree x ∧ (∀ i,frameLaw m (onSide x i))){ζ : ℝ} {q : ℕ}(h : ∀ x,U x → ∀ y,V y → v.keys t x=w.keys t y → v.promised w t m a.sp b.sp x y)(hv : v.avoids a.sp q) (hw : w.avoids b.sp q)(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004)(hμ : SubLaw μ) (hδ : SubLaw δ)(hA : a.clear ζ μ) (hB : b.clear ζ δ)(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)(L : ℝ)(hLf : bp (dim (Ledger (v.frozen a.sp t))) ≤ L)(hLg : bp (dim (Ledger (w.frozen b.sp t))) ≤ L) :hit N *(∑ u : Keys (p:=p) t N, pr μ (fun x => U x ∧ v.keys t x=u) *pr δ (fun x => V x ∧ w.keys t x=u)) ≤pr (pairW μ δ) (fun x => (rawHoles m).conflict x.1 x.2)+2*(hit N*tau N (kslots p I)*L) := byclassicallet X := UnitType p n Nlet T := Keys (p:=p) t Nlet K (u : T) (x : X) := U x ∧ v.keys t x=ulet K' (u : T) (x : X) := V x ∧ w.keys t x=ulet H := hit N*tau N (kslots p I)*Llet P := pairW μ δlet C (x : X × X) := (rawHoles m).conflict x.1 x.2let G (u : T) (x : X × X) := K u x.1 ∧ K' u x.2 ∧ C xrw [Finset.mul_sum]have hh (i : Keys (p:=p) t N) :hit N * (pr μ (K i) * pr δ (K' i))≤ pr P (G i)+H*(pr μ (K i)+pr δ (K' i)) := byapply record_hit v w m (K i) (K' i) i _ _ _ hv hw hz hK hμ hδ hA hB hN hT L hLf hLg· exact fun x h => ⟨(ha x h.1).1,(ha x h.1).2,h.2⟩· exact fun x h => ⟨(hb x h.1).1,(hb x h.1).2,h.2⟩exact fun x hx y hy => h x hx.1 y hy.1 (hx.2.trans hy.2.symm)refine (Finset.sum_le_sum fun i _ => hh i).trans ?_rw [Finset.sum_add_distrib]have hi : (∑ i : Keys (p:=p) t N, pr P (G i)) ≤ pr P C := byrw [← sum_pr_tag P C (v.keys t ∘ Prod.fst)]exact Finset.sum_le_sum fun i _ => pr_mono (subLaw_pair hμ hδ).nz (fun x h => ⟨h.2.2,h.1.2⟩)refine add_le_add hi ?_have hU : (∑ i : Keys (p:=p) t N, pr μ (K i))≤1 :=(sum_pr_tag μ U (v.keys t)).trans_le ((pr_le_tot hμ.nz).trans hμ.total)have hV : (∑ i : Keys (p:=p) t N, pr δ (K' i))≤1 :=(sum_pr_tag δ V (w.keys t)).trans_le ((pr_le_tot hδ.nz).trans hδ.total)have hz : 0 ≤ H := mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le) ((bp_pos _).le.trans hLf)rw [← Finset.mul_sum,Finset.sum_add_distrib,mul_comm 2]exact mul_le_mul_of_nonneg_left (by linarith only [hU,hV]) hzset_option maxHeartbeats 1200000 intheorem collision (v : A→Volley p n I) (w : B→Volley p n I){t : Tagging p I} (m : Mixer p n){a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}(rhoA : Wgt A) (rhoB : Wgt B)(U : A → UnitType p n N → Prop) (V : B → UnitType p n N → Prop)(ha : ∀ i x, U i x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))(hb : ∀ i x, V i x → b.agree x ∧ (∀ i,frameLaw m (onSide x i))){ζ : ℝ} {q K : ℕ}(h : ∀ i j x,U i x → ∀ y,V j y → (v i).keys t x=(w j).keys t y →(v i).promised (w j) t m a.sp b.sp x y)(hv : ∀ i, (v i).avoids a.sp q) (hw : ∀ i, (w i).avoids b.sp q)(hκ : planRank a.sp≤K) (hκ' : planRank b.sp≤K)(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004) (hslots : kslots p I≤kmax p)(hμ : SubLaw μ) (hδ : SubLaw δ) (hu : SubLaw rhoA) (hu' : SubLaw rhoB)(hA : a.clear ζ μ) (hB : b.clear ζ δ)(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)(hL : (K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N)(J : Keys (p:=p) t N → Prop) :overlap (unifOn J) (hist v t μ rhoA U) (hist w t δ rhoB V) ≤bp (((kslots p I:ℝ)+0.02)*N)*pr (pairW μ δ) (fun x =>(rawHoles m).conflict x.1 x.2) + 2*bp (-0.005*N) := byclassicallet k := kslots p Ilet L := bp (0.005*N)let C := fun (x : UnitType p n N × _) => (rawHoles m).conflict x.1 x.2let X := hist v t μ rhoA Ulet Y := hist w t δ rhoB Vlet H := hit N*tau N k*Llet D := pr (pairW μ δ) Clet α (u : Keys (p:=p) t N) i := pr μ (fun x => U i x ∧ (v i).keys t x=u)let β (u : Keys (p:=p) t N) i := pr δ (fun x => V i x ∧ (w i).keys t x=u)have hX u : 0≤ X u := avg_nonneg hu.nz (fun i => pr_nonneg hμ.nz)have hY u : 0≤ Y u := avg_nonneg hu'.nz (fun i => pr_nonneg hδ.nz)have hW (f : Plan p n) (hk : planRank f ≤ K) (v : Volley p n I) (hv : v.avoids f q) :bp (dim (Ledger (v.frozen f t)))≤L := byapply bp_lerw [ledger_dim]push_casthave ht : (planRank (v.frozen f t) : ℝ) ≤ K+(kmax p:ℝ) := byhave hh := plan_add_rank f (v.keyPlan t)rw [key_slots t hv] at hhexact_mod_cast (show planRank (f⊔v.keyPlan t) ≤ K+kmax p fromhh.symm ▸ add_le_add hk hslots)exact le_trans (mul_le_mul_of_nonneg_right ht (Nat.cast_nonneg _)) hLhave hf (x : A × B) :hit N * (∑ u : Keys (p:=p) t N, α u x.1*β u x.2) ≤ D+ 2*H :=record_sum (v x.1) (w x.2) m (U _) (V _) (ha x.1) (hb x.2) (h x.1 x.2)(hv x.1) (hw x.2) hz hK hμ hδ hA hB hN hT L (hW a.sp hκ _ (hv _)) (hW _ hκ' _ (hw _))have hh : hit N * (∑ u : Keys (p:=p) t N,X u * Y u) ≤ D + 2*H := bylet F := pairW rhoA rhoBhave hh' : 0 ≤ D+2*H := byapply add_nonneg (pr_nonneg (subLaw_pair hμ hδ).nz)exact mul_nonneg (by norm_num) (mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le)(bp_pos _).le)have hl := (subLaw_pair hu hu').avg_le hh' hfrw [avg_mul',avg_sum] at hlhave ht (u : Keys (p:=p) t N) :X u*Y u=avg F (fun x : A×B => α u x.1*β u x.2) := (pairW_separate ..).symmsimp_rw [ht]; exact hlapply (overlap_count J X Y hX hY).transrw [card_space,dim_keys,Nat.cast_mul]let Z := bp (((k:ℝ)+0.02)*N)have he : Z*hit N = bp ((k:ℝ)*N) := byunfold Z hit; rw [← bp_add]; congr 1; ringhave he' : Z*H = bp (-0.005*N) := byunfold H; rw [← mul_assoc,← mul_assoc,he]unfold L taurw [← bp_add,← bp_add]; congr 1; ringchange bp ((k:ℝ)*N)*_≤ Z*D+_rw [← he, mul_assoc,← he']refine (mul_le_mul_of_nonneg_left hh (bp_pos _).le).trans_eq ?_ringend Volleytheorem collision_scales (p : Shape) (K : ℕ) :∀ᶠ M : ℕ in atTop,∀ᶠ n : ℕ in atTop, let N := M*n;100≤N ∧ (dim (CheckGram p n):ℝ) ≤ 0.01*N ∧(K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N := byfilter_upwards [columns_budget p (δ:=0.01) (by norm_num)(16*(ncComp p:ℝ)*p.h) 0 (by positivity) (by norm_num),columns_budget p (δ:=0.005) (by norm_num)(2*(K+(kmax p:ℝ))) 0 (by positivity) (by norm_num),eventually_ge_atTop 1] with M hM hB hgfilter_upwards [eventually_ge_atTop 100] with n hnspecialize hM n (by omega)specialize hB n (by omega)have hN : 100 ≤ M*n := by nlinarithrefine ⟨hN,?_,?_⟩· rw [checkgram_dim]simp only [Nat.cast_mul,Nat.cast_ofNat]; unfold num at hMhave hi : (↑(Fintype.card (Row p n)):ℝ)≤Fintype.card (Full p n) := byhave he : Fintype.card (Full p n)=_+_ := Fintype.card_sum ..exact_mod_cast (show Fintype.card (Row p n)≤Fintype.card (Full p n) from he.symm ▸Nat.le_add_right ..)rw [add_zero] at hMrw [Nat.cast_mul] at hMexact le_trans (mul_le_mul_of_nonneg_left hi (by positivity)) hMrw [show num (JointIdx p n) = 2*num (Full p n) from (byunfold num JointIdx; rw [Fintype.card_sum]; push_cast; ring)]linarith only [hB]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204import OAI.Combinatorics.HadwigerCounterexample.UnaryRecordsimport OAI.Combinatorics.HadwigerCounterexample.ConstructionScalesnamespace OAI/-! # Collision Inequality -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module Finset Filteropen scoped BigOperatorsvariable {p : Shape} {n N : ℕ}variable {I A B : Type} [Fintype I] [Fintype A] [Fintype B]def density (v w : Wgt I) := fun x => w x/v xdef overlap (v a b : Wgt I) :=avg v (fun x => density v a x*density v b x)theorem overlap_count (P : I→Prop) (p q : Wgt I) (h : ∀ x, 0 ≤ p x) (h' : ∀ x, 0≤ q x) :overlap (unifOn P) p q ≤ (Fintype.card I:ℝ) * (∑ i, p i*q i) := byclassicalsimp only [overlap,density, avg,Finset.mul_sum]refine Finset.sum_le_sum fun i _ => ?_have hg := mul_nonneg (h i) (h' i)have hw : 0 ≤ (↑(Fintype.card I) : ℝ) := Nat.cast_nonneg _by_cases he : P i· have hh : 0 < nbr P := byhave hpos : 0 < Fintype.card {x//P x} := Fintype.card_pos_iff.mpr ⟨⟨i,he⟩⟩rw [nbr_eq_card]; exact_mod_cast hposhave hd : unifOn P i * (p i/unifOn P i * (q i / unifOn P i))=nbr P*(p i*q i) := byrw [unifOn_val,ind_one he]field_simprw [hd]apply mul_le_mul_of_nonneg_right _ hgrw [nbr_eq_card]exact_mod_cast Fintype.card_le_of_injective _ (@Subtype.val_injective _ P)rw [unifOn_carried P i he,zero_mul]exact mul_nonneg hw hgnamespace Volley/-- law of accepted keys as an unnormalized histogram -/def hist (v : A → Volley p n I) (t : Tagging p I)(μ : Wgt (UnitType p n N)) (rho' : Wgt A) (U : A → UnitType p n N → Prop) :Wgt (Keys (p:=p) t N) :=fun u => avg rho' (fun a => pr μ (fun x => U a x ∧ (v a).keys t x=u))set_option maxHeartbeats 800000 inprivate theorem record_sum (v w : Volley p n I) {t : Tagging p I} (m : Mixer p n){a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}(U V : UnitType p n N → Prop)(ha : ∀ x, U x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))(hb : ∀ x, V x → b.agree x ∧ (∀ i,frameLaw m (onSide x i))){ζ : ℝ} {q : ℕ}(h : ∀ x,U x → ∀ y,V y → v.keys t x=w.keys t y → v.promised w t m a.sp b.sp x y)(hv : v.avoids a.sp q) (hw : w.avoids b.sp q)(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004)(hμ : SubLaw μ) (hδ : SubLaw δ)(hA : a.clear ζ μ) (hB : b.clear ζ δ)(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)(L : ℝ)(hLf : bp (dim (Ledger (v.frozen a.sp t))) ≤ L)(hLg : bp (dim (Ledger (w.frozen b.sp t))) ≤ L) :hit N *(∑ u : Keys (p:=p) t N, pr μ (fun x => U x ∧ v.keys t x=u) *pr δ (fun x => V x ∧ w.keys t x=u)) ≤pr (pairW μ δ) (fun x => (rawHoles m).conflict x.1 x.2)+2*(hit N*tau N (kslots p I)*L) := byclassicallet X := UnitType p n Nlet T := Keys (p:=p) t Nlet K (u : T) (x : X) := U x ∧ v.keys t x=ulet K' (u : T) (x : X) := V x ∧ w.keys t x=ulet H := hit N*tau N (kslots p I)*Llet P := pairW μ δlet C (x : X × X) := (rawHoles m).conflict x.1 x.2let G (u : T) (x : X × X) := K u x.1 ∧ K' u x.2 ∧ C xrw [Finset.mul_sum]have hh (i : Keys (p:=p) t N) :hit N * (pr μ (K i) * pr δ (K' i))≤ pr P (G i)+H*(pr μ (K i)+pr δ (K' i)) := byapply record_hit v w m (K i) (K' i) i _ _ _ hv hw hz hK hμ hδ hA hB hN hT L hLf hLg· exact fun x h => ⟨(ha x h.1).1,(ha x h.1).2,h.2⟩· exact fun x h => ⟨(hb x h.1).1,(hb x h.1).2,h.2⟩exact fun x hx y hy => h x hx.1 y hy.1 (hx.2.trans hy.2.symm)refine (Finset.sum_le_sum fun i _ => hh i).trans ?_rw [Finset.sum_add_distrib]have hi : (∑ i : Keys (p:=p) t N, pr P (G i)) ≤ pr P C := byrw [← sum_pr_tag P C (v.keys t ∘ Prod.fst)]exact Finset.sum_le_sum fun i _ => pr_mono (subLaw_pair hμ hδ).nz (fun x h => ⟨h.2.2,h.1.2⟩)refine add_le_add hi ?_have hU : (∑ i : Keys (p:=p) t N, pr μ (K i))≤1 :=(sum_pr_tag μ U (v.keys t)).trans_le ((pr_le_tot hμ.nz).trans hμ.total)have hV : (∑ i : Keys (p:=p) t N, pr δ (K' i))≤1 :=(sum_pr_tag δ V (w.keys t)).trans_le ((pr_le_tot hδ.nz).trans hδ.total)have hz : 0 ≤ H := mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le) ((bp_pos _).le.trans hLf)rw [← Finset.mul_sum,Finset.sum_add_distrib,mul_comm 2]exact mul_le_mul_of_nonneg_left (by linarith only [hU,hV]) hzset_option maxHeartbeats 1200000 intheorem collision (v : A→Volley p n I) (w : B→Volley p n I){t : Tagging p I} (m : Mixer p n){a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}(rhoA : Wgt A) (rhoB : Wgt B)(U : A → UnitType p n N → Prop) (V : B → UnitType p n N → Prop)(ha : ∀ i x, U i x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))(hb : ∀ i x, V i x → b.agree x ∧ (∀ i,frameLaw m (onSide x i))){ζ : ℝ} {q K : ℕ}(h : ∀ i j x,U i x → ∀ y,V j y → (v i).keys t x=(w j).keys t y →(v i).promised (w j) t m a.sp b.sp x y)(hv : ∀ i, (v i).avoids a.sp q) (hw : ∀ i, (w i).avoids b.sp q)(hκ : planRank a.sp≤K) (hκ' : planRank b.sp≤K)(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004) (hslots : kslots p I≤kmax p)(hμ : SubLaw μ) (hδ : SubLaw δ) (hu : SubLaw rhoA) (hu' : SubLaw rhoB)(hA : a.clear ζ μ) (hB : b.clear ζ δ)(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)(hL : (K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N)(J : Keys (p:=p) t N → Prop) :overlap (unifOn J) (hist v t μ rhoA U) (hist w t δ rhoB V) ≤bp (((kslots p I:ℝ)+0.02)*N)*pr (pairW μ δ) (fun x =>(rawHoles m).conflict x.1 x.2) + 2*bp (-0.005*N) := byclassicallet k := kslots p Ilet L := bp (0.005*N)let C := fun (x : UnitType p n N × _) => (rawHoles m).conflict x.1 x.2let X := hist v t μ rhoA Ulet Y := hist w t δ rhoB Vlet H := hit N*tau N k*Llet D := pr (pairW μ δ) Clet α (u : Keys (p:=p) t N) i := pr μ (fun x => U i x ∧ (v i).keys t x=u)let β (u : Keys (p:=p) t N) i := pr δ (fun x => V i x ∧ (w i).keys t x=u)have hX u : 0≤ X u := avg_nonneg hu.nz (fun i => pr_nonneg hμ.nz)have hY u : 0≤ Y u := avg_nonneg hu'.nz (fun i => pr_nonneg hδ.nz)have hW (f : Plan p n) (hk : planRank f ≤ K) (v : Volley p n I) (hv : v.avoids f q) :bp (dim (Ledger (v.frozen f t)))≤L := byapply bp_lerw [ledger_dim]push_casthave ht : (planRank (v.frozen f t) : ℝ) ≤ K+(kmax p:ℝ) := byhave hh := plan_add_rank f (v.keyPlan t)rw [key_slots t hv] at hhexact_mod_cast (show planRank (f⊔v.keyPlan t) ≤ K+kmax p fromhh.symm ▸ add_le_add hk hslots)exact le_trans (mul_le_mul_of_nonneg_right ht (Nat.cast_nonneg _)) hLhave hf (x : A × B) :hit N * (∑ u : Keys (p:=p) t N, α u x.1*β u x.2) ≤ D+ 2*H :=record_sum (v x.1) (w x.2) m (U _) (V _) (ha x.1) (hb x.2) (h x.1 x.2)(hv x.1) (hw x.2) hz hK hμ hδ hA hB hN hT L (hW a.sp hκ _ (hv _)) (hW _ hκ' _ (hw _))have hh : hit N * (∑ u : Keys (p:=p) t N,X u * Y u) ≤ D + 2*H := bylet F := pairW rhoA rhoBhave hh' : 0 ≤ D+2*H := byapply add_nonneg (pr_nonneg (subLaw_pair hμ hδ).nz)exact mul_nonneg (by norm_num) (mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le)(bp_pos _).le)have hl := (subLaw_pair hu hu').avg_le hh' hfrw [avg_mul',avg_sum] at hlhave ht (u : Keys (p:=p) t N) :X u*Y u=avg F (fun x : A×B => α u x.1*β u x.2) := (pairW_separate ..).symmsimp_rw [ht]; exact hlapply (overlap_count J X Y hX hY).transrw [card_space,dim_keys,Nat.cast_mul]let Z := bp (((k:ℝ)+0.02)*N)have he : Z*hit N = bp ((k:ℝ)*N) := byunfold Z hit; rw [← bp_add]; congr 1; ringhave he' : Z*H = bp (-0.005*N) := byunfold H; rw [← mul_assoc,← mul_assoc,he]unfold L taurw [← bp_add,← bp_add]; congr 1; ringchange bp ((k:ℝ)*N)*_≤ Z*D+_rw [← he, mul_assoc,← he']refine (mul_le_mul_of_nonneg_left hh (bp_pos _).le).trans_eq ?_ringend Volleytheorem collision_scales (p : Shape) (K : ℕ) :∀ᶠ M : ℕ in atTop,∀ᶠ n : ℕ in atTop, let N := M*n;100≤N ∧ (dim (CheckGram p n):ℝ) ≤ 0.01*N ∧(K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N := byfilter_upwards [columns_budget p (δ:=0.01) (by norm_num)(16*(ncComp p:ℝ)*p.h) 0 (by positivity) (by norm_num),columns_budget p (δ:=0.005) (by norm_num)(2*(K+(kmax p:ℝ))) 0 (by positivity) (by norm_num),eventually_ge_atTop 1] with M hM hB hgfilter_upwards [eventually_ge_atTop 100] with n hnspecialize hM n (by omega)specialize hB n (by omega)have hN : 100 ≤ M*n := by nlinarithrefine ⟨hN,?_,?_⟩· rw [checkgram_dim]simp only [Nat.cast_mul,Nat.cast_ofNat]; unfold num at hMhave hi : (↑(Fintype.card (Row p n)):ℝ)≤Fintype.card (Full p n) := byhave he : Fintype.card (Full p n)=_+_ := Fintype.card_sum ..exact_mod_cast (show Fintype.card (Row p n)≤Fintype.card (Full p n) from he.symm ▸Nat.le_add_right ..)rw [add_zero] at hMrw [Nat.cast_mul] at hMexact le_trans (mul_le_mul_of_nonneg_left hi (by positivity)) hMrw [show num (JointIdx p n) = 2*num (Full p n) from (byunfold num JointIdx; rw [Fintype.card_sum]; push_cast; ring)]linarith only [hB]end HadwigerCounterexampleendend OAI
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import OAI.Combinatorics.HadwigerCounterexample.RectangleComparisonsnamespace OAI/-! # Common Partition Refinement -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix Functionopen scoped BigOperators Topologyvariable {p:Shape} {n N K M r : ℕ}def refines {r r':ℕ} (Y:Silhouette p N r) (Y':Silhouette p N r') :=∀ l q, ∃ f:Fin r→Fin r',∀ x,Y' l q x=f (Y l q x)theorem self_refine (Y:Silhouette p N r): refines Y Y :=fun _ _=> ⟨id,fun _=>rfl⟩theorem refines_next {r s t:ℕ} {Y:Silhouette p N r} {X:Silhouette p N s}{Z:Silhouette p N t} (h : refines Y X) (hg : refines X Z) :refines Y Z := byintro l qobtain ⟨f,hf⟩:=h l q; obtain ⟨g,hg⟩:=hg l qrefine ⟨g∘ f,fun x => ?_⟩; rw [hg,hf]; rflvariable {A B : Type} [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B]def bouquet (f : A→ℕ) := Fintype.card ((i:A)→ Fin (f i))def bundleY (f:A→ℕ) (w: (i:A)→ Silhouette p N (f i)) :Silhouette p N (bouquet f) :=fun l q x=> Fintype.equivFin ((i:A)→ Fin (f i)) (fun i=> w i l q x)theorem bundle_refines (f:A→ℕ) (w:(i:A)→ Silhouette p N (f i)) :∀ i,refines (bundleY f w) (w i) := byintro i l qlet e:= Fintype.equivFin ((i:A)→Fin (f i))exact ⟨fun x=> e.symm x i,fun x=>(congr_fun (e.symm_apply_apply (fun i=> w i l q x)) i).symm⟩def duoY {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :Silhouette p N (r*s) :=open scoped Classical in fun i q x => finProdFinEquiv (Y i q x,X i q x)theorem duo_good {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :refines (duoY Y X) Y ∧ refines (duoY Y X) X := bylet e : Fin r × Fin s ≃ Fin (r*s):=finProdFinEquivconstructor· intro i j; exact ⟨fun k=>(e.symm k).1,fun x=> (congrArg Prod.fst(e.symm_apply_apply (Y i j x,X i j x))).symm⟩intro i j; exact ⟨fun k=>(e.symm k).2,fun x=> (congrArg Prod.snd(e.symm_apply_apply (Y i j x,X i j x))).symm⟩namespace StatusAnalysisvariable (v : Template p A)def paletteSize (A B : Type) [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] := Fintype.card (B × A → Bool)theorem buildPalette (N : ℕ) (q : A → F) (w : B → Template.Paint v N) :∃ Y : Silhouette p N (paletteSize A B),∀ i,pigments q Y (w i) := byclassicallet E := Fintype.equivFin (B × A→Bool)let H (l) (q:F) (x : AtomKey (p:=p) l N) (i:B) (j:A) :=if h:v.t j=l then decide ((w i).flies j (h ▸ x)) else falselet Y : Silhouette p N (paletteSize A B) :=fun l q x=> E (fun i=> H l q x i.1 i.2)refine ⟨Y,fun i j=>⟨fun x=>(E.symm x (i,j)),fun x=>?_⟩⟩change _ ↔ E.symm (E (fun i => H (v.t j) (q j) x i.1 i.2)) (i,j)=truerw [Equiv.symm_apply_apply]unfold H; rw [dite_eq_left rfl]; simpomit [Fintype A] [DecidableEq A] intheorem finerPigment {v : Template p A} {r s:ℕ} (Y : Silhouette p N r)(Y' : Silhouette p N s) (h : refines Y' Y) {q} (w : Template.Paint v N)(hh : pigments q Y w) : pigments q Y' w := byintro iobtain ⟨g,hg⟩:=hh i; obtain ⟨f,hf⟩:=h (v.t i) (q i)exact ⟨g∘ f,fun x=> (hg x).trans (by rw [hf]; rfl)⟩end StatusAnalysisend HadwigerCounterexampleendend OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import OAI.Combinatorics.HadwigerCounterexample.RectangleComparisonsnamespace OAI/-! # Common Partition Refinement -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix Functionopen scoped BigOperators Topologyvariable {p:Shape} {n N K M r : ℕ}def refines {r r':ℕ} (Y:Silhouette p N r) (Y':Silhouette p N r') :=∀ l q, ∃ f:Fin r→Fin r',∀ x,Y' l q x=f (Y l q x)theorem self_refine (Y:Silhouette p N r): refines Y Y :=fun _ _=> ⟨id,fun _=>rfl⟩theorem refines_next {r s t:ℕ} {Y:Silhouette p N r} {X:Silhouette p N s}{Z:Silhouette p N t} (h : refines Y X) (hg : refines X Z) :refines Y Z := byintro l qobtain ⟨f,hf⟩:=h l q; obtain ⟨g,hg⟩:=hg l qrefine ⟨g∘ f,fun x => ?_⟩; rw [hg,hf]; rflvariable {A B : Type} [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B]def bouquet (f : A→ℕ) := Fintype.card ((i:A)→ Fin (f i))def bundleY (f:A→ℕ) (w: (i:A)→ Silhouette p N (f i)) :Silhouette p N (bouquet f) :=fun l q x=> Fintype.equivFin ((i:A)→ Fin (f i)) (fun i=> w i l q x)theorem bundle_refines (f:A→ℕ) (w:(i:A)→ Silhouette p N (f i)) :∀ i,refines (bundleY f w) (w i) := byintro i l qlet e:= Fintype.equivFin ((i:A)→Fin (f i))exact ⟨fun x=> e.symm x i,fun x=>(congr_fun (e.symm_apply_apply (fun i=> w i l q x)) i).symm⟩def duoY {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :Silhouette p N (r*s) :=open scoped Classical in fun i q x => finProdFinEquiv (Y i q x,X i q x)theorem duo_good {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :refines (duoY Y X) Y ∧ refines (duoY Y X) X := bylet e : Fin r × Fin s ≃ Fin (r*s):=finProdFinEquivconstructor· intro i j; exact ⟨fun k=>(e.symm k).1,fun x=> (congrArg Prod.fst(e.symm_apply_apply (Y i j x,X i j x))).symm⟩intro i j; exact ⟨fun k=>(e.symm k).2,fun x=> (congrArg Prod.snd(e.symm_apply_apply (Y i j x,X i j x))).symm⟩namespace StatusAnalysisvariable (v : Template p A)def paletteSize (A B : Type) [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] := Fintype.card (B × A → Bool)theorem buildPalette (N : ℕ) (q : A → F) (w : B → Template.Paint v N) :∃ Y : Silhouette p N (paletteSize A B),∀ i,pigments q Y (w i) := byclassicallet E := Fintype.equivFin (B × A→Bool)let H (l) (q:F) (x : AtomKey (p:=p) l N) (i:B) (j:A) :=if h:v.t j=l then decide ((w i).flies j (h ▸ x)) else falselet Y : Silhouette p N (paletteSize A B) :=fun l q x=> E (fun i=> H l q x i.1 i.2)refine ⟨Y,fun i j=>⟨fun x=>(E.symm x (i,j)),fun x=>?_⟩⟩change _ ↔ E.symm (E (fun i => H (v.t j) (q j) x i.1 i.2)) (i,j)=truerw [Equiv.symm_apply_apply]unfold H; rw [dite_eq_left rfl]; simpomit [Fintype A] [DecidableEq A] intheorem finerPigment {v : Template p A} {r s:ℕ} (Y : Silhouette p N r)(Y' : Silhouette p N s) (h : refines Y' Y) {q} (w : Template.Paint v N)(hh : pigments q Y w) : pigments q Y' w := byintro iobtain ⟨g,hg⟩:=hh i; obtain ⟨f,hf⟩:=h (v.t i) (q i)exact ⟨g∘ f,fun x=> (hg x).trans (by rw [hf]; rfl)⟩end StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119import OAI.Combinatorics.HadwigerCounterexample.ProjectionErrornamespace OAI/-! # Common Partitions -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Module Matrix Filter Functionopen scoped BigOperatorsvariable {A B I J X : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J] [Fintype X]variable (u : Wgt A) (w : Wgt I) (v : Wgt J)set_option maxHeartbeats 800000 intheorem rollup [Nonempty B] (hw : IsLaw w) (hv : IsLaw v) (hu : IsLaw u)(f : I×B→Wgt A) (g : J×B→Wgt A) (h k : I×J→ B) (R : ℝ) (hr : 0<R)(hg : ∀ i x, |g i x|≤R)(p : A→X) (ε : ℝ) (hx : wanes (pairW w unif) u f p ε) :avg (pairW w v) (fun i=> |rebate u (f (i.1,h i)) (g (i.2,k i)) p|) ≤num B ^ 2 * (R*ε) := byclassicallet H (i : I × B) (j : J × B) := |rebate u (f i) (g j) p|let T := num Bhave ht : 0<T := by unfold T num; positivityhave he j :avg (pairW w (unif : Wgt B)) (fun i=> H i j)≤ R*ε := bylet g' (i:A) := g j i/Rhave hh (i) : |g' i|≤1 := byunfold g'; rw [abs_div,abs_of_pos hr,div_le_one hr]; exact hg _ _have hz (i) :H i j=R* |dip u (fun x=> f i x-banner u p (f i) x) g'| := byunfold H; rw [rebate_calc _ _ _ _ hu.nz]unfold g' dip; simp_rw [←mul_div_assoc,avg_div]rw [abs_div,abs_of_pos hr]; field_simpsimp_rw [hz,avg_mul']; exact mul_le_mul_of_nonneg_left (hx g' hh) hr.lehave hh i j :H (i,h (i,j)) (j,k (i,j))≤ ∑ b : B,∑ c : B,H (i,b) (j,c) :=(Finset.single_le_sum (f:=fun x=> H (i,h (i,j)) (j,x)) (fun _ _ => abs_nonneg _) (mem_univ (k (i,j)))).trans(Finset.single_le_sum (f:=fun x => ∑ c:B,H (i,x) (j,c)) (fun _ _=> Finset.sum_nonneg (fun _ _=>abs_nonneg _)) (mem_univ (h (i,j))))have hi j c :avg w (fun i=>∑ b : B,H (i,b) (j,c))≤ T*(R*ε) := byhave hg : ∀ i : I,(∑ b:B,H (i,b) (j,c))=T*avg unif (fun b=> H (i,b) (j,c)) := byintro i; simp only [avg,unif_apply,← Finset.mul_sum]change _ = T*(T⁻¹ * _)rw [←mul_assoc,mul_inv_cancel₀ ht.ne',one_mul]simp_rw [hg,avg_mul']refine mul_le_mul_of_nonneg_left ?_ ht.le; rw [← pairW_avg w unif (fun p : I×B=>H p (j,c))]exact he _change avg (pairW w v) _ ≤ T^2*(R*ε)rw [pairW_avg,avg_avg]refine hv.avg_le fun j=> ?_have hz i : ∑ b:B,∑ c:B,H (i,b) (j,c)=∑ c:B,∑ b:B,H (i,b) (j,c) :=Finset.sum_commapply (avg_mono hw.nz (fun i => (hh i j).trans_eq (hz i))).transrw [avg_sum]exact (Finset.sum_le_sum fun i _=>hi j i).trans_eq (bysimp only [sum_const,nsmul_eq_mul,Finset.card_univ,T,num]; ring)set_option maxHeartbeats 1200000 intheorem global_net (R ε : ℝ) (hr : 0<R) (hε : 0<ε) :∃ δ : ℝ,0<δ ∧ ∀ r : ℕ,∃ l : ℕ,∀ (I J A : Type) [Fintype I] [Fintype J] [Fintype A](w : Wgt I) (v : Wgt J) (u : Wgt A), IsLaw w→IsLaw v →IsLaw u →∀ (P : I→Wgt A→Prop) (Q : J→Wgt A→Prop), (∀ i,roster (P i) r δ) →(∀ i,roster (Q i) r δ) →∃ k : ℕ,k ≤ l∧ ∃ p:A→Fin k,∀ f g:I × J→Wgt A,(∀ i,P i.1 (f i)) → (∀ i,Q i.2 (g i)) →avg (pairW w v) (fun i => |rebate u (mcut R u (f i)) (mcut R u (g i)) p|)≤ ε := byclassicallet δ := ε/(8*R)have hd : 0<δ := by positivityrefine ⟨δ,hd,fun r=>?_⟩let B:=Fin (r+1); let t:=num Bhave ht : 0<t := by unfold t num; positivitylet c:=ε/(2*(t^2)*R)have hc : 0<c := by positivityobtain ⟨l,hl⟩:= erosive R c hr.le hcrefine ⟨l,fun I J A _ _ _ w v u hw hv hu P Q hp hq=>?_⟩choose s hs h1 using fun i=> roster_clip R u hu hr.le (P i) r δ (hp i)choose y hy h2 using fun i=> roster_clip R u hu hr.le (Q i) r δ (hq i)let F : I×B→Wgt A := uncurry slet G : J×B→Wgt A := uncurry yobtain ⟨m,hm,p,hP⟩:= hl A (I×B) (pairW w unif) u F (pairW_law hw unif_law) hu (fun i j=> hs _ _ _)refine ⟨m,hm,p,fun f g hf hg=>?_⟩let f' (i : I×J):= mcut R u (f i)let g' (i : I×J):= mcut R u (g i)choose a hA using fun i:I×J => h1 i.1 (f i) (hf i)choose b hB using fun i:I×J => h2 i.2 (g i) (hg i)let H (i:I×J) := |rebate u (F (i.1,a i)) (G (i.2,b i)) p|let D:=pairW w v; have hD:= pairW_law hw hvhave he := rollup u w v hw hv hu F G a b R hr (fun i j=> hy _ _ _) p c hPhave hb : 0≤2*R := by linarith only [hr]have hi (i:I×J) : |rebate u (f' i) (g' i) p|≤ H i+(δ*(4*R)) := bylet A' := F (i.1,a i); let B' := G (i.2,b i)have h1 (j) : |g' i j|≤R := byrw [abs_of_nonneg ((mcut_range _ _ _ hr.le j).1)]exact (mcut_range _ _ _ hr.le j).2have h3 : |rebate u (f' i) (g' i) p - rebate u A' (g' i) p|≤ δ*(2*R) := byexact (rebate_cost u _ _ A' p hu.nz R hr.le h1).trans (mul_le_mul_of_nonneg_right (hA i) hb)have h4 : |rebate u A' (g' i) p - rebate u A' B' p|≤δ*(2*R) := byrw [rebate_sym u A',rebate_sym u A']exact (rebate_cost u _ _ B' p hu.nz R hr.le (fun i=>hs _ _ _)).trans(mul_le_mul_of_nonneg_right (hB i) hb)let U:=rebate u A' B' plet X:=rebate u (f' i) (g' i) phave hz:= (abs_sub_le X (rebate u A' (g' i) p) U).trans (add_le_add h3 h4)calc |X| = |(X-U)+U| := by rw [sub_add_cancel]_ ≤ _ := ((abs_add_le _ _).trans (add_le_add_left hz _)).trans_eq (bychange _+ |U| = |U|+δ*(4*R)ring)refine (avg_mono hD.nz hi).trans ?_rw [avg_add,hD.avg_const]exact (add_le_add_left he _).trans_eq (bychange t^2*(R*c)+δ*(4*R)=_unfold δ c; field_simp; ring)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119import OAI.Combinatorics.HadwigerCounterexample.ProjectionErrornamespace OAI/-! # Common Partitions -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Module Matrix Filter Functionopen scoped BigOperatorsvariable {A B I J X : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J] [Fintype X]variable (u : Wgt A) (w : Wgt I) (v : Wgt J)set_option maxHeartbeats 800000 intheorem rollup [Nonempty B] (hw : IsLaw w) (hv : IsLaw v) (hu : IsLaw u)(f : I×B→Wgt A) (g : J×B→Wgt A) (h k : I×J→ B) (R : ℝ) (hr : 0<R)(hg : ∀ i x, |g i x|≤R)(p : A→X) (ε : ℝ) (hx : wanes (pairW w unif) u f p ε) :avg (pairW w v) (fun i=> |rebate u (f (i.1,h i)) (g (i.2,k i)) p|) ≤num B ^ 2 * (R*ε) := byclassicallet H (i : I × B) (j : J × B) := |rebate u (f i) (g j) p|let T := num Bhave ht : 0<T := by unfold T num; positivityhave he j :avg (pairW w (unif : Wgt B)) (fun i=> H i j)≤ R*ε := bylet g' (i:A) := g j i/Rhave hh (i) : |g' i|≤1 := byunfold g'; rw [abs_div,abs_of_pos hr,div_le_one hr]; exact hg _ _have hz (i) :H i j=R* |dip u (fun x=> f i x-banner u p (f i) x) g'| := byunfold H; rw [rebate_calc _ _ _ _ hu.nz]unfold g' dip; simp_rw [←mul_div_assoc,avg_div]rw [abs_div,abs_of_pos hr]; field_simpsimp_rw [hz,avg_mul']; exact mul_le_mul_of_nonneg_left (hx g' hh) hr.lehave hh i j :H (i,h (i,j)) (j,k (i,j))≤ ∑ b : B,∑ c : B,H (i,b) (j,c) :=(Finset.single_le_sum (f:=fun x=> H (i,h (i,j)) (j,x)) (fun _ _ => abs_nonneg _) (mem_univ (k (i,j)))).trans(Finset.single_le_sum (f:=fun x => ∑ c:B,H (i,x) (j,c)) (fun _ _=> Finset.sum_nonneg (fun _ _=>abs_nonneg _)) (mem_univ (h (i,j))))have hi j c :avg w (fun i=>∑ b : B,H (i,b) (j,c))≤ T*(R*ε) := byhave hg : ∀ i : I,(∑ b:B,H (i,b) (j,c))=T*avg unif (fun b=> H (i,b) (j,c)) := byintro i; simp only [avg,unif_apply,← Finset.mul_sum]change _ = T*(T⁻¹ * _)rw [←mul_assoc,mul_inv_cancel₀ ht.ne',one_mul]simp_rw [hg,avg_mul']refine mul_le_mul_of_nonneg_left ?_ ht.le; rw [← pairW_avg w unif (fun p : I×B=>H p (j,c))]exact he _change avg (pairW w v) _ ≤ T^2*(R*ε)rw [pairW_avg,avg_avg]refine hv.avg_le fun j=> ?_have hz i : ∑ b:B,∑ c:B,H (i,b) (j,c)=∑ c:B,∑ b:B,H (i,b) (j,c) :=Finset.sum_commapply (avg_mono hw.nz (fun i => (hh i j).trans_eq (hz i))).transrw [avg_sum]exact (Finset.sum_le_sum fun i _=>hi j i).trans_eq (bysimp only [sum_const,nsmul_eq_mul,Finset.card_univ,T,num]; ring)set_option maxHeartbeats 1200000 intheorem global_net (R ε : ℝ) (hr : 0<R) (hε : 0<ε) :∃ δ : ℝ,0<δ ∧ ∀ r : ℕ,∃ l : ℕ,∀ (I J A : Type) [Fintype I] [Fintype J] [Fintype A](w : Wgt I) (v : Wgt J) (u : Wgt A), IsLaw w→IsLaw v →IsLaw u →∀ (P : I→Wgt A→Prop) (Q : J→Wgt A→Prop), (∀ i,roster (P i) r δ) →(∀ i,roster (Q i) r δ) →∃ k : ℕ,k ≤ l∧ ∃ p:A→Fin k,∀ f g:I × J→Wgt A,(∀ i,P i.1 (f i)) → (∀ i,Q i.2 (g i)) →avg (pairW w v) (fun i => |rebate u (mcut R u (f i)) (mcut R u (g i)) p|)≤ ε := byclassicallet δ := ε/(8*R)have hd : 0<δ := by positivityrefine ⟨δ,hd,fun r=>?_⟩let B:=Fin (r+1); let t:=num Bhave ht : 0<t := by unfold t num; positivitylet c:=ε/(2*(t^2)*R)have hc : 0<c := by positivityobtain ⟨l,hl⟩:= erosive R c hr.le hcrefine ⟨l,fun I J A _ _ _ w v u hw hv hu P Q hp hq=>?_⟩choose s hs h1 using fun i=> roster_clip R u hu hr.le (P i) r δ (hp i)choose y hy h2 using fun i=> roster_clip R u hu hr.le (Q i) r δ (hq i)let F : I×B→Wgt A := uncurry slet G : J×B→Wgt A := uncurry yobtain ⟨m,hm,p,hP⟩:= hl A (I×B) (pairW w unif) u F (pairW_law hw unif_law) hu (fun i j=> hs _ _ _)refine ⟨m,hm,p,fun f g hf hg=>?_⟩let f' (i : I×J):= mcut R u (f i)let g' (i : I×J):= mcut R u (g i)choose a hA using fun i:I×J => h1 i.1 (f i) (hf i)choose b hB using fun i:I×J => h2 i.2 (g i) (hg i)let H (i:I×J) := |rebate u (F (i.1,a i)) (G (i.2,b i)) p|let D:=pairW w v; have hD:= pairW_law hw hvhave he := rollup u w v hw hv hu F G a b R hr (fun i j=> hy _ _ _) p c hPhave hb : 0≤2*R := by linarith only [hr]have hi (i:I×J) : |rebate u (f' i) (g' i) p|≤ H i+(δ*(4*R)) := bylet A' := F (i.1,a i); let B' := G (i.2,b i)have h1 (j) : |g' i j|≤R := byrw [abs_of_nonneg ((mcut_range _ _ _ hr.le j).1)]exact (mcut_range _ _ _ hr.le j).2have h3 : |rebate u (f' i) (g' i) p - rebate u A' (g' i) p|≤ δ*(2*R) := byexact (rebate_cost u _ _ A' p hu.nz R hr.le h1).trans (mul_le_mul_of_nonneg_right (hA i) hb)have h4 : |rebate u A' (g' i) p - rebate u A' B' p|≤δ*(2*R) := byrw [rebate_sym u A',rebate_sym u A']exact (rebate_cost u _ _ B' p hu.nz R hr.le (fun i=>hs _ _ _)).trans(mul_le_mul_of_nonneg_right (hB i) hb)let U:=rebate u A' B' plet X:=rebate u (f' i) (g' i) phave hz:= (abs_sub_le X (rebate u A' (g' i) p) U).trans (add_le_add h3 h4)calc |X| = |(X-U)+U| := by rw [sub_add_cancel]_ ≤ _ := ((abs_add_le _ _).trans (add_le_add_left hz _)).trans_eq (bychange _+ |U| = |U|+δ*(4*R)ring)refine (avg_mono hD.nz hi).trans ?_rw [avg_add,hD.avg_const]exact (add_le_add_left he _).trans_eq (bychange t^2*(R*c)+δ*(4*R)=_unfold δ c; field_simp; ring)end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112import OAI.Combinatorics.HadwigerCounterexample.PointAtomVanishingimport OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBoundsnamespace OAI/-! # Common Predictions -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module LinearMap Function Finset Submoduleopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ}abbrev Augur (p : Shape) (N : ℕ) := ∀ t : Tag p.g,F→AtomKey (p:=p) t N→Fdef mismatch (p : Shape) {n N : ℕ} (g : Augur p N) (F : Pdual p n) (l : Tag p.g)(s : Label p.b) (f : Flavor p.g) (x : Orient p n N) (y : Knobs p.g n) :=F (useAtom p l s f y)≠ g l (dialed p l f y) (keyOne p l s (lit f l y) x)def postulates (p : Shape) (o : Orient p n N)(g : Augur p N) (w : Pdual p n) (E : Finset (Label p.b)) (δ : ℝ) :=∀ s,s∉E→∀ l f, pr (spins p n) (fun i => mismatch p g w l s f o i)≤δdef yoke (p : Shape) (m : Mixer p n) (x : UnitType p n N) (i : Bool)(u : Profile p n) (α : F) : Pdual p n :=innerP p x i + (Tsym m u + α • role p n)def claimed (p : Shape) (x : UnitType p n N)(g : Bool→Augur p N) (m : Mixer p n)(w : Bool→Profile p n) (α : Bool→F) (L : Bool → Finset (Label p.b)) (δ : ℝ) :=∀ i,postulates p (onSide x i) (g i) (yoke p m x i (w i) (α i)) (L i) δdef silent (w : Pdual p n) := ∀ x, x∈Xspace p n → w x=0def fixStar (p : Shape) (n : ℕ) (l : Tag p.g) :Moment p n →ₗ[F] Profile p n :=cut p n ∘ₗ LinearMap.single F (fun _ : Tag p.g => Moment p n) ltheorem fix_one (p : Shape) (n : ℕ) (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :atom p l s z=fixStar p n l (mom p s z) := rfltheorem atom_silent {w : Pdual p n}(h : ∀ l s z,allows l z → w (atom p l s z)=0) : silent w := byclassicalintro x hxobtain ⟨u,hu,rfl⟩ := mem_X.mp hxhave he l : Wtag p n l≤LinearMap.ker (w∘ₗfixStar p n l) := byrefine Submodule.span_le.mpr ?_rintro x ⟨s,z,hz,rfl⟩exact h l s z hzhave ht : (cut p n u)=∑ i : Tag p.g,fixStar p n i (u i) := byhave hh := Finset.univ_sum_single uunfold fixStarsimp_rw [LinearMap.comp_apply, ← map_sum (cut p n)]exact congrArg (cut p n) (Eq.symm hh)rw [ht,map_sum]; exact Finset.sum_eq_zero fun i _=>he _ (hu i)theorem shared_base (p : Shape) (hn : 2*p.r≤n) (hr : 1 ≤ p.r) (hg : 0 < p.g) :∃ (z : Base p.g n) (s : Label p.b), (∀ l, allows l z) ∧ eta p n (mom p s z)=1 := byclassicallet l : Tag p.g := ⟨0,hg⟩let f : Flavor p.g:= Flavor.sharedOnlylet i := (Sum.inr () : ProbeIdx p.g)let v : Digest p.g := Pi.single i 1have hx : v.feasible l f := byrintro (x|⟨⟩) _· exact Pi.single_eq_of_ne (by simp [i]) _exact (‹¬_› trivial).elimhave he := exists_of_pr_pos (spins_law p n).nz((scanPrice_pos p).trans_le (scan_fraction (n:=n) l f v hr hn hx))obtain ⟨x,h,_⟩ := herefine ⟨lit f l x,0,fun i d t h k => ite_eq_right (by simp [f,Flavor.keeps]),?_⟩rw [←etaScan,h]; simp [v,Digest.sumBit,Digest.diagO,i]theorem atom_union (p : Shape) (n : ℕ) (z : Base p.g n) (s : Label p.b) :∑ i:Tag p.g,atom p i s z=0 := bysimp_rw [atom,←map_sum (cut p n)]rw [Finset.univ_sum_single (fun i : Tag p.g => mom p s z)]funext xexact char_two (mom p s z)set_option maxHeartbeats 800000 intheorem exact_vat (w : Pdual p n) (E : Finset (Label p.b)) (g : F)(hE : (E.card:ℝ)<bp ((p.b:ℝ)-2*p.j))(hj : Odd p.g) (hn : 2*p.r≤n) (hr : 1≤p.r)(h : ∀ l s,s∉E → pr (spins p n)(fun x => w (useAtom p l s Flavor.full x)≠g *dialed p l Flavor.full x)<1/4) :g=0∧ silent w := byclassicallet Q l := w ∘ₗ fixStar p n l - g • eta p nhave hi (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :Q l (mom p s z)= w (atom p l s z)-g*eta p n (mom p s z) := rflhave hh (l s z) (hz : allows l z) : Q l (mom p s z)=0 := byhave he (s) (hs : s∉E) :pr (spins p n) (fun x=> Q l (mom p s (lit Flavor.full l x))≠0)<1/4 := bysimp_rw [hi,←etaScan p l s Flavor.full]simpa only [sub_ne_zero,useAtom,dialed] using h l s hsexact vat_excluded z E (Q l) (fun i h=>vat_erase l i (Q l) (he i h) z hz) hE ssimp_rw [hi] at hhhave he l s z (h : allows l z) : w (atom p l s z) =g*eta p n (mom p s z) :=sub_eq_zero.mp (hh l s z h)obtain ⟨z,s,hz,hb⟩ := shared_base p hn hr (by obtain ⟨_,hh⟩ := hj; omega)have h0 : g=0 := byhave ht : w (∑ l:Tag p.g,atom p l s z)=0 := by rw [atom_union,map_zero]rw [map_sum] at htsimp_rw [he _ s z (hz _),hb,mul_one] at htsimpa only [Finset.sum_const, Finset.card_univ,Tag,Fintype.card_fin,odd_smul_bit hj] using htrefine ⟨h0,atom_silent (fun i s z h=> (he i s z h).trans ?_)⟩rw [h0,zero_mul]end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112import OAI.Combinatorics.HadwigerCounterexample.PointAtomVanishingimport OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBoundsnamespace OAI/-! # Common Predictions -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module LinearMap Function Finset Submoduleopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ}abbrev Augur (p : Shape) (N : ℕ) := ∀ t : Tag p.g,F→AtomKey (p:=p) t N→Fdef mismatch (p : Shape) {n N : ℕ} (g : Augur p N) (F : Pdual p n) (l : Tag p.g)(s : Label p.b) (f : Flavor p.g) (x : Orient p n N) (y : Knobs p.g n) :=F (useAtom p l s f y)≠ g l (dialed p l f y) (keyOne p l s (lit f l y) x)def postulates (p : Shape) (o : Orient p n N)(g : Augur p N) (w : Pdual p n) (E : Finset (Label p.b)) (δ : ℝ) :=∀ s,s∉E→∀ l f, pr (spins p n) (fun i => mismatch p g w l s f o i)≤δdef yoke (p : Shape) (m : Mixer p n) (x : UnitType p n N) (i : Bool)(u : Profile p n) (α : F) : Pdual p n :=innerP p x i + (Tsym m u + α • role p n)def claimed (p : Shape) (x : UnitType p n N)(g : Bool→Augur p N) (m : Mixer p n)(w : Bool→Profile p n) (α : Bool→F) (L : Bool → Finset (Label p.b)) (δ : ℝ) :=∀ i,postulates p (onSide x i) (g i) (yoke p m x i (w i) (α i)) (L i) δdef silent (w : Pdual p n) := ∀ x, x∈Xspace p n → w x=0def fixStar (p : Shape) (n : ℕ) (l : Tag p.g) :Moment p n →ₗ[F] Profile p n :=cut p n ∘ₗ LinearMap.single F (fun _ : Tag p.g => Moment p n) ltheorem fix_one (p : Shape) (n : ℕ) (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :atom p l s z=fixStar p n l (mom p s z) := rfltheorem atom_silent {w : Pdual p n}(h : ∀ l s z,allows l z → w (atom p l s z)=0) : silent w := byclassicalintro x hxobtain ⟨u,hu,rfl⟩ := mem_X.mp hxhave he l : Wtag p n l≤LinearMap.ker (w∘ₗfixStar p n l) := byrefine Submodule.span_le.mpr ?_rintro x ⟨s,z,hz,rfl⟩exact h l s z hzhave ht : (cut p n u)=∑ i : Tag p.g,fixStar p n i (u i) := byhave hh := Finset.univ_sum_single uunfold fixStarsimp_rw [LinearMap.comp_apply, ← map_sum (cut p n)]exact congrArg (cut p n) (Eq.symm hh)rw [ht,map_sum]; exact Finset.sum_eq_zero fun i _=>he _ (hu i)theorem shared_base (p : Shape) (hn : 2*p.r≤n) (hr : 1 ≤ p.r) (hg : 0 < p.g) :∃ (z : Base p.g n) (s : Label p.b), (∀ l, allows l z) ∧ eta p n (mom p s z)=1 := byclassicallet l : Tag p.g := ⟨0,hg⟩let f : Flavor p.g:= Flavor.sharedOnlylet i := (Sum.inr () : ProbeIdx p.g)let v : Digest p.g := Pi.single i 1have hx : v.feasible l f := byrintro (x|⟨⟩) _· exact Pi.single_eq_of_ne (by simp [i]) _exact (‹¬_› trivial).elimhave he := exists_of_pr_pos (spins_law p n).nz((scanPrice_pos p).trans_le (scan_fraction (n:=n) l f v hr hn hx))obtain ⟨x,h,_⟩ := herefine ⟨lit f l x,0,fun i d t h k => ite_eq_right (by simp [f,Flavor.keeps]),?_⟩rw [←etaScan,h]; simp [v,Digest.sumBit,Digest.diagO,i]theorem atom_union (p : Shape) (n : ℕ) (z : Base p.g n) (s : Label p.b) :∑ i:Tag p.g,atom p i s z=0 := bysimp_rw [atom,←map_sum (cut p n)]rw [Finset.univ_sum_single (fun i : Tag p.g => mom p s z)]funext xexact char_two (mom p s z)set_option maxHeartbeats 800000 intheorem exact_vat (w : Pdual p n) (E : Finset (Label p.b)) (g : F)(hE : (E.card:ℝ)<bp ((p.b:ℝ)-2*p.j))(hj : Odd p.g) (hn : 2*p.r≤n) (hr : 1≤p.r)(h : ∀ l s,s∉E → pr (spins p n)(fun x => w (useAtom p l s Flavor.full x)≠g *dialed p l Flavor.full x)<1/4) :g=0∧ silent w := byclassicallet Q l := w ∘ₗ fixStar p n l - g • eta p nhave hi (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :Q l (mom p s z)= w (atom p l s z)-g*eta p n (mom p s z) := rflhave hh (l s z) (hz : allows l z) : Q l (mom p s z)=0 := byhave he (s) (hs : s∉E) :pr (spins p n) (fun x=> Q l (mom p s (lit Flavor.full l x))≠0)<1/4 := bysimp_rw [hi,←etaScan p l s Flavor.full]simpa only [sub_ne_zero,useAtom,dialed] using h l s hsexact vat_excluded z E (Q l) (fun i h=>vat_erase l i (Q l) (he i h) z hz) hE ssimp_rw [hi] at hhhave he l s z (h : allows l z) : w (atom p l s z) =g*eta p n (mom p s z) :=sub_eq_zero.mp (hh l s z h)obtain ⟨z,s,hz,hb⟩ := shared_base p hn hr (by obtain ⟨_,hh⟩ := hj; omega)have h0 : g=0 := byhave ht : w (∑ l:Tag p.g,atom p l s z)=0 := by rw [atom_union,map_zero]rw [map_sum] at htsimp_rw [he _ s z (hz _),hb,mul_one] at htsimpa only [Finset.sum_const, Finset.card_univ,Tag,Fintype.card_fin,odd_smul_bit hj] using htrefine ⟨h0,atom_silent (fun i s z h=> (he i s z h).trans ?_)⟩rw [h0,zero_mul]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130import OAI.Combinatorics.HadwigerCounterexample.PairedEventBoundsnamespace OAI/-! # Compatible Option Realization -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Function Module LinearMapopen scoped BigOperatorsvariable {p:Shape} {n N M K s0:ℕ}namespace StatusAnalysisvariable {q:Format} {d e: Rates} {b:Bool}abbrev Stalls (p:Shape) := Bool→Finset (Label p.b)def booths (p:Shape) (K:ℕ) (s: Plan p n) (H:Stalls p) :=(∀ i,(H i).card≤frameBills p.g K) ∧∀ i j, protectedBy p (sPin s j i) (qorth K) (H i)theorem buildBooths (K:ℕ) (s:Plan p n) (h:planRank s≤K)(hj:(K+1)*qorth K≤p.j+1) :∃ H,booths p K s H := byclassicalchoose H hH hG using fun i : Bool=> pin_protection s i K (qorth K) h hjexact ⟨H,hH,hG⟩theorem shelter (K :ℕ) (S:Pin p n N) (t : Quill p q d b) (z : Tagging p (Messenger q)) (H:Stalls p)(h:booths p K S.sp H) (hp : Injective t.sel)(ht:∀ i:Messenger q,t.sel i∉H (parcel b i))(hg : ∀ i,1≤q i ∧ q i≤7) : t.penSpace z S K := byintro x ilet v:=(t.pen z).draw xrefine ⟨H i,h.2 i,fun j hj=>?_,?_,hp.injOn⟩· have he : parcel b j=i := Finset.mem_filter.mp hj|>.2rw [←he]; exact ht jexact (Volley.here_card v (shots_ok b v rfl hg) i).trans (by unfold qorth; omega)theorem sizedCharts (K:ℕ) (w:LeafMixture p n N) (t:Station p n N K w) (ht:t.bank)(i:w.T) (h:planRank (w.pin i.val).sp≤K) :∃ d:Stakes K,charted (t.cAxes i (toRates d)) (w.pin i.val).sp := bylet s:=(w.pin i.val).splet d (i:Nodes):= dim (effective s i)have hd i : d i < K^2+1 := Nat.lt_of_le_of_lt((effective_dim s i).trans (by gcongr)) (Nat.lt_succ_self _)exact ⟨fun i=>⟨d i,hd i⟩,ht.1 i⟩structure Fabric (p:Shape) (q:Format) (d:Rates) (b:Bool) wheresel : Messenger q → Label p.bflav : Messenger q → Flavor p.gamp : Amounts p q d bnamespace Fabricvariable (w:Fabric p q d b) (t:Tagging p (Messenger q))def hang (s:Script p (Messenger q)) : Quill p q d b :=⟨w.sel,w.flav,w.amp,s⟩def up (w:Fabric p q d b) (t:Tagging p (Messenger q)) (z: Messenger q→F) :=(w.hang 0).moral t zend Fabricvariable {i j:Bool} {L:ℕ}set_option maxHeartbeats 1200000 intheorem optionVia (q:Format) (d e : Rates) (s t:Pin p n N) (T:Cross p n) (K:ℕ)(ha: tableInj s.sp t.sp T) (hb : tableInj t.sp s.sp (reciprocal p T))(p':Tagging p (Messenger q)) (x:Charts p n d) (y:Charts p n e)(hx:charted x s.sp) (hy:charted y t.sp)(f:Fabric p q d true) (g:Fabric p q e false)(hs h:Stalls p) (hm:booths p K s.sp hs) (hu : booths p K t.sp h)(hf:∀ i,f.sel i∉ hs (parcel true i)) (hg:∀ i,g.sel i∉ h (parcel false i))(z:Messenger q→F) (hF:f.up p' z)(hG:g.up p' z)(hj : 1≤p.J) (h2: 2≤p.g) (h₀:∀ i,1≤q i∧q i≤7)(he:speak _ _ (sendSum z f.amp g.amp)=(hailing p x y T,0)) :∃ (a b:Script p (Messenger q)),Typus.chances ⟨p',z,f.hang a,g.hang b⟩ x y s t T K := byobtain ⟨hQ,hR,hL,hS⟩:= (spoken x y T z f.amp g.amp).mp heobtain ⟨a,ha'⟩:= proclaim_script true f.amp g.amp p' y (reciprocal p T) hR (fun i=>(h₀ i).1)hS h2 hjhave hh : rhyme g.amp f.amp := fun i=> (add_comm ..).trans (hR i)obtain ⟨b,hb'⟩:= proclaim_script false g.amp f.amp p' x T hh (fun i=>(h₀ i).1)hL h2 hjexact ⟨a,b, ⟨h₀,hF,hG,hQ,hR,ha',hb'⟩,⟨hx,shelter K s (f.hang a) p' hs hm hF.1 hf h₀,hL,ha⟩,⟨hy,shelter K t (g.hang b) p' h hu hG.1 hg h₀,hS,hb⟩⟩def berthTicket (a b:Pin p n N) (T: Cross p n)(x:UnitType p n N × UnitType p n N) :=tableInj a.sp b.sp T ∧ tableInj b.sp a.sp (reciprocal p T)∧ fitsTable a.sp b.sp T (actual p x.1 x.2)theorem issueTicket (x y:UnitType p n N) (w : LeafMixture p n N) (t:Station p n N K w)(i j:w.T) (ha:apart w.T)(hx:x∈i.val) (hy:y∈j.val) (ht:t.bank)(he : secureAt p w.rooting (x,y)) :∃ k, berthTicket (w.pin i.val) (w.pin j.val) (t.mails i j k) (x,y) := byobtain ⟨k,hk⟩:=ht.2 i j (actual p x y)obtain ⟨h1,h2⟩:=helet a:= w.pin i.val; let b:= w.pin j.valhave hh : w.rooting x=a.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha i.property hx)have hg : w.rooting y=b.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha j.property hy)change tableInj (w.rooting x) (w.rooting y) (actual p x y) at h1change tableInj (w.rooting y) (w.rooting x) (actual p y x) at h2rw [hh,hg] at h1 h2rw [← reciprocal_actual] at h2exact ⟨k, fits_inj hk h1,fits_inj (fits_recip hk) h2,hk⟩theorem berth_flags (a b:Pin p n N) (T:Cross p n) {x:UnitType p n N × UnitType p n N}(h:berthTicket a b T x) (ha:a.agree x.1) (hb:b.agree x.2) :tableFlag a b T x.1 ∧ tableFlag b a (reciprocal p T) x.2 := byhave hg:=fits_recip h.2.2; rw [reciprocal_actual] at hgexact ⟨fits_flag T _ a b x.1 h.2.2 (flag_actual _ _ hb),fits_flag _ _ b a x.2 hg (flag_actual _ _ ha)⟩def cardTone (m:BMark p n N) (x:UnitType p n N) (T:Cross p n) (j:Bool) : F :=∑ i:Bool,contract p T i j (m x i)theorem actualTone (m:BMark p n N) (a b : UnitType p n N) (j:Bool) :cardTone m a (actual p a b) j = tone p b (unary j) (delta m a) := byrw [lone]unfold cardTone deltarw [map_add,Fintype.sum_bool]simp_rw [contract_actual]; rfltheorem fitsTone {w v: Plan p n} {T U:Cross p n}(m:BMark p n N) (x:UnitType p n N)(h:fitsTable w v T U) (hx:∀ i,m x i∈effective w i) (j) :cardTone m x T j=cardTone m x U j :=Finset.sum_congr rfl (fun i _=>fits_contract h i j _ (hx i))end StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130import OAI.Combinatorics.HadwigerCounterexample.PairedEventBoundsnamespace OAI/-! # Compatible Option Realization -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Function Module LinearMapopen scoped BigOperatorsvariable {p:Shape} {n N M K s0:ℕ}namespace StatusAnalysisvariable {q:Format} {d e: Rates} {b:Bool}abbrev Stalls (p:Shape) := Bool→Finset (Label p.b)def booths (p:Shape) (K:ℕ) (s: Plan p n) (H:Stalls p) :=(∀ i,(H i).card≤frameBills p.g K) ∧∀ i j, protectedBy p (sPin s j i) (qorth K) (H i)theorem buildBooths (K:ℕ) (s:Plan p n) (h:planRank s≤K)(hj:(K+1)*qorth K≤p.j+1) :∃ H,booths p K s H := byclassicalchoose H hH hG using fun i : Bool=> pin_protection s i K (qorth K) h hjexact ⟨H,hH,hG⟩theorem shelter (K :ℕ) (S:Pin p n N) (t : Quill p q d b) (z : Tagging p (Messenger q)) (H:Stalls p)(h:booths p K S.sp H) (hp : Injective t.sel)(ht:∀ i:Messenger q,t.sel i∉H (parcel b i))(hg : ∀ i,1≤q i ∧ q i≤7) : t.penSpace z S K := byintro x ilet v:=(t.pen z).draw xrefine ⟨H i,h.2 i,fun j hj=>?_,?_,hp.injOn⟩· have he : parcel b j=i := Finset.mem_filter.mp hj|>.2rw [←he]; exact ht jexact (Volley.here_card v (shots_ok b v rfl hg) i).trans (by unfold qorth; omega)theorem sizedCharts (K:ℕ) (w:LeafMixture p n N) (t:Station p n N K w) (ht:t.bank)(i:w.T) (h:planRank (w.pin i.val).sp≤K) :∃ d:Stakes K,charted (t.cAxes i (toRates d)) (w.pin i.val).sp := bylet s:=(w.pin i.val).splet d (i:Nodes):= dim (effective s i)have hd i : d i < K^2+1 := Nat.lt_of_le_of_lt((effective_dim s i).trans (by gcongr)) (Nat.lt_succ_self _)exact ⟨fun i=>⟨d i,hd i⟩,ht.1 i⟩structure Fabric (p:Shape) (q:Format) (d:Rates) (b:Bool) wheresel : Messenger q → Label p.bflav : Messenger q → Flavor p.gamp : Amounts p q d bnamespace Fabricvariable (w:Fabric p q d b) (t:Tagging p (Messenger q))def hang (s:Script p (Messenger q)) : Quill p q d b :=⟨w.sel,w.flav,w.amp,s⟩def up (w:Fabric p q d b) (t:Tagging p (Messenger q)) (z: Messenger q→F) :=(w.hang 0).moral t zend Fabricvariable {i j:Bool} {L:ℕ}set_option maxHeartbeats 1200000 intheorem optionVia (q:Format) (d e : Rates) (s t:Pin p n N) (T:Cross p n) (K:ℕ)(ha: tableInj s.sp t.sp T) (hb : tableInj t.sp s.sp (reciprocal p T))(p':Tagging p (Messenger q)) (x:Charts p n d) (y:Charts p n e)(hx:charted x s.sp) (hy:charted y t.sp)(f:Fabric p q d true) (g:Fabric p q e false)(hs h:Stalls p) (hm:booths p K s.sp hs) (hu : booths p K t.sp h)(hf:∀ i,f.sel i∉ hs (parcel true i)) (hg:∀ i,g.sel i∉ h (parcel false i))(z:Messenger q→F) (hF:f.up p' z)(hG:g.up p' z)(hj : 1≤p.J) (h2: 2≤p.g) (h₀:∀ i,1≤q i∧q i≤7)(he:speak _ _ (sendSum z f.amp g.amp)=(hailing p x y T,0)) :∃ (a b:Script p (Messenger q)),Typus.chances ⟨p',z,f.hang a,g.hang b⟩ x y s t T K := byobtain ⟨hQ,hR,hL,hS⟩:= (spoken x y T z f.amp g.amp).mp heobtain ⟨a,ha'⟩:= proclaim_script true f.amp g.amp p' y (reciprocal p T) hR (fun i=>(h₀ i).1)hS h2 hjhave hh : rhyme g.amp f.amp := fun i=> (add_comm ..).trans (hR i)obtain ⟨b,hb'⟩:= proclaim_script false g.amp f.amp p' x T hh (fun i=>(h₀ i).1)hL h2 hjexact ⟨a,b, ⟨h₀,hF,hG,hQ,hR,ha',hb'⟩,⟨hx,shelter K s (f.hang a) p' hs hm hF.1 hf h₀,hL,ha⟩,⟨hy,shelter K t (g.hang b) p' h hu hG.1 hg h₀,hS,hb⟩⟩def berthTicket (a b:Pin p n N) (T: Cross p n)(x:UnitType p n N × UnitType p n N) :=tableInj a.sp b.sp T ∧ tableInj b.sp a.sp (reciprocal p T)∧ fitsTable a.sp b.sp T (actual p x.1 x.2)theorem issueTicket (x y:UnitType p n N) (w : LeafMixture p n N) (t:Station p n N K w)(i j:w.T) (ha:apart w.T)(hx:x∈i.val) (hy:y∈j.val) (ht:t.bank)(he : secureAt p w.rooting (x,y)) :∃ k, berthTicket (w.pin i.val) (w.pin j.val) (t.mails i j k) (x,y) := byobtain ⟨k,hk⟩:=ht.2 i j (actual p x y)obtain ⟨h1,h2⟩:=helet a:= w.pin i.val; let b:= w.pin j.valhave hh : w.rooting x=a.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha i.property hx)have hg : w.rooting y=b.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha j.property hy)change tableInj (w.rooting x) (w.rooting y) (actual p x y) at h1change tableInj (w.rooting y) (w.rooting x) (actual p y x) at h2rw [hh,hg] at h1 h2rw [← reciprocal_actual] at h2exact ⟨k, fits_inj hk h1,fits_inj (fits_recip hk) h2,hk⟩theorem berth_flags (a b:Pin p n N) (T:Cross p n) {x:UnitType p n N × UnitType p n N}(h:berthTicket a b T x) (ha:a.agree x.1) (hb:b.agree x.2) :tableFlag a b T x.1 ∧ tableFlag b a (reciprocal p T) x.2 := byhave hg:=fits_recip h.2.2; rw [reciprocal_actual] at hgexact ⟨fits_flag T _ a b x.1 h.2.2 (flag_actual _ _ hb),fits_flag _ _ b a x.2 hg (flag_actual _ _ ha)⟩def cardTone (m:BMark p n N) (x:UnitType p n N) (T:Cross p n) (j:Bool) : F :=∑ i:Bool,contract p T i j (m x i)theorem actualTone (m:BMark p n N) (a b : UnitType p n N) (j:Bool) :cardTone m a (actual p a b) j = tone p b (unary j) (delta m a) := byrw [lone]unfold cardTone deltarw [map_add,Fintype.sum_bool]simp_rw [contract_actual]; rfltheorem fitsTone {w v: Plan p n} {T U:Cross p n}(m:BMark p n N) (x:UnitType p n N)(h:fitsTable w v T U) (hx:∀ i,m x i∈effective w i) (j) :cardTone m x T j=cardTone m x U j :=Finset.sum_congr rfl (fun i _=>fits_contract h i j _ (hx i))end StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import OAI.Combinatorics.HadwigerCounterexample.PredictionClassBoundsnamespace OAI/-! # Compatible Pair Tests -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Function Module LinearMap Matrixopen scoped BigOperators Topologyopen Templatenamespace StatusAnalysisopen PreparationParameters Station PredictionClass Club Guild DualAnalysisvariable {p:Shape} {n N M r s0:ℕ}{w:rhythms p M} {b:PreparationParameters}set_option maxHeartbeats 1800000 intheorem foretold (w:rhythms p M) (m:cycleM p) (x:Sketch p M)(v:Station p n (M*n) b.pins (w n)) (hv:v.bank)(U:Wgt (UnitType p n (M*n))) (h:Lead U (w n) (m n) b)(hE:AnalyticParameters p M b s0)(hm:(w n).within (engrave x b m w n))(hn:2*p.r≤n) (Y:Silhouette p (M*n) r) (f:Bool→Pulsar p r){τ ε δ η a d0:ℝ} (hh: hue x.c Y f (fun i=>x.g i n) x.α τ)(hε:0<ε) (hp:Jubilee p b.pins ε η)(hB:supportBudget p b.pins η a)(hz:x.ε n ≤scanPrice p*ε) (ht:10*ε≤τ) (hT:2*τ<1)(hF:Beams b (m n) Y (w n) U v a ε δ d0) (i : ViewPair p n (M*n) (w n))(hx:cirque (w n) U i ≠0)(hg1:gauze p δ δ Y (m n) b.pins i.1.2) (hg2:gauze p δ δ Y (m n) b.pins i.2.2)(hC:matchProg x n (i.1.2,i.2.2))(hS:secureAt p (w n).rooting (i.1.2,i.2.2)) :eligiblePair v (m n) i.1 i.2 Y a := byclassicallet s:=w n; let μ:= U; let K:=b.pinslet X:=i.1.2; let Z:=i.2.2let j:=i.1.1; let k:=i.2.1let L:=troupe s μhave hs : L i.1≠0:=left_ne_zero_of_mul hxhave hl : L i.2 ≠0:=right_ne_zero_of_mul hxhave hX := troupe_home h i.1 hshave hZ:= troupe_home h i.2 hlhave hL i:= (h.strength.leaf _ (Subtype.prop (show s.T from i))).boundobtain ⟨g,hg⟩:= ready_loupe s v hv hE hLlet d:= g.r j; let e:=g.r klet t:=v.cAxes j (toRates d); let u:=v.cAxes k (toRates e)let A:=g.H j; let B:=g.H klet m':=x.m nlet F:=x.L n X; let H:=x.L n Zlet P:= A⊔F; let Q:=B⊔ Hobtain ⟨⟨h1,h2⟩,h3,h4⟩:=hm _ j.property X hX.1obtain ⟨⟨h1',h2'⟩,h3',h4'⟩:=hm _ k.property Z hZ.1let M0:=s.pin j.val; let M1:=s.pin k.valhave he (i):m' X i∈ effective M0.sp i:= (hX.2.1 ▸ (h1 i).2)have he' i:m' Z i∈effective M1.sp i:= (hZ.2.1 ▸ (h1' i).2)choose T hP using fun i=> show m' X i∈LinearMap.range (t i) from(hg.charts j i).1.symm ▸ he ichoose S hQ using fun i=> show m' Z i∈ LinearMap.range (u i) from(hg.charts k i).1.symm ▸ he' ilet Γ:PredictionData p (toRates d) (toRates e) r := ⟨x.α,f,T,S⟩have ht0:= hE.enter.firstlet M' := m nlet D:=wisp p Y; let X0:=wake p Y M' X t; let X1:=wake p Y M' Z ulet β:=trimBeta p Klet C:=stellar D X0 X1 η P Qhave hk0 i t:=Nat.lt_succ_iff.mp (g.r i t).isLthave hA: reports p r D X0 β δ:=routeLive s g v hg M' hE hn i.1 Y δ hF.haze.1 (hL _) hg1have hB1: reports p r D X1 β δ:=routeLive s g v hg M' hE hn i.2 Y δ hF.haze.1 (hL _) hg2have hR := boothseek b _ (g.H j) F (hg.baseline j) hE (fun i=>(h1 i).1)have hR' := boothseek b _ (g.H k) H (hg.baseline k) hE (fun i=>(h1' i).1)have hG: rich C:= plenitude hF.soft hA hB1 ht0.hG P Q hR hR' (trimBeta_pos ..) hp.poshp.sturdyR (hk0 _) (hk0 _)obtain ⟨E,hE0,hr⟩:=stable C hGobtain ⟨y,hy⟩:= issueTicket X Z s v j k h.strength.part hX.1 hZ.1 hv hSlet U0:=v.mails j k yhave hQ': x.c.compatible x.α (glint p (m' X)) (cardTone m' X U0,cardTone m' Z(reciprocal p U0)) := bychange glint p _=_ at h3have he1 l: cardTone m' X U0 l=(quench p (delta m') (X,Z)).1 l:=(fitsTone m' X hy.2.2 he l).trans (actualTone m' X Z l)have he2 l:cardTone m' Z (reciprocal p U0) l=(quench p (delta m') (X,Z)).2 l:= byhave hg := fits_recip hy.2.2; rw [reciprocal_actual] at hgexact (fitsTone m' Z hg he' l).trans (actualTone m' Z X l)rw [funext he1,funext he2,h3]; exact hChave hc: countStory p K η δ ε β D:=⟨hF.soft,(trimBeta_pos ..).le,hε.le,hp.pos.le,hp.book,hp.low⟩have hv : Γ.colored D X0 X1 P Q (2*ε):= byconstructor· exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) t T m' X F P le_sup_righthP hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2 i j hj k f).trans hz) h4 hg1exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) u S m' Z H Q le_sup_righthQ hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2' i j hj k f).trans hz) h4' hg2have hZ0 := laysScore p K Y (m n) D X Z m' (toRates d) (toRates e) t u x.c Γ P QE η ε β δ τ hP hQ (paintChorus _ _ f _ x.α τ hh T S) (by linarith only [hε,ht]) hT hchA hB1 hv (hk0 _) (hk0 _) ht0.hG ht hR hR' hE0 U0 (h3.trans h3'.symm) hQ' hGexact inform (w n) v _ Y i.1 i.2 hX.2.2.1 hZ.2.2.1 hX.2.2.2 hZ.2.2.2 d e (hg.charts _)(hg.charts _) hB A B (hg.baseline _) (hg.baseline _) P Q le_sup_left le_sup_left ht0.hGhE.jump hp.pos y hy E hr hZ0end StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import OAI.Combinatorics.HadwigerCounterexample.PredictionClassBoundsnamespace OAI/-! # Compatible Pair Tests -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Function Module LinearMap Matrixopen scoped BigOperators Topologyopen Templatenamespace StatusAnalysisopen PreparationParameters Station PredictionClass Club Guild DualAnalysisvariable {p:Shape} {n N M r s0:ℕ}{w:rhythms p M} {b:PreparationParameters}set_option maxHeartbeats 1800000 intheorem foretold (w:rhythms p M) (m:cycleM p) (x:Sketch p M)(v:Station p n (M*n) b.pins (w n)) (hv:v.bank)(U:Wgt (UnitType p n (M*n))) (h:Lead U (w n) (m n) b)(hE:AnalyticParameters p M b s0)(hm:(w n).within (engrave x b m w n))(hn:2*p.r≤n) (Y:Silhouette p (M*n) r) (f:Bool→Pulsar p r){τ ε δ η a d0:ℝ} (hh: hue x.c Y f (fun i=>x.g i n) x.α τ)(hε:0<ε) (hp:Jubilee p b.pins ε η)(hB:supportBudget p b.pins η a)(hz:x.ε n ≤scanPrice p*ε) (ht:10*ε≤τ) (hT:2*τ<1)(hF:Beams b (m n) Y (w n) U v a ε δ d0) (i : ViewPair p n (M*n) (w n))(hx:cirque (w n) U i ≠0)(hg1:gauze p δ δ Y (m n) b.pins i.1.2) (hg2:gauze p δ δ Y (m n) b.pins i.2.2)(hC:matchProg x n (i.1.2,i.2.2))(hS:secureAt p (w n).rooting (i.1.2,i.2.2)) :eligiblePair v (m n) i.1 i.2 Y a := byclassicallet s:=w n; let μ:= U; let K:=b.pinslet X:=i.1.2; let Z:=i.2.2let j:=i.1.1; let k:=i.2.1let L:=troupe s μhave hs : L i.1≠0:=left_ne_zero_of_mul hxhave hl : L i.2 ≠0:=right_ne_zero_of_mul hxhave hX := troupe_home h i.1 hshave hZ:= troupe_home h i.2 hlhave hL i:= (h.strength.leaf _ (Subtype.prop (show s.T from i))).boundobtain ⟨g,hg⟩:= ready_loupe s v hv hE hLlet d:= g.r j; let e:=g.r klet t:=v.cAxes j (toRates d); let u:=v.cAxes k (toRates e)let A:=g.H j; let B:=g.H klet m':=x.m nlet F:=x.L n X; let H:=x.L n Zlet P:= A⊔F; let Q:=B⊔ Hobtain ⟨⟨h1,h2⟩,h3,h4⟩:=hm _ j.property X hX.1obtain ⟨⟨h1',h2'⟩,h3',h4'⟩:=hm _ k.property Z hZ.1let M0:=s.pin j.val; let M1:=s.pin k.valhave he (i):m' X i∈ effective M0.sp i:= (hX.2.1 ▸ (h1 i).2)have he' i:m' Z i∈effective M1.sp i:= (hZ.2.1 ▸ (h1' i).2)choose T hP using fun i=> show m' X i∈LinearMap.range (t i) from(hg.charts j i).1.symm ▸ he ichoose S hQ using fun i=> show m' Z i∈ LinearMap.range (u i) from(hg.charts k i).1.symm ▸ he' ilet Γ:PredictionData p (toRates d) (toRates e) r := ⟨x.α,f,T,S⟩have ht0:= hE.enter.firstlet M' := m nlet D:=wisp p Y; let X0:=wake p Y M' X t; let X1:=wake p Y M' Z ulet β:=trimBeta p Klet C:=stellar D X0 X1 η P Qhave hk0 i t:=Nat.lt_succ_iff.mp (g.r i t).isLthave hA: reports p r D X0 β δ:=routeLive s g v hg M' hE hn i.1 Y δ hF.haze.1 (hL _) hg1have hB1: reports p r D X1 β δ:=routeLive s g v hg M' hE hn i.2 Y δ hF.haze.1 (hL _) hg2have hR := boothseek b _ (g.H j) F (hg.baseline j) hE (fun i=>(h1 i).1)have hR' := boothseek b _ (g.H k) H (hg.baseline k) hE (fun i=>(h1' i).1)have hG: rich C:= plenitude hF.soft hA hB1 ht0.hG P Q hR hR' (trimBeta_pos ..) hp.poshp.sturdyR (hk0 _) (hk0 _)obtain ⟨E,hE0,hr⟩:=stable C hGobtain ⟨y,hy⟩:= issueTicket X Z s v j k h.strength.part hX.1 hZ.1 hv hSlet U0:=v.mails j k yhave hQ': x.c.compatible x.α (glint p (m' X)) (cardTone m' X U0,cardTone m' Z(reciprocal p U0)) := bychange glint p _=_ at h3have he1 l: cardTone m' X U0 l=(quench p (delta m') (X,Z)).1 l:=(fitsTone m' X hy.2.2 he l).trans (actualTone m' X Z l)have he2 l:cardTone m' Z (reciprocal p U0) l=(quench p (delta m') (X,Z)).2 l:= byhave hg := fits_recip hy.2.2; rw [reciprocal_actual] at hgexact (fitsTone m' Z hg he' l).trans (actualTone m' Z X l)rw [funext he1,funext he2,h3]; exact hChave hc: countStory p K η δ ε β D:=⟨hF.soft,(trimBeta_pos ..).le,hε.le,hp.pos.le,hp.book,hp.low⟩have hv : Γ.colored D X0 X1 P Q (2*ε):= byconstructor· exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) t T m' X F P le_sup_righthP hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2 i j hj k f).trans hz) h4 hg1exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) u S m' Z H Q le_sup_righthQ hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2' i j hj k f).trans hz) h4' hg2have hZ0 := laysScore p K Y (m n) D X Z m' (toRates d) (toRates e) t u x.c Γ P QE η ε β δ τ hP hQ (paintChorus _ _ f _ x.α τ hh T S) (by linarith only [hε,ht]) hT hchA hB1 hv (hk0 _) (hk0 _) ht0.hG ht hR hR' hE0 U0 (h3.trans h3'.symm) hQ' hGexact inform (w n) v _ Y i.1 i.2 hX.2.2.1 hZ.2.2.1 hX.2.2.2 hZ.2.2.2 d e (hg.charts _)(hg.charts _) hB A B (hg.baseline _) (hg.baseline _) P Q le_sup_left le_sup_left ht0.hGhE.jump hp.pos y hy E hr hZ0end StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149import OAI.Combinatorics.HadwigerCounterexample.RareTestEventsnamespace OAI/-! # Compatible Table Events -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix LinearMap Functionopen scoped BigOperators Topologyopen Templatenamespace StatusAnalysisopen PreparationParameters PredictionClassvariable {p:Shape} {n M K s0 N :ℕ} {w:LeafMixture p n N} {q:PreparationParameters}structure Settled (t: LeafMixture p n N) (m:Mixer p n) (q:PreparationParameters)(U : Wgt (UnitType p n N)) (z:BMark p n N) (k:F) : Prop wherereadyC :IsLaw U ∧ t.strength U (usual p m N) q.leafNew (2*q.ζ) q.pins ∧t.within (fun o=>frameSide p m o ∧ exactInk p m z o ∧(∀ i,z o i∈effective (t.rooting o) i) ∧ glint p (z o)=k)hard : q.hardened p N t zdef shimmer (z:BMark p n N) (r:F) (x:UnitType p n N× UnitType p n N) :=quench p (delta z) x=repeatQ rvariable (v: Station p n N q.pins w) (i j:w.T)(U:Wgt (UnitType p n N)) (m:Mixer p n) (z:BMark p n N)private theorem chartKnown {r : F} (q:PreparationParameters) (x:w.T) (d: Stakes q.pins)(hw:Settled w m q U z r){v : Charts p n (toRates d)} (hc:charted v (w.pin x.val).sp)(o : UnitType p n N) (hx:o∈x.val) :(∀ i,totalRank (z o i)≤ q.pins) ∧ ∃ y,∀ i∈x.val,coordSpec z i v y := byobtain ⟨h1,h2,h3⟩:=hw.readyClet A:=(w.pin x.val).sphave hi j : z o j∈effective A j := byhave hh : w.rooting o=A:=congrArg Pin.sp (LeafMixture.poller_eq w h2.part x.property hx)rw [←hh]; exact (h3 x.val x.property o hx).2.2.1 jobtain ⟨T,hK,hB,hG⟩:=hw.hardobtain ⟨b,hb,hf⟩:=hG x.val x.propertychoose y hy using fun j=> show z o j∈LinearMap.range (v j) from (hc j).1.symm ▸ hi jrefine ⟨fun i=>(effective_rank (hi i)).trans (h2.leaf x.val x.property).bound,y,fun i hh j=>?_⟩exact (hy j).trans (congr_fun (hb.2.2 _ hx _ hh).1 j)set_option maxHeartbeats 1800000 intheorem invoke (k:Fin (2^deckMax p q.pins))(r:F) (a:ℝ) (hα:0<a) (h:AnalyticParameters p M q s0)(hw:Settled w m q U z r) (ht:v.bank)(hk:2*a ≤ pr (pairW (partW U i.val) (partW U j.val))(fun x=> shimmer z r x∧ berthTicket (w.pin i.val) (w.pin j.val) (v.mails i j k) x)) :∃ x:Scrip p q.pins, v.charter x.2.2 m x.2.1 U a (i,j) := byclassicallet K:=q.pinslet T:=v.mails i j khave hq:=h.enter.firstlet a0:= w.pin i.val; let b0:= w.pin j.vallet μ i:=partW U (Subtype.val (show w.T from i))let S:=pairW (μ i) (μ j)obtain ⟨hm,hv,hC⟩:=hw.readyChave hu x:=show IsLaw (μ x) from on_law hm.nz (hv.leaf x.val x.property).poshave hμ: IsLaw S:= pairW_law (hu _) (hu _)have hK x : planRank (w.pin (Subtype.val (show w.T from x))).sp ≤ K :=(hv.leaf _ (Subtype.prop x)).boundobtain ⟨f,hF⟩:=sizedCharts q.pins w v ht i (hK i)obtain ⟨g,hG⟩:=sizedCharts q.pins w v ht j (hK j)let A:= toRates f; let B:=toRates g; let X:=v.cAxes i A; let Y:=v.cAxes j Blet P x:= shimmer z r x∧ berthTicket a0 b0 T xobtain ⟨o,⟨hop,hOK⟩,ho⟩:= exists_of_pr_pos hμ.nz (lt_of_lt_of_le(show 0<2*a by positivity) hk)let x:=o.1; let y:=o.2have hcol i x (hx:μ i x≠0) : x∈ i.val := (onW_ne hx).1have hx : x∈ i.val:= hcol i x (left_ne_zero_of_mul ho.ne')have hy : y∈ j.val:= hcol j y (right_ne_zero_of_mul ho.ne')obtain ⟨hχ,l,hl⟩:= chartKnown (v:=X) U m z q i f hw hF x hxobtain ⟨hξ,t,ht'⟩:= chartKnown (v:=Y) U m z q j g hw hG y hyhave he (i : w.T) x (hx:x∈ i.val) : ∀ j,z x j∈effective (w.pin i.val).sp j := byhave hi : w.rooting x=(w.pin i.val).sp:=congrArg Pin.sp (LeafMixture.poller_eq w hv.part i.property hx)rw [← hi]; exact (hC _ i.property _ hx).2.2.1let kappa : Tag p.g:= ⟨0,by linarith only [hq.hG]⟩let tt : Tagging p (Messenger singles):=fun _=>kappalet ref := show Messenger singles→F from fun _=>1obtain ⟨E,h1,h2,h3⟩:= generic_summary p hq.hG kappa 1 0obtain ⟨H,h4,h5,h6⟩:= generic_summary p hq.hG kappa 1 1obtain ⟨L,hLa⟩:= buildBooths K a0.sp (hK i) h.penRoomobtain ⟨O,hLb⟩:= buildBooths K b0.sp (hK j) h.penRoomhave hh : 2*frameBills p.g K+4 ≤ Fintype.card (Label p.b) := byhave hl : frameBills p.g K + 1000 ≤ q.B:=h.forbidhave he:= h.spare; omegaobtain ⟨J,hJ,hJ'⟩:= fourPens _ K L hLa hhobtain ⟨I,hI,hI'⟩:= fourPens _ K O hLb hhlet F0:Fabric p singles A true:=⟨J,fun _ => Flavor.full,beacon p X l true T E⟩let T':= reciprocal p Tlet G0:Fabric p singles B false:=⟨I,fun _=> Flavor.full,beacon p Y t false T' H⟩have hs : speak A B (sendSum ref F0.amp G0.amp)=(hailing p X Y T,0) := byapply (spoken X Y T ref F0.amp G0.amp).mprhave hFq a : fullq ref a=1 := byunfold fullqchange (∑ _:Fin 1,(1:F))=1; rw [Fintype.sum_unique]have hR : rhyme F0.amp G0.amp := byintro i; have hf : (funds F0.amp i).1.1=E.diagO := congrArg (fun x=> x.1.1) (funds_one F0 i)have hg : (funds G0.amp i).1.1=H.diagO := congrArg (fun x=> x.1.1) (funds_one G0 i)change (funds (b:=true) F0.amp i).1.1+(funds (b:=false) G0.amp i).1.1=_; rw [hf,hg,h3,h6,zero_add]refine ⟨hFq,hR, stillBeacon z x X l true T E (hl _ hx) (fun k=>?_),stillBeacon z y Y t falseT' H (ht' _ hy) (fun k=>?_)⟩· rw [fitsTone z x hOK.2.2 (he _ _ hx), actualTone,(hC _ i.property _ hx).2.2.2]exact congr_fun (congrArg Prod.fst hop) khave hg:=fits_recip hOK.2.2; rw [reciprocal_actual] at hgrw [fitsTone z y hg (he _ _ hy), actualTone,(hC _ j.property _ hy).2.2.2]exact congr_fun (congrArg Prod.snd hop) kobtain ⟨P0,Q0,hf⟩:= optionVia singles A B a0 b0 T K hOK.1 hOK.2.1 tt X Y hF hG F0 G0 L O hLa hLb(fun i=>hJ' i _) (fun i=> hI' i _) ref ⟨hJ,fun i=>h2,fun i=>h1⟩⟨hI,fun i=>h5,fun i=>h4⟩ h.jump (by linarith only [hq.hG]) singles_short hslet τ:Typus p singles A B:= ⟨tt,ref,F0.hang P0,G0.hang Q0⟩let Front:=v.frontPage τ m i j k; let Back:=v.backPage τ m i j khave hi a (ha:a∈ i.val): a0.agree a := (hv.leaf _ i.property).fixpin _ hahave hi' a (ha:a∈ j.val): b0.agree a := (hv.leaf _ j.property).fixpin _ hahave hm : 2*a≤ (pr (μ i) Front)*(pr (μ j) Back) := byrw [←pairW_pr]apply hk.transrefine pr_on_mono hμ.nz (fun x hx he=>?_)have h1 := hcol i x.1 (left_ne_zero_of_mul hx)have h2 := hcol j x.2 (right_ne_zero_of_mul hx)obtain ⟨ha,hb⟩:= berth_flags a0 b0 T he.2 (hi _ h1) (hi' _ h2)exact ⟨⟨hf,hi _ h1,(hC _ i.property x.1 h1).1, ha⟩,⟨hf,hi' _ h2,(hC _ j.property _ h2).1,hb⟩⟩refine ⟨⟨(volume1,f,g),k,show OnFile p _ from τ⟩,hf.1,⟨?_,fun o ho hx=>?_⟩,⟨?_,fun o ho hx=>?_⟩⟩· exact hm.trans ((mul_le_mul_of_nonneg_left ((pr_le_tot (hu _).nz).trans (hu j).total.le)(pr_nonneg (hu _).nz)).trans_eq (mul_one _))· have hv := hcol i o hxexact steadyBeacon z o X l true T τ.qA tt m E K(fun x=> Nat.lt_succ_iff.mp (f x).isLt) rfl (hK i) hF (hl _ hv) ho.2.2.1(hC _ i.property _ hv).2.1· exact hm.trans ((mul_le_mul_of_nonneg_right ((pr_le_tot (hu _).nz).trans (hu i).total.le)(pr_nonneg (hu _).nz)).trans_eq (one_mul _))have hv:=hcol j o hxexact steadyBeacon z o Y t false T' τ.qB tt m H K(fun x=> Nat.lt_succ_iff.mp (g x).isLt) rfl (hK j) hG (ht' _ hv) ho.2.2.1(hC _ j.property _ hv).2.1end StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149import OAI.Combinatorics.HadwigerCounterexample.RareTestEventsnamespace OAI/-! # Compatible Table Events -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix LinearMap Functionopen scoped BigOperators Topologyopen Templatenamespace StatusAnalysisopen PreparationParameters PredictionClassvariable {p:Shape} {n M K s0 N :ℕ} {w:LeafMixture p n N} {q:PreparationParameters}structure Settled (t: LeafMixture p n N) (m:Mixer p n) (q:PreparationParameters)(U : Wgt (UnitType p n N)) (z:BMark p n N) (k:F) : Prop wherereadyC :IsLaw U ∧ t.strength U (usual p m N) q.leafNew (2*q.ζ) q.pins ∧t.within (fun o=>frameSide p m o ∧ exactInk p m z o ∧(∀ i,z o i∈effective (t.rooting o) i) ∧ glint p (z o)=k)hard : q.hardened p N t zdef shimmer (z:BMark p n N) (r:F) (x:UnitType p n N× UnitType p n N) :=quench p (delta z) x=repeatQ rvariable (v: Station p n N q.pins w) (i j:w.T)(U:Wgt (UnitType p n N)) (m:Mixer p n) (z:BMark p n N)private theorem chartKnown {r : F} (q:PreparationParameters) (x:w.T) (d: Stakes q.pins)(hw:Settled w m q U z r){v : Charts p n (toRates d)} (hc:charted v (w.pin x.val).sp)(o : UnitType p n N) (hx:o∈x.val) :(∀ i,totalRank (z o i)≤ q.pins) ∧ ∃ y,∀ i∈x.val,coordSpec z i v y := byobtain ⟨h1,h2,h3⟩:=hw.readyClet A:=(w.pin x.val).sphave hi j : z o j∈effective A j := byhave hh : w.rooting o=A:=congrArg Pin.sp (LeafMixture.poller_eq w h2.part x.property hx)rw [←hh]; exact (h3 x.val x.property o hx).2.2.1 jobtain ⟨T,hK,hB,hG⟩:=hw.hardobtain ⟨b,hb,hf⟩:=hG x.val x.propertychoose y hy using fun j=> show z o j∈LinearMap.range (v j) from (hc j).1.symm ▸ hi jrefine ⟨fun i=>(effective_rank (hi i)).trans (h2.leaf x.val x.property).bound,y,fun i hh j=>?_⟩exact (hy j).trans (congr_fun (hb.2.2 _ hx _ hh).1 j)set_option maxHeartbeats 1800000 intheorem invoke (k:Fin (2^deckMax p q.pins))(r:F) (a:ℝ) (hα:0<a) (h:AnalyticParameters p M q s0)(hw:Settled w m q U z r) (ht:v.bank)(hk:2*a ≤ pr (pairW (partW U i.val) (partW U j.val))(fun x=> shimmer z r x∧ berthTicket (w.pin i.val) (w.pin j.val) (v.mails i j k) x)) :∃ x:Scrip p q.pins, v.charter x.2.2 m x.2.1 U a (i,j) := byclassicallet K:=q.pinslet T:=v.mails i j khave hq:=h.enter.firstlet a0:= w.pin i.val; let b0:= w.pin j.vallet μ i:=partW U (Subtype.val (show w.T from i))let S:=pairW (μ i) (μ j)obtain ⟨hm,hv,hC⟩:=hw.readyChave hu x:=show IsLaw (μ x) from on_law hm.nz (hv.leaf x.val x.property).poshave hμ: IsLaw S:= pairW_law (hu _) (hu _)have hK x : planRank (w.pin (Subtype.val (show w.T from x))).sp ≤ K :=(hv.leaf _ (Subtype.prop x)).boundobtain ⟨f,hF⟩:=sizedCharts q.pins w v ht i (hK i)obtain ⟨g,hG⟩:=sizedCharts q.pins w v ht j (hK j)let A:= toRates f; let B:=toRates g; let X:=v.cAxes i A; let Y:=v.cAxes j Blet P x:= shimmer z r x∧ berthTicket a0 b0 T xobtain ⟨o,⟨hop,hOK⟩,ho⟩:= exists_of_pr_pos hμ.nz (lt_of_lt_of_le(show 0<2*a by positivity) hk)let x:=o.1; let y:=o.2have hcol i x (hx:μ i x≠0) : x∈ i.val := (onW_ne hx).1have hx : x∈ i.val:= hcol i x (left_ne_zero_of_mul ho.ne')have hy : y∈ j.val:= hcol j y (right_ne_zero_of_mul ho.ne')obtain ⟨hχ,l,hl⟩:= chartKnown (v:=X) U m z q i f hw hF x hxobtain ⟨hξ,t,ht'⟩:= chartKnown (v:=Y) U m z q j g hw hG y hyhave he (i : w.T) x (hx:x∈ i.val) : ∀ j,z x j∈effective (w.pin i.val).sp j := byhave hi : w.rooting x=(w.pin i.val).sp:=congrArg Pin.sp (LeafMixture.poller_eq w hv.part i.property hx)rw [← hi]; exact (hC _ i.property _ hx).2.2.1let kappa : Tag p.g:= ⟨0,by linarith only [hq.hG]⟩let tt : Tagging p (Messenger singles):=fun _=>kappalet ref := show Messenger singles→F from fun _=>1obtain ⟨E,h1,h2,h3⟩:= generic_summary p hq.hG kappa 1 0obtain ⟨H,h4,h5,h6⟩:= generic_summary p hq.hG kappa 1 1obtain ⟨L,hLa⟩:= buildBooths K a0.sp (hK i) h.penRoomobtain ⟨O,hLb⟩:= buildBooths K b0.sp (hK j) h.penRoomhave hh : 2*frameBills p.g K+4 ≤ Fintype.card (Label p.b) := byhave hl : frameBills p.g K + 1000 ≤ q.B:=h.forbidhave he:= h.spare; omegaobtain ⟨J,hJ,hJ'⟩:= fourPens _ K L hLa hhobtain ⟨I,hI,hI'⟩:= fourPens _ K O hLb hhlet F0:Fabric p singles A true:=⟨J,fun _ => Flavor.full,beacon p X l true T E⟩let T':= reciprocal p Tlet G0:Fabric p singles B false:=⟨I,fun _=> Flavor.full,beacon p Y t false T' H⟩have hs : speak A B (sendSum ref F0.amp G0.amp)=(hailing p X Y T,0) := byapply (spoken X Y T ref F0.amp G0.amp).mprhave hFq a : fullq ref a=1 := byunfold fullqchange (∑ _:Fin 1,(1:F))=1; rw [Fintype.sum_unique]have hR : rhyme F0.amp G0.amp := byintro i; have hf : (funds F0.amp i).1.1=E.diagO := congrArg (fun x=> x.1.1) (funds_one F0 i)have hg : (funds G0.amp i).1.1=H.diagO := congrArg (fun x=> x.1.1) (funds_one G0 i)change (funds (b:=true) F0.amp i).1.1+(funds (b:=false) G0.amp i).1.1=_; rw [hf,hg,h3,h6,zero_add]refine ⟨hFq,hR, stillBeacon z x X l true T E (hl _ hx) (fun k=>?_),stillBeacon z y Y t falseT' H (ht' _ hy) (fun k=>?_)⟩· rw [fitsTone z x hOK.2.2 (he _ _ hx), actualTone,(hC _ i.property _ hx).2.2.2]exact congr_fun (congrArg Prod.fst hop) khave hg:=fits_recip hOK.2.2; rw [reciprocal_actual] at hgrw [fitsTone z y hg (he _ _ hy), actualTone,(hC _ j.property _ hy).2.2.2]exact congr_fun (congrArg Prod.snd hop) kobtain ⟨P0,Q0,hf⟩:= optionVia singles A B a0 b0 T K hOK.1 hOK.2.1 tt X Y hF hG F0 G0 L O hLa hLb(fun i=>hJ' i _) (fun i=> hI' i _) ref ⟨hJ,fun i=>h2,fun i=>h1⟩⟨hI,fun i=>h5,fun i=>h4⟩ h.jump (by linarith only [hq.hG]) singles_short hslet τ:Typus p singles A B:= ⟨tt,ref,F0.hang P0,G0.hang Q0⟩let Front:=v.frontPage τ m i j k; let Back:=v.backPage τ m i j khave hi a (ha:a∈ i.val): a0.agree a := (hv.leaf _ i.property).fixpin _ hahave hi' a (ha:a∈ j.val): b0.agree a := (hv.leaf _ j.property).fixpin _ hahave hm : 2*a≤ (pr (μ i) Front)*(pr (μ j) Back) := byrw [←pairW_pr]apply hk.transrefine pr_on_mono hμ.nz (fun x hx he=>?_)have h1 := hcol i x.1 (left_ne_zero_of_mul hx)have h2 := hcol j x.2 (right_ne_zero_of_mul hx)obtain ⟨ha,hb⟩:= berth_flags a0 b0 T he.2 (hi _ h1) (hi' _ h2)exact ⟨⟨hf,hi _ h1,(hC _ i.property x.1 h1).1, ha⟩,⟨hf,hi' _ h2,(hC _ j.property _ h2).1,hb⟩⟩refine ⟨⟨(volume1,f,g),k,show OnFile p _ from τ⟩,hf.1,⟨?_,fun o ho hx=>?_⟩,⟨?_,fun o ho hx=>?_⟩⟩· exact hm.trans ((mul_le_mul_of_nonneg_left ((pr_le_tot (hu _).nz).trans (hu j).total.le)(pr_nonneg (hu _).nz)).trans_eq (mul_one _))· have hv := hcol i o hxexact steadyBeacon z o X l true T τ.qA tt m E K(fun x=> Nat.lt_succ_iff.mp (f x).isLt) rfl (hK i) hF (hl _ hv) ho.2.2.1(hC _ i.property _ hv).2.1· exact hm.trans ((mul_le_mul_of_nonneg_right ((pr_le_tot (hu _).nz).trans (hu i).total.le)(pr_nonneg (hu _).nz)).trans_eq (one_mul _))have hv:=hcol j o hxexact steadyBeacon z o Y t false T' τ.qB tt m H K(fun x=> Nat.lt_succ_iff.mp (g x).isLt) rfl (hK j) hG (ht' _ hv) ho.2.2.1(hC _ j.property _ hv).2.1end StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115import Mathlib.Algebra.Group.Fin.Basicimport Mathlib.Data.Fintype.Cardimport Mathlib.Data.Fintype.Prodnamespace OAI/-! # Component Indices -/noncomputable sectionnamespace HadwigerCounterexampleabbrev Tag := Finabbrev Comp (g : ℕ) := { p : Tag g × Tag g // p.1 < p.2 }variable {g : ℕ}def edge (l d : Tag g) (h : l ≠ d) : Comp g :=if hl : l < d then ⟨(l,d),hl⟩ else ⟨(d,l),lt_of_le_of_ne (le_of_not_gt hl) h.symm⟩theorem edge_eq {l d : Tag g} (h : l < d) : edge l d (ne_of_lt h) = ⟨(l,d),h⟩ := bysimp [edge,h]theorem edge_symm {l d : Tag g} (h : l ≠ d) : edge l d h = edge d l h.symm := byrcases lt_or_gt_of_ne h with e|e· simp [edge,e,not_lt.mpr e.le]· simp [edge,e,not_lt.mpr e.le]def inc (e : Comp g) (l : Tag g) : Prop := e.val.1 = l ∨ e.val.2 = linstance (e : Comp g) (l : Tag g) : Decidable (inc e l) := inferInstanceAs (Decidable (_ ∨ _))theorem inc_edge_fst {l d : Tag g} (h : l ≠ d) : inc (edge l d h) l := byby_cases e : l < d <;> simp [inc,edge,e]theorem inc_edge_iff {l d x : Tag g} (h : l ≠ d) : inc (edge l d h) x ↔ (l=x ∨ d=x) := byby_cases e : l < d <;> simp [inc,edge,e,or_comm]abbrev TagStar (l : Tag g) := {e : Comp g // inc e l}def starEquiv (l : Tag g) : {d : Tag g // l ≠ d} ≃ TagStar l := bylet f (d : {d : Tag g // l ≠ d}) : TagStar l := ⟨edge l d d.property,inc_edge_fst _⟩apply Equiv.ofBijective fconstructor· intro i j hhave hi : inc (edge l i i.property) i := (inc_edge_iff _).mpr (Or.inr rfl)change inc (f i).val i at hirw [h] at hiexact Subtype.ext (((inc_edge_iff j.property).mp hi).resolve_left i.property).symm· rintro ⟨⟨⟨i,j⟩,hij⟩,he⟩rcases he with g|g· change i = l at gsubst lrefine ⟨⟨j,hij.ne⟩,Subtype.ext ?_⟩exact edge_eq hij· change j = l at gsubst lrefine ⟨⟨i,hij.ne.symm⟩,Subtype.ext ?_⟩dsimp only [f]rw [edge_symm,edge_eq hij]theorem card_star (l : Tag g) : Fintype.card (TagStar l) = g - 1 := byrw [← Fintype.card_congr (starEquiv l)]exact (Fintype.card_subtype_compl (fun d => l=d)).trans (by simp)/-- l in I_d. -/def allowed (d l : Tag g) :=0 < (l-d).val ∧ (l-d).val ≤ (g-1)/2instance (d l : Tag g) : Decidable (allowed d l) :=inferInstanceAs (Decidable (_ ∧ _))theorem not_allowed (d : Tag g) : ¬allowed d d := byhave : NeZero g := ⟨by have := d.isLt; omega⟩simp [allowed]theorem card_allowed (d : Tag g) : Fintype.card {l : Tag g // allowed d l} = (g-1)/2 := byhave : NeZero g := ⟨by have := d.isLt; omega⟩let T := {l : Tag g // allowed d l}let f (i : Fin ((g-1)/2)) : Tag g := ⟨i.val+1,by have := i.isLt; omega⟩have hf (i) : allowed d (f i + d) := byhave := i.isLtsimp only [allowed,add_sub_cancel_right,f]omegalet h : Fin ((g-1)/2) → T := fun i => ⟨f i + d,hf i⟩have hh : Function.Bijective h := byconstructor· intro i j hijhave he : f i = f j := add_right_cancel (congrArg Subtype.val hij)have he' := congrArg Fin.val heexact Fin.ext (Nat.add_right_cancel he')· intro lhave hl := l.propertyunfold allowed at hllet i : Fin ((g-1)/2) := ⟨(l.val-d).val-1,by omega⟩have hi : f i = l.val-d := Fin.ext (by dsimp only [i,f]; omega)refine ⟨i,Subtype.ext ?_⟩change f i + d = _rw [hi,sub_add_cancel]simpa using (Fintype.card_congr (Equiv.ofBijective h hh)).symmtheorem card_allowed' (l : Tag g) :Fintype.card {d : Tag g // allowed d l} = (g-1)/2 := byhave : NeZero g := ⟨by have := l.isLt; omega⟩let h : {d : Tag g // allowed d l} ≃ {x : Tag g // allowed 0 x} := {toFun := fun d => ⟨l-d.val, by simpa only [allowed,sub_zero] using d.property⟩invFun := fun x => ⟨l-x.val, by simpa only [allowed,sub_sub_cancel,sub_zero] usingx.property⟩left_inv := fun d => Subtype.ext (sub_sub_cancel _ _)right_inv := fun x => Subtype.ext (sub_sub_cancel _ _) }exact (Fintype.card_congr h).trans (card_allowed _)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115import Mathlib.Algebra.Group.Fin.Basicimport Mathlib.Data.Fintype.Cardimport Mathlib.Data.Fintype.Prodnamespace OAI/-! # Component Indices -/noncomputable sectionnamespace HadwigerCounterexampleabbrev Tag := Finabbrev Comp (g : ℕ) := { p : Tag g × Tag g // p.1 < p.2 }variable {g : ℕ}def edge (l d : Tag g) (h : l ≠ d) : Comp g :=if hl : l < d then ⟨(l,d),hl⟩ else ⟨(d,l),lt_of_le_of_ne (le_of_not_gt hl) h.symm⟩theorem edge_eq {l d : Tag g} (h : l < d) : edge l d (ne_of_lt h) = ⟨(l,d),h⟩ := bysimp [edge,h]theorem edge_symm {l d : Tag g} (h : l ≠ d) : edge l d h = edge d l h.symm := byrcases lt_or_gt_of_ne h with e|e· simp [edge,e,not_lt.mpr e.le]· simp [edge,e,not_lt.mpr e.le]def inc (e : Comp g) (l : Tag g) : Prop := e.val.1 = l ∨ e.val.2 = linstance (e : Comp g) (l : Tag g) : Decidable (inc e l) := inferInstanceAs (Decidable (_ ∨ _))theorem inc_edge_fst {l d : Tag g} (h : l ≠ d) : inc (edge l d h) l := byby_cases e : l < d <;> simp [inc,edge,e]theorem inc_edge_iff {l d x : Tag g} (h : l ≠ d) : inc (edge l d h) x ↔ (l=x ∨ d=x) := byby_cases e : l < d <;> simp [inc,edge,e,or_comm]abbrev TagStar (l : Tag g) := {e : Comp g // inc e l}def starEquiv (l : Tag g) : {d : Tag g // l ≠ d} ≃ TagStar l := bylet f (d : {d : Tag g // l ≠ d}) : TagStar l := ⟨edge l d d.property,inc_edge_fst _⟩apply Equiv.ofBijective fconstructor· intro i j hhave hi : inc (edge l i i.property) i := (inc_edge_iff _).mpr (Or.inr rfl)change inc (f i).val i at hirw [h] at hiexact Subtype.ext (((inc_edge_iff j.property).mp hi).resolve_left i.property).symm· rintro ⟨⟨⟨i,j⟩,hij⟩,he⟩rcases he with g|g· change i = l at gsubst lrefine ⟨⟨j,hij.ne⟩,Subtype.ext ?_⟩exact edge_eq hij· change j = l at gsubst lrefine ⟨⟨i,hij.ne.symm⟩,Subtype.ext ?_⟩dsimp only [f]rw [edge_symm,edge_eq hij]theorem card_star (l : Tag g) : Fintype.card (TagStar l) = g - 1 := byrw [← Fintype.card_congr (starEquiv l)]exact (Fintype.card_subtype_compl (fun d => l=d)).trans (by simp)/-- l in I_d. -/def allowed (d l : Tag g) :=0 < (l-d).val ∧ (l-d).val ≤ (g-1)/2instance (d l : Tag g) : Decidable (allowed d l) :=inferInstanceAs (Decidable (_ ∧ _))theorem not_allowed (d : Tag g) : ¬allowed d d := byhave : NeZero g := ⟨by have := d.isLt; omega⟩simp [allowed]theorem card_allowed (d : Tag g) : Fintype.card {l : Tag g // allowed d l} = (g-1)/2 := byhave : NeZero g := ⟨by have := d.isLt; omega⟩let T := {l : Tag g // allowed d l}let f (i : Fin ((g-1)/2)) : Tag g := ⟨i.val+1,by have := i.isLt; omega⟩have hf (i) : allowed d (f i + d) := byhave := i.isLtsimp only [allowed,add_sub_cancel_right,f]omegalet h : Fin ((g-1)/2) → T := fun i => ⟨f i + d,hf i⟩have hh : Function.Bijective h := byconstructor· intro i j hijhave he : f i = f j := add_right_cancel (congrArg Subtype.val hij)have he' := congrArg Fin.val heexact Fin.ext (Nat.add_right_cancel he')· intro lhave hl := l.propertyunfold allowed at hllet i : Fin ((g-1)/2) := ⟨(l.val-d).val-1,by omega⟩have hi : f i = l.val-d := Fin.ext (by dsimp only [i,f]; omega)refine ⟨i,Subtype.ext ?_⟩change f i + d = _rw [hi,sub_add_cancel]simpa using (Fintype.card_congr (Equiv.ofBijective h hh)).symmtheorem card_allowed' (l : Tag g) :Fintype.card {d : Tag g // allowed d l} = (g-1)/2 := byhave : NeZero g := ⟨by have := l.isLt; omega⟩let h : {d : Tag g // allowed d l} ≃ {x : Tag g // allowed 0 x} := {toFun := fun d => ⟨l-d.val, by simpa only [allowed,sub_zero] using d.property⟩invFun := fun x => ⟨l-x.val, by simpa only [allowed,sub_sub_cancel,sub_zero] usingx.property⟩left_inv := fun d => Subtype.ext (sub_sub_cancel _ _)right_inv := fun x => Subtype.ext (sub_sub_cancel _ _) }exact (Fintype.card_congr h).trans (card_allowed _)end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169import OAI.Combinatorics.HadwigerCounterexample.DependentPairConcentrationnamespace OAI/-! # Concentration Scales -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Module Finset Filter Real Functionopen scoped BigOperators Topologyvariable {X : Type*}/-- pay slack for any fixed multiple of exponentially smaller term. -/theorem pay_nat {a b : ℝ} (c : ℝ) (hab : b < a) :∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ bp (-b*n) := byhave h := (bp_tendsto (sub_pos.mpr hab)).comp (tendsto_natCast_atTop_atTop (R:=ℝ))filter_upwards [h.eventually (eventually_ge_atTop c)] with n hnchange c ≤ bp ((a-b)*n) at hnrefine (mul_le_mul_of_nonneg_right hn (bp_pos _).le).trans_eq ?_rw [← bp_add, show (a-b)*n + -a*n= -b*n by ring]theorem pay_div_nat {a b : ℝ} (c u : ℝ) (hu : 0 < u) (hab : b < a) :∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ u*bp (-b*n) := byfilter_upwards [pay_nat (c/u) hab] with n hncalc _ = u*(c/u*bp (-a*n)) := by field_simp_ ≤ _ := mul_le_mul_of_nonneg_left hn hu.letheorem cast_tops (M : ℕ) (hM : 1≤M) :Tendsto (fun n : ℕ => (↑(M*n):ℝ)) atTop atTop := bysimp_rw [Nat.cast_mul]; exact(tendsto_const_mul_atTop_of_pos (show 0<(M:ℝ) from byexact_mod_cast (show 0 < M from hM))).mpr tendsto_natCast_atTop_atTopvariable {p : Shape} {M n N : ℕ}variable {I J K G A B : Type} [Fintype I] [Fintype J] [Fintype K] [Fintype G]variable [DecidableEq I] [DecidableEq J] [DecidableEq K] [DecidableEq G]variable [Fintype A] [Fintype B]variable {g : Route J G}omit [Fintype G] [DecidableEq J] intheorem port_limit (g : Route J G) (i : G) :num (Port g i) ≤ num J := byexact_mod_cast Fintype.card_subtype_le _namespace Programvariable {s : Program p n g A}/-- empirical input-and-image law -/def makeData (s : Program p n g A) (w : Wgt A) (o : Forum p n N G) :Wgt (A×Rack J N) :=mapW w (fun x => (x,s.showKey x o))omit [Fintype G] [DecidableEq G] intheorem data_law (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)(hw : IsLaw w) : IsLaw (s.makeData w o) := mapW_law hw _omit [Fintype G] [DecidableEq G] intheorem view_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)(f : Wgt (A×Rack J N)) :avg (s.makeData w o) f=s.oexpect w (fun a b => f (a,b)) o := mapW_avg ..omit [Fintype G] [DecidableEq G] intheorem freq_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)(P : A×Rack J N→Prop) :pr (s.makeData w o) P = oFreq w (fun a b => P (a,b)) o s := mapW_pr ..set_option maxHeartbeats 600000 intheorem variance_calendar (p : Shape) (M : ℕ) (g : Route J G)(r u : ℝ) (hu : 0 < u) (hM : 1≤M) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)(A : Type) [Fintype A] (s : Program p n g A)(T : A→ Wgt (Rack J N)) (w : Wgt A), IsLaw w →(∀ x y, |T x y|≤1) →2*num (Full p n)<N →pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →(let v := forumLaw m Nlet f := s.oexpect w Tavg v (fun x => (f x-avg v f)^2)) ≤ u*bp (-(1/4:ℝ)*n) := bylet t := tied g Boollet k := num (Bool×J)let b := 2*netFact tlet c := num G* (2*bp k)+1filter_upwards [pay_div_nat (a:=1) (2*bp r) (u/2) (by positivity) (b:=1/4) (by norm_num),pay_div_nat (a:=1/2) (b*c) (u/2) (by positivity) (b:=1/4) (by norm_num),(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]with n hn hh hk N m A _ s T w hw hT hN hchange (2*k+1) ≤ (↑(M*n) : ℝ) at hkhave he := oVar m hN T w hw hT k (fun i => port_limit _ i) (by linarith only [hk])(bp (r-n)) happly he.transsubst Nhave hv : (n:ℝ) ≤ (M*n:ℕ) := by exact_mod_cast (show n ≤ M*n from by nlinarith)let P := bp (-(1/2:ℝ)*n)have ht : twinkle t k (M*n) ≤ c*P := byhave hq : bp (k-(M*n:ℕ)) ≤ bp k*P := byunfold P; rw [← bp_add]; apply bp_le; linarith only [hv,Nat.cast_nonneg (α:=ℝ) n]have hr : bp (-(↑(M*n):ℝ)/2)≤P := bp_le (by linarith only [hv])calc _ ≤ num G*(2*(bp k * P))+P := add_le_add(mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hq (by norm_num))(Nat.cast_nonneg _)) hr_ = _ := by unfold c; ringhave h1 : 2*bp (r-n) ≤ u/2*bp (-(1/4:ℝ)*n) := bysimpa only [mul_assoc,← bp_add,neg_mul,one_mul,←sub_eq_add_neg] using hnhave h2 : 2*netFact t* twinkle t k (M*n)≤ u/2*bp (-(1/4:ℝ)*n) :=(mul_le_mul_of_nonneg_left ht (by apply mul_nonneg (by norm_num) netFact_pos.le)).trans(le_trans (le_of_eq (Eq.symm (mul_assoc b c P))) hh)exact (add_le_add h1 h2).trans_eq (by ring)theorem approx_calendar (p : Shape) (M : ℕ) (g : Route J G)(r η : ℝ) (hη : 0<η) (hM : 1 ≤ M) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)(A : Type) [Fintype A] (s : Program p n g A)(w : Wgt A), IsLaw w →2*num (Full p n)<N →pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →approxData (forumLaw m N) (s.makeData w) η (bp (-(1/4:ℝ)*n)) := byfilter_upwards [variance_calendar p M g r (η^2) (by positivity) hM]with n hn N m A _ s w hw hN he F hFsubst Nlet T (x : A) (y : Rack J (M*n)) := F (x,y)rw [mixW_avg]; simp_rw [view_data]refine (outlier (forum_law m hN).nz _ η hη(hn m _ s T w hw (fun x y => hF _) hN he)).trans_eq ?_field_simptheorem thin_calendar (p : Shape) (M : ℕ) (g : Route J G)(b η c : ℝ) (hc : 0 < c) (hη : 0<η) (hM : 1≤M) :∃ l : ℕ, ∀ r : ℝ, ∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)(A : Type) [Fintype A] (s : Program p n g A)(w : Wgt A), IsLaw w →2*num (Full p n)<N →pr (draws (Fin l) w) (fun x => ¬ s.free x) ≤ bp (r-n) →thinData (forumLaw m N) (s.makeData w) (bp (-c*n)) η (bp (-b*n)) := byobtain ⟨l,hl⟩ := exists_nat_gt (b/c)let d := η^l/2have hd : 0<d := by positivitylet t := tied g (Fin l)let k := num (Fin l × J)refine ⟨l,fun r => ?_⟩filter_upwards [pay_div_nat (a:=1) (bp r) d hd (b:=0) (by norm_num),pay_div_nat (a:=c*l) (netFact t) d hd (b:=b)(by rwa [div_lt_iff₀ hc,mul_comm] at hl),(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]with n hn hh hk N m A _ s w hw hN hr P hPsubst N; let N := M*nchange 2*k+1 ≤ (N:ℝ) at hklet T (x : A) (y : Rack J N) := P (x,y)let v := forumLaw (G:=G) m Nlet f := fun o => oFreq w T o srw [show pr (mixW v (s.makeData w)) P=avg v (fun x => pr (s.makeData w x) P) from mixW_avg ..] at hPsimp_rw [freq_data] at *have hi : bp (r-n) ≤ d := bysimpa only [neg_zero,zero_mul,bp_zero,mul_one,← bp_add,neg_mul,one_mul, ← sub_eq_add_neg]using hnhave hj : η^l=d+d := by unfold d; ringhave he := oTail m hN T w hw (k:=k) (fun i => port_limit _ i) (by linarith only [hk])(bp (r-n)) hr hη.lehave hv := forum_law (G:=G) m hNapply le_of_mul_le_mul_left _ hdcalc d*pr v (fun x => η ≤ f x)_ ≤ _ := mul_le_mul_of_nonneg_right (show d≤η^l-bp (r-n) from byrw [hj]; linarith only [hi]) (pr_nonneg hv.nz)_ ≤ _ := he_ ≤ netFact t * bp (-c*n)^l := mul_le_mul_of_nonneg_left(pow_le_pow_left₀ (avg_nonneg hv.nz fun x => pr_nonneg hw.nz) hP l) netFact_pos.le_ ≤ _ := by rw [← bp_mul_nat,show -c*n*l= -(c*l)*n by ring]; exact hhend Programend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169import OAI.Combinatorics.HadwigerCounterexample.DependentPairConcentrationnamespace OAI/-! # Concentration Scales -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Module Finset Filter Real Functionopen scoped BigOperators Topologyvariable {X : Type*}/-- pay slack for any fixed multiple of exponentially smaller term. -/theorem pay_nat {a b : ℝ} (c : ℝ) (hab : b < a) :∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ bp (-b*n) := byhave h := (bp_tendsto (sub_pos.mpr hab)).comp (tendsto_natCast_atTop_atTop (R:=ℝ))filter_upwards [h.eventually (eventually_ge_atTop c)] with n hnchange c ≤ bp ((a-b)*n) at hnrefine (mul_le_mul_of_nonneg_right hn (bp_pos _).le).trans_eq ?_rw [← bp_add, show (a-b)*n + -a*n= -b*n by ring]theorem pay_div_nat {a b : ℝ} (c u : ℝ) (hu : 0 < u) (hab : b < a) :∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ u*bp (-b*n) := byfilter_upwards [pay_nat (c/u) hab] with n hncalc _ = u*(c/u*bp (-a*n)) := by field_simp_ ≤ _ := mul_le_mul_of_nonneg_left hn hu.letheorem cast_tops (M : ℕ) (hM : 1≤M) :Tendsto (fun n : ℕ => (↑(M*n):ℝ)) atTop atTop := bysimp_rw [Nat.cast_mul]; exact(tendsto_const_mul_atTop_of_pos (show 0<(M:ℝ) from byexact_mod_cast (show 0 < M from hM))).mpr tendsto_natCast_atTop_atTopvariable {p : Shape} {M n N : ℕ}variable {I J K G A B : Type} [Fintype I] [Fintype J] [Fintype K] [Fintype G]variable [DecidableEq I] [DecidableEq J] [DecidableEq K] [DecidableEq G]variable [Fintype A] [Fintype B]variable {g : Route J G}omit [Fintype G] [DecidableEq J] intheorem port_limit (g : Route J G) (i : G) :num (Port g i) ≤ num J := byexact_mod_cast Fintype.card_subtype_le _namespace Programvariable {s : Program p n g A}/-- empirical input-and-image law -/def makeData (s : Program p n g A) (w : Wgt A) (o : Forum p n N G) :Wgt (A×Rack J N) :=mapW w (fun x => (x,s.showKey x o))omit [Fintype G] [DecidableEq G] intheorem data_law (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)(hw : IsLaw w) : IsLaw (s.makeData w o) := mapW_law hw _omit [Fintype G] [DecidableEq G] intheorem view_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)(f : Wgt (A×Rack J N)) :avg (s.makeData w o) f=s.oexpect w (fun a b => f (a,b)) o := mapW_avg ..omit [Fintype G] [DecidableEq G] intheorem freq_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)(P : A×Rack J N→Prop) :pr (s.makeData w o) P = oFreq w (fun a b => P (a,b)) o s := mapW_pr ..set_option maxHeartbeats 600000 intheorem variance_calendar (p : Shape) (M : ℕ) (g : Route J G)(r u : ℝ) (hu : 0 < u) (hM : 1≤M) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)(A : Type) [Fintype A] (s : Program p n g A)(T : A→ Wgt (Rack J N)) (w : Wgt A), IsLaw w →(∀ x y, |T x y|≤1) →2*num (Full p n)<N →pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →(let v := forumLaw m Nlet f := s.oexpect w Tavg v (fun x => (f x-avg v f)^2)) ≤ u*bp (-(1/4:ℝ)*n) := bylet t := tied g Boollet k := num (Bool×J)let b := 2*netFact tlet c := num G* (2*bp k)+1filter_upwards [pay_div_nat (a:=1) (2*bp r) (u/2) (by positivity) (b:=1/4) (by norm_num),pay_div_nat (a:=1/2) (b*c) (u/2) (by positivity) (b:=1/4) (by norm_num),(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]with n hn hh hk N m A _ s T w hw hT hN hchange (2*k+1) ≤ (↑(M*n) : ℝ) at hkhave he := oVar m hN T w hw hT k (fun i => port_limit _ i) (by linarith only [hk])(bp (r-n)) happly he.transsubst Nhave hv : (n:ℝ) ≤ (M*n:ℕ) := by exact_mod_cast (show n ≤ M*n from by nlinarith)let P := bp (-(1/2:ℝ)*n)have ht : twinkle t k (M*n) ≤ c*P := byhave hq : bp (k-(M*n:ℕ)) ≤ bp k*P := byunfold P; rw [← bp_add]; apply bp_le; linarith only [hv,Nat.cast_nonneg (α:=ℝ) n]have hr : bp (-(↑(M*n):ℝ)/2)≤P := bp_le (by linarith only [hv])calc _ ≤ num G*(2*(bp k * P))+P := add_le_add(mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hq (by norm_num))(Nat.cast_nonneg _)) hr_ = _ := by unfold c; ringhave h1 : 2*bp (r-n) ≤ u/2*bp (-(1/4:ℝ)*n) := bysimpa only [mul_assoc,← bp_add,neg_mul,one_mul,←sub_eq_add_neg] using hnhave h2 : 2*netFact t* twinkle t k (M*n)≤ u/2*bp (-(1/4:ℝ)*n) :=(mul_le_mul_of_nonneg_left ht (by apply mul_nonneg (by norm_num) netFact_pos.le)).trans(le_trans (le_of_eq (Eq.symm (mul_assoc b c P))) hh)exact (add_le_add h1 h2).trans_eq (by ring)theorem approx_calendar (p : Shape) (M : ℕ) (g : Route J G)(r η : ℝ) (hη : 0<η) (hM : 1 ≤ M) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)(A : Type) [Fintype A] (s : Program p n g A)(w : Wgt A), IsLaw w →2*num (Full p n)<N →pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →approxData (forumLaw m N) (s.makeData w) η (bp (-(1/4:ℝ)*n)) := byfilter_upwards [variance_calendar p M g r (η^2) (by positivity) hM]with n hn N m A _ s w hw hN he F hFsubst Nlet T (x : A) (y : Rack J (M*n)) := F (x,y)rw [mixW_avg]; simp_rw [view_data]refine (outlier (forum_law m hN).nz _ η hη(hn m _ s T w hw (fun x y => hF _) hN he)).trans_eq ?_field_simptheorem thin_calendar (p : Shape) (M : ℕ) (g : Route J G)(b η c : ℝ) (hc : 0 < c) (hη : 0<η) (hM : 1≤M) :∃ l : ℕ, ∀ r : ℝ, ∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)(A : Type) [Fintype A] (s : Program p n g A)(w : Wgt A), IsLaw w →2*num (Full p n)<N →pr (draws (Fin l) w) (fun x => ¬ s.free x) ≤ bp (r-n) →thinData (forumLaw m N) (s.makeData w) (bp (-c*n)) η (bp (-b*n)) := byobtain ⟨l,hl⟩ := exists_nat_gt (b/c)let d := η^l/2have hd : 0<d := by positivitylet t := tied g (Fin l)let k := num (Fin l × J)refine ⟨l,fun r => ?_⟩filter_upwards [pay_div_nat (a:=1) (bp r) d hd (b:=0) (by norm_num),pay_div_nat (a:=c*l) (netFact t) d hd (b:=b)(by rwa [div_lt_iff₀ hc,mul_comm] at hl),(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]with n hn hh hk N m A _ s w hw hN hr P hPsubst N; let N := M*nchange 2*k+1 ≤ (N:ℝ) at hklet T (x : A) (y : Rack J N) := P (x,y)let v := forumLaw (G:=G) m Nlet f := fun o => oFreq w T o srw [show pr (mixW v (s.makeData w)) P=avg v (fun x => pr (s.makeData w x) P) from mixW_avg ..] at hPsimp_rw [freq_data] at *have hi : bp (r-n) ≤ d := bysimpa only [neg_zero,zero_mul,bp_zero,mul_one,← bp_add,neg_mul,one_mul, ← sub_eq_add_neg]using hnhave hj : η^l=d+d := by unfold d; ringhave he := oTail m hN T w hw (k:=k) (fun i => port_limit _ i) (by linarith only [hk])(bp (r-n)) hr hη.lehave hv := forum_law (G:=G) m hNapply le_of_mul_le_mul_left _ hdcalc d*pr v (fun x => η ≤ f x)_ ≤ _ := mul_le_mul_of_nonneg_right (show d≤η^l-bp (r-n) from byrw [hj]; linarith only [hi]) (pr_nonneg hv.nz)_ ≤ _ := he_ ≤ netFact t * bp (-c*n)^l := mul_le_mul_of_nonneg_left(pow_le_pow_left₀ (avg_nonneg hv.nz fun x => pr_nonneg hw.nz) hP l) netFact_pos.le_ ≤ _ := by rw [← bp_mul_nat,show -c*n*l= -(c*l)*n by ring]; exact hhend Programend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156import OAI.Combinatorics.HadwigerCounterexample.GradientRealizationimport OAI.Combinatorics.HadwigerCounterexample.WalshBoundsnamespace OAI/-! # Conditional Cell Entropy -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Submodule Module Finsetopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ}theorem plan_add_disjoint (a b : Plan p n) (h : ∀ z, Disjoint (a z) (b z)) :planRank (a⊔b)=planRank a+planRank b := byunfold planRankrw [← Finset.sum_add_distrib]refine Finset.sum_congr rfl fun i _ => ?_have he := Submodule.finrank_sup_add_finrank_inf_eq (a i) (b i)rw [(h i).eq_bot,finrank_bot,add_zero] at heexact hetheorem plan_new_disjoint (a b : Plan p n) (h : ∀ z,Disjoint (a z) (b z)) :planNew a b=planRank b := by rw [planNew,plan_add_disjoint a b h,Nat.add_sub_cancel_left]variable {I : Type} [Fintype I]def kslots (p : Shape) (I : Type) [Fintype I] :=Fintype.card I*(p.g-1)*2def kmax (p : Shape) := 56*(p.g-1)theorem slots_budget {w : I→Bool} (v : Volley p n I)(hb : v.bounded w) : kslots p I ≤ kmax p := byclassicalhave h := v.call_count hbunfold kslots kmax; nlinarithinstance instFKeys (t : Tagging p I) (N : ℕ) : Fintype (Keys (p:=p) t N) :=by classical exact inferInstancetheorem dim_keys (t : Tagging p I) :dim (Keys (p:=p) t N) = kslots p I * N := byhave h (l : Tag p.g) :dim (AtomKey (p:=p) l N)=(p.g-1)*(2*N) := byunfold AtomKey dimrw [finrank_pi_fintype]have he : finrank F (Bool → Vec (Fin N))=2*N := byrw [finrank_pi_fintype]simp_rw [show finrank F (Vec (Fin N))=_ from dim_vec _]simpsimp_rw [he]simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_star]; rflunfold dim Keys kslotsrw [finrank_pi_fintype]have hx i : finrank F (AtomKey (p:=p) (t i) N)=(p.g-1)*(2*N) := h (t i)simp_rw [hx]simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.cast_id]ringnamespace Volleyvariable {v : Volley p n I}theorem key_slots (t : Tagging p I) {q} {a : Plan p n}(h : v.avoids a q) :planNew a (v.keyPlan t) = kslots p I := byclassicallet Y := visits p thave hh i := key_independent v t h ihave he (z : Place p) : dim (keyPlan v t z)=Fintype.card (Y z.1) :=mrk_inj.mp (hh z).1rw [plan_new_disjoint a _ (fun i => Disjoint.mono_left (pin_le_table a i)(hh i).2.symm), planRank,Fintype.sum_prod_type]simp_rw [Fintype.sum_bool,he,←two_mul,←Finset.mul_sum]have hE : ∑ i : Comp p.g,Fintype.card (Y i)=Fintype.card I*(p.g-1) := byhave hf {A : Type} [Fintype A] (p : A → Prop) [DecidablePred p] :Fintype.card {i:A//p i}=∑ i:A, if p i then (1:ℕ) else 0 := byrw [Fintype.card_subtype,←Finset.sum_filter]; simphave hY (i) : Fintype.card (Y i)=∑ j:I,if inc i (t j) then (1:ℕ) else 0 := hf _simp_rw [hY]rw [Finset.sum_comm]simp_rw [← hf (fun i => inc i _)]have hz (j) : Fintype.card {i:Comp p.g//inc i (t j)}=p.g-1 := card_star (t j)simp_rw [hz]simprw [hE]; unfold kslots; ring/-- chosen reference x fixes the pin made of a and all key directionsfor every y in the same pin which agrees on query key. -/theorem key_pin (t : Tagging p I) {a : Pin p n N} {x y : UnitType p n N}(hx : a.agree x) (hy : a.agree y) (h : v.keys t x=v.keys t y) :(Pin.make (v.frozen a.sp t) x).agree y := byclassicalintro i u huobtain ⟨l,hl,r,⟨z,rfl⟩,rfl⟩ := Submodule.mem_sup.mp(show u∈a.sp i⊔v.keyPlan t i from hu)have hZ : images y i * v.keyM t i.1 = images x i * v.keyM t i.1 := byext b jobtain ⟨k,hk⟩ := jhave ht := congr_fun (congr_fun (congr_fun h k) (⟨i.1,hk⟩ : TagStar _)) i.2rw [v.keys_loc,v.keys_loc] at htexact congr_fun ht.symm bchange images y i *ᵥ _ = images x i *ᵥ _rw [Matrix.mulVec_add,Matrix.mulVec_add,hx _ _ hl,hy _ _ hl]rw [mulVecLin_apply,mulVec_mulVec,mulVec_mulVec,hZ]end Volleydef tau (N k : ℕ) := bp (-((k:ℝ)+0.01)*N)def hit (N : ℕ) := bp (-0.02*N)theorem in_clear {a f : Pin p n N} {k : ℕ} {ζ : ℝ} {w : Wgt (UnitType p n N)}(hz : ζ ≤ 0.004) (hkz : ζ*k ≤ 0.004)(hw : SubLaw w) (h : a.clear ζ w) (hF : a.sp≤f.sp) (hk : planRank f.sp=planRank a.sp+k)(S : UnitType p n N → Prop)(hS : ∀ x,S x → f.agree x) (ht : tau N k ≤ pr w S) :IsLaw (onW w S) ∧ f.clear 0.05 (onW w S) := byclassicalhave hpos : 0 < pr w S := lt_of_lt_of_le (bp_pos _) hthave hh : IsLaw (onW w S) := normW_law (subW_nonneg hw.nz _) hposrefine ⟨hh,fun b => ?_⟩let t := planNew f.sp b.spby_cases he : t=0· change pr _ _ ≤ fee N _ trw [he,fee]simp only [Nat.cast_zero,mul_zero,zero_mul,bp_zero]exact (pr_le_tot hh.nz).trans hh.total.lelet R := fun x => S x ∧ b.agree xby_cases hf : 0 < pr w R· obtain ⟨x,⟨hx,hB⟩,_⟩ := exists_of_pr_pos hw.nz hflet c := Pin.make (f.sp⊔b.sp) xhave hc : pr w R≤ fee N ζ (planNew a.sp c.sp) := (pr_mono hw.nz (q:=c.agree)(fun y hy => ((Pin.combine (hS x hx) hB).mpr ⟨hS _ hy.1,hy.2⟩))).trans (h c)have hN : planNew a.sp c.sp=k+t := byhave hh : planNew a.sp f.sp+t=planNew a.sp c.sp := planNew_mono_add hFrw [← hh]rw [planNew, sup_eq_right.mpr hF,hk, Nat.add_sub_cancel_left]rw [hN] at hcrw [pr_on]refine ((div_le_div₀ (bp_pos _).le hc (bp_pos _) ht)).trans ?_unfold feerw [←bp_sub]refine bp_le ?_have h1 : 1 ≤ (t:ℝ) := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hehave hg := mul_le_mul_of_nonneg_right hz (show 0≤(t:ℝ) from Nat.cast_nonneg _)rw [Nat.cast_add]change _ ≤ -(1-0.05)*(t : ℝ)*Nrw [← sub_mul]exact mul_le_mul_of_nonneg_right (by linarith only [hkz,h1,hg]) (Nat.cast_nonneg _)· rw [pr_on]exact (div_nonpos_of_nonpos_of_nonneg (not_lt.mp hf) hpos.le).trans (bp_pos _).leend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156import OAI.Combinatorics.HadwigerCounterexample.GradientRealizationimport OAI.Combinatorics.HadwigerCounterexample.WalshBoundsnamespace OAI/-! # Conditional Cell Entropy -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix LinearMap Submodule Module Finsetopen scoped BigOperatorsvariable {p : Shape} {n N : ℕ}theorem plan_add_disjoint (a b : Plan p n) (h : ∀ z, Disjoint (a z) (b z)) :planRank (a⊔b)=planRank a+planRank b := byunfold planRankrw [← Finset.sum_add_distrib]refine Finset.sum_congr rfl fun i _ => ?_have he := Submodule.finrank_sup_add_finrank_inf_eq (a i) (b i)rw [(h i).eq_bot,finrank_bot,add_zero] at heexact hetheorem plan_new_disjoint (a b : Plan p n) (h : ∀ z,Disjoint (a z) (b z)) :planNew a b=planRank b := by rw [planNew,plan_add_disjoint a b h,Nat.add_sub_cancel_left]variable {I : Type} [Fintype I]def kslots (p : Shape) (I : Type) [Fintype I] :=Fintype.card I*(p.g-1)*2def kmax (p : Shape) := 56*(p.g-1)theorem slots_budget {w : I→Bool} (v : Volley p n I)(hb : v.bounded w) : kslots p I ≤ kmax p := byclassicalhave h := v.call_count hbunfold kslots kmax; nlinarithinstance instFKeys (t : Tagging p I) (N : ℕ) : Fintype (Keys (p:=p) t N) :=by classical exact inferInstancetheorem dim_keys (t : Tagging p I) :dim (Keys (p:=p) t N) = kslots p I * N := byhave h (l : Tag p.g) :dim (AtomKey (p:=p) l N)=(p.g-1)*(2*N) := byunfold AtomKey dimrw [finrank_pi_fintype]have he : finrank F (Bool → Vec (Fin N))=2*N := byrw [finrank_pi_fintype]simp_rw [show finrank F (Vec (Fin N))=_ from dim_vec _]simpsimp_rw [he]simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_star]; rflunfold dim Keys kslotsrw [finrank_pi_fintype]have hx i : finrank F (AtomKey (p:=p) (t i) N)=(p.g-1)*(2*N) := h (t i)simp_rw [hx]simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.cast_id]ringnamespace Volleyvariable {v : Volley p n I}theorem key_slots (t : Tagging p I) {q} {a : Plan p n}(h : v.avoids a q) :planNew a (v.keyPlan t) = kslots p I := byclassicallet Y := visits p thave hh i := key_independent v t h ihave he (z : Place p) : dim (keyPlan v t z)=Fintype.card (Y z.1) :=mrk_inj.mp (hh z).1rw [plan_new_disjoint a _ (fun i => Disjoint.mono_left (pin_le_table a i)(hh i).2.symm), planRank,Fintype.sum_prod_type]simp_rw [Fintype.sum_bool,he,←two_mul,←Finset.mul_sum]have hE : ∑ i : Comp p.g,Fintype.card (Y i)=Fintype.card I*(p.g-1) := byhave hf {A : Type} [Fintype A] (p : A → Prop) [DecidablePred p] :Fintype.card {i:A//p i}=∑ i:A, if p i then (1:ℕ) else 0 := byrw [Fintype.card_subtype,←Finset.sum_filter]; simphave hY (i) : Fintype.card (Y i)=∑ j:I,if inc i (t j) then (1:ℕ) else 0 := hf _simp_rw [hY]rw [Finset.sum_comm]simp_rw [← hf (fun i => inc i _)]have hz (j) : Fintype.card {i:Comp p.g//inc i (t j)}=p.g-1 := card_star (t j)simp_rw [hz]simprw [hE]; unfold kslots; ring/-- chosen reference x fixes the pin made of a and all key directionsfor every y in the same pin which agrees on query key. -/theorem key_pin (t : Tagging p I) {a : Pin p n N} {x y : UnitType p n N}(hx : a.agree x) (hy : a.agree y) (h : v.keys t x=v.keys t y) :(Pin.make (v.frozen a.sp t) x).agree y := byclassicalintro i u huobtain ⟨l,hl,r,⟨z,rfl⟩,rfl⟩ := Submodule.mem_sup.mp(show u∈a.sp i⊔v.keyPlan t i from hu)have hZ : images y i * v.keyM t i.1 = images x i * v.keyM t i.1 := byext b jobtain ⟨k,hk⟩ := jhave ht := congr_fun (congr_fun (congr_fun h k) (⟨i.1,hk⟩ : TagStar _)) i.2rw [v.keys_loc,v.keys_loc] at htexact congr_fun ht.symm bchange images y i *ᵥ _ = images x i *ᵥ _rw [Matrix.mulVec_add,Matrix.mulVec_add,hx _ _ hl,hy _ _ hl]rw [mulVecLin_apply,mulVec_mulVec,mulVec_mulVec,hZ]end Volleydef tau (N k : ℕ) := bp (-((k:ℝ)+0.01)*N)def hit (N : ℕ) := bp (-0.02*N)theorem in_clear {a f : Pin p n N} {k : ℕ} {ζ : ℝ} {w : Wgt (UnitType p n N)}(hz : ζ ≤ 0.004) (hkz : ζ*k ≤ 0.004)(hw : SubLaw w) (h : a.clear ζ w) (hF : a.sp≤f.sp) (hk : planRank f.sp=planRank a.sp+k)(S : UnitType p n N → Prop)(hS : ∀ x,S x → f.agree x) (ht : tau N k ≤ pr w S) :IsLaw (onW w S) ∧ f.clear 0.05 (onW w S) := byclassicalhave hpos : 0 < pr w S := lt_of_lt_of_le (bp_pos _) hthave hh : IsLaw (onW w S) := normW_law (subW_nonneg hw.nz _) hposrefine ⟨hh,fun b => ?_⟩let t := planNew f.sp b.spby_cases he : t=0· change pr _ _ ≤ fee N _ trw [he,fee]simp only [Nat.cast_zero,mul_zero,zero_mul,bp_zero]exact (pr_le_tot hh.nz).trans hh.total.lelet R := fun x => S x ∧ b.agree xby_cases hf : 0 < pr w R· obtain ⟨x,⟨hx,hB⟩,_⟩ := exists_of_pr_pos hw.nz hflet c := Pin.make (f.sp⊔b.sp) xhave hc : pr w R≤ fee N ζ (planNew a.sp c.sp) := (pr_mono hw.nz (q:=c.agree)(fun y hy => ((Pin.combine (hS x hx) hB).mpr ⟨hS _ hy.1,hy.2⟩))).trans (h c)have hN : planNew a.sp c.sp=k+t := byhave hh : planNew a.sp f.sp+t=planNew a.sp c.sp := planNew_mono_add hFrw [← hh]rw [planNew, sup_eq_right.mpr hF,hk, Nat.add_sub_cancel_left]rw [hN] at hcrw [pr_on]refine ((div_le_div₀ (bp_pos _).le hc (bp_pos _) ht)).trans ?_unfold feerw [←bp_sub]refine bp_le ?_have h1 : 1 ≤ (t:ℝ) := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hehave hg := mul_le_mul_of_nonneg_right hz (show 0≤(t:ℝ) from Nat.cast_nonneg _)rw [Nat.cast_add]change _ ≤ -(1-0.05)*(t : ℝ)*Nrw [← sub_mul]exact mul_le_mul_of_nonneg_right (by linarith only [hkz,h1,hg]) (Nat.cast_nonneg _)· rw [pr_on]exact (div_nonpos_of_nonpos_of_nonneg (not_lt.mp hf) hpos.le).trans (bp_pos _).leend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import OAI.Combinatorics.HadwigerCounterexample.FiniteProjectionCentersnamespace OAI/-! # Conditional Flags -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Realopen scoped BigOperatorsvariable {A B C X Y : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype X] [Fintype Y]variable {w : Wgt X}def stained (w : Wgt X) (f : X→Y) (i : Y) : Wgt X := byclassical exact if mapW w f i≠0 then onW w (fun x => f x=i) else wtheorem stained_law (f : X→Y) (hw : IsLaw w) (i : Y) : IsLaw (stained w f i) := byunfold stained; splitnext h => exact on_law hw.nz (lt_of_le_of_ne ((mapW_law hw f).nz _) (Ne.symm h))next => exact hwtheorem stain_rebuild (f : X→Y) (P : Y→Prop) (hw : IsLaw w) :subW w (P∘f) = mixW (subW (mapW w f) P) (stained w f) := byclassicalhave hh := disintegrate hw.nz ffunext ihave hi (y) :mapW w f y * stained w f y i=mapW w f y * onW w (fun x => f x=y) i := byby_cases h : mapW w f y=0 <;> simp [stained,h]have he := congr_fun hh iunfold subW mixW Function.compunfold mixW at herw [he,avg,Finset.sum_mul]unfold avg at *apply sum_congr rflintro j _rw [mul_right_comm _ (ind _), hi]by_cases hx : f i=j· rw [hx]simp only [onW_val,ind_zero hx,mul_zero,zero_div,zero_mul]theorem stain_inputs (f : X→Y) (hw : IsLaw w) :w=mixW (mapW w f) (stained w f) := byhave ht := stain_rebuild f (fun _ => True) hwunfold subW at htsimpa only [Function.comp_apply,ind_true,mul_one] using htvariable {μ : Wgt A}def colored (μ : Wgt A) (w : Wgt X) (v : A→ X→ Y) :=semi μ (fun i => mapW w (v i))def coloredP (w : Wgt X) (v : A→ X→Y) (K : A→X→B) :=fun i : A×Y => mapW (stained w (v i.1) i.2) (K i.1)def flaggedW (μ : Wgt A) (w : Wgt X) (v : A→X→Y) (K : A→X→B) (P : A→Y→Prop) :=mixW μ (fun i => mapW (subW w (P i ∘ v i)) (K i))theorem semi_total (μ : Wgt A) (v : A → Wgt Y) :tot (semi μ v)=avg μ (fun i=>tot (v i)) := bysimpa only [avg_const,mul_one] using semi_avg μ v (fun i=>1)theorem colored_ultra (hμ : IsLaw μ) (hw : IsLaw w) (K : A→X→B) (v : A→X→Y) :Ultra (colored μ w v) (coloredP w v K) := byhave ht (i) := mapW_law hw (v i)refine ⟨⟨fun x => mul_nonneg (hμ.nz _) ((ht _).nz _),?_⟩,fun i => mapW_law (stained_law _ hw _) (K i.1)⟩unfold colored; rw [semi_total]simp_rw [(ht _).total]exact hμ.avg_const _theorem flag_catalog (K : A→ X→B) (v : A→ X→ Y) (P : A→ Y→ Prop)(hw : IsLaw w) (hμ : IsLaw μ) :catalog (colored μ w v) (coloredP w v K)(flaggedW μ w v K P) := byclassicallet W := colored μ w vhave hh := (colored_ultra hμ hw K v).lawrefine ⟨subW W (fun i => P i.1 i.2),subW_nonneg hh.nz _,subW_le hh.nz _,?_⟩unfold flaggedWsimp_rw [stain_rebuild (v _) (P _) hw,map_mix]funext xsimp only [mixW,coloredP,colored,W,avg,subW,semi,Finset.mul_sum,Fintype.sum_prod_type]exact sum_congr rfl fun i _ => sum_congr rfl fun j _ => by ringtheorem colored_budget [Nonempty Y] (K : A→ X→B) (v : A→ X→ Y) (f : B→C)(hw : IsLaw w) (hμ : IsLaw μ) :budget (colored μ w v) (coloredP w v K) f ≤budget μ (fun i => mapW w (K i)) f + Real.log (num Y) := byunfold budget colored coloredPrw [semi_avg,← hμ.avg_const (Real.log _),← avg_add]apply avg_mono hμ.nzintro ilet u := mapW w (v i)have he : IsLaw u := mapW_law hw (v i)let q (j : Y) := mapW (mapW (stained w (v i) j) (K i)) fhave hq (j) : IsLaw (q j) := mapW_law (mapW_law (stained_law _ hw _) _) _have ht : mapW (mapW w (K i)) f=mixW u q := bycalc mapW _ _ = mapW (mapW (mixW u (stained w (v i))) (K i)) f :=congrArg (fun z => mapW (mapW z (K i)) f) (stain_inputs (v i) hw)_ = _ := by rw [map_mix,map_mix]change avg u (fun j => tension (q j) _)≤ tension _ _+_rw [tension_mix,add_comm _ (log _),ht]exact add_le_add_left (mix_charge he hq) _end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import OAI.Combinatorics.HadwigerCounterexample.FiniteProjectionCentersnamespace OAI/-! # Conditional Flags -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Realopen scoped BigOperatorsvariable {A B C X Y : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype X] [Fintype Y]variable {w : Wgt X}def stained (w : Wgt X) (f : X→Y) (i : Y) : Wgt X := byclassical exact if mapW w f i≠0 then onW w (fun x => f x=i) else wtheorem stained_law (f : X→Y) (hw : IsLaw w) (i : Y) : IsLaw (stained w f i) := byunfold stained; splitnext h => exact on_law hw.nz (lt_of_le_of_ne ((mapW_law hw f).nz _) (Ne.symm h))next => exact hwtheorem stain_rebuild (f : X→Y) (P : Y→Prop) (hw : IsLaw w) :subW w (P∘f) = mixW (subW (mapW w f) P) (stained w f) := byclassicalhave hh := disintegrate hw.nz ffunext ihave hi (y) :mapW w f y * stained w f y i=mapW w f y * onW w (fun x => f x=y) i := byby_cases h : mapW w f y=0 <;> simp [stained,h]have he := congr_fun hh iunfold subW mixW Function.compunfold mixW at herw [he,avg,Finset.sum_mul]unfold avg at *apply sum_congr rflintro j _rw [mul_right_comm _ (ind _), hi]by_cases hx : f i=j· rw [hx]simp only [onW_val,ind_zero hx,mul_zero,zero_div,zero_mul]theorem stain_inputs (f : X→Y) (hw : IsLaw w) :w=mixW (mapW w f) (stained w f) := byhave ht := stain_rebuild f (fun _ => True) hwunfold subW at htsimpa only [Function.comp_apply,ind_true,mul_one] using htvariable {μ : Wgt A}def colored (μ : Wgt A) (w : Wgt X) (v : A→ X→ Y) :=semi μ (fun i => mapW w (v i))def coloredP (w : Wgt X) (v : A→ X→Y) (K : A→X→B) :=fun i : A×Y => mapW (stained w (v i.1) i.2) (K i.1)def flaggedW (μ : Wgt A) (w : Wgt X) (v : A→X→Y) (K : A→X→B) (P : A→Y→Prop) :=mixW μ (fun i => mapW (subW w (P i ∘ v i)) (K i))theorem semi_total (μ : Wgt A) (v : A → Wgt Y) :tot (semi μ v)=avg μ (fun i=>tot (v i)) := bysimpa only [avg_const,mul_one] using semi_avg μ v (fun i=>1)theorem colored_ultra (hμ : IsLaw μ) (hw : IsLaw w) (K : A→X→B) (v : A→X→Y) :Ultra (colored μ w v) (coloredP w v K) := byhave ht (i) := mapW_law hw (v i)refine ⟨⟨fun x => mul_nonneg (hμ.nz _) ((ht _).nz _),?_⟩,fun i => mapW_law (stained_law _ hw _) (K i.1)⟩unfold colored; rw [semi_total]simp_rw [(ht _).total]exact hμ.avg_const _theorem flag_catalog (K : A→ X→B) (v : A→ X→ Y) (P : A→ Y→ Prop)(hw : IsLaw w) (hμ : IsLaw μ) :catalog (colored μ w v) (coloredP w v K)(flaggedW μ w v K P) := byclassicallet W := colored μ w vhave hh := (colored_ultra hμ hw K v).lawrefine ⟨subW W (fun i => P i.1 i.2),subW_nonneg hh.nz _,subW_le hh.nz _,?_⟩unfold flaggedWsimp_rw [stain_rebuild (v _) (P _) hw,map_mix]funext xsimp only [mixW,coloredP,colored,W,avg,subW,semi,Finset.mul_sum,Fintype.sum_prod_type]exact sum_congr rfl fun i _ => sum_congr rfl fun j _ => by ringtheorem colored_budget [Nonempty Y] (K : A→ X→B) (v : A→ X→ Y) (f : B→C)(hw : IsLaw w) (hμ : IsLaw μ) :budget (colored μ w v) (coloredP w v K) f ≤budget μ (fun i => mapW w (K i)) f + Real.log (num Y) := byunfold budget colored coloredPrw [semi_avg,← hμ.avg_const (Real.log _),← avg_add]apply avg_mono hμ.nzintro ilet u := mapW w (v i)have he : IsLaw u := mapW_law hw (v i)let q (j : Y) := mapW (mapW (stained w (v i) j) (K i)) fhave hq (j) : IsLaw (q j) := mapW_law (mapW_law (stained_law _ hw _) _) _have ht : mapW (mapW w (K i)) f=mixW u q := bycalc mapW _ _ = mapW (mapW (mixW u (stained w (v i))) (K i)) f :=congrArg (fun z => mapW (mapW z (K i)) f) (stain_inputs (v i) hw)_ = _ := by rw [map_mix,map_mix]change avg u (fun j => tension (q j) _)≤ tension _ _+_rw [tension_mix,add_comm _ (log _),ht]exact add_le_add_left (mix_charge he hq) _end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101import OAI.Combinatorics.HadwigerCounterexample.UnseenCrossingFactorizationimport OAI.Combinatorics.HadwigerCounterexample.GramConditionedLawsnamespace OAI/-! # Conditional Four Corners -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Module LinearMap Function Filteropen scoped BigOperatorsvariable {p : Shape} {n N : ℕ} {I J : Type} [Fintype I] [DecidableEq I]set_option maxHeartbeats 600000 inprivate theorem stip_mask (E : Rail I) (t : Vec E) (p : Wgt (Rack I N)) (δ : ℝ)(hδ : 0≤δ) (hh : |avg unif p|≤δ) (h : ∀ f:Vec E,f≠0 →|avg unif (fun i=>phasedBy (ledgerM E f) i*p i)|≤bp (-(N:ℝ)/2)) :|partMean (fun x=>traced x E t) p|≤δ+bp (-(N:ℝ)/2) := byclassicalhave he (f : Vec E) :|vectorPhase f t*avg unif (fun i : Rack I N=>phasedBy (ledgerM E f) i*p i)|≤ δ+bp (-(N:ℝ)/2) := byrw [abs_mul,vectorPhase,wsign_abs,one_mul]by_cases hz : f=0· subst f; simpa only [ledger_zero,layer_zero,one_mul] using hh.trans (le_add_of_nonneg_right (bp_pos (-(N:ℝ)/2)).le)exact (h f hz).trans (le_add_of_nonneg_left hδ)have hf : partMean (fun x=>traced x E t) p=avg unif (fun f:Vec E => vectorPhase f t*avg unif(fun i:Rack I N=>phasedBy (ledgerM E f) i*p i)) := byunfold partMean; simp_rw [rail_expand,←avg_mul]rw [avg_avg]; simp_rw [←avg_mul']; exact avg_congr (fun i _=>avg_congr fun j _=>by ring)rw [hf]exact (abs_avg_le unif_law.nz).trans (unif_law.avg_le he)namespace Templatevariable (v : Template p I)theorem pack_bound (v : Template p I) (j : I) (U : Wgt (Keys (p:=p) v.t N))(hU : ∀ i, |U i|≤1) (i) : |packSecs v j U i| ≤1 := byunfold packSecs; rw [Finset.abs_prod]exact (Finset.prod_le_prod₀ (fun i _=>abs_nonneg _) (fun i _ => hU _)).trans_eq (by simp)set_option maxHeartbeats 800000 intheorem lopsided (v : Template p I) (j : I) (q : I→F)(U : Wgt (Keys (p:=p) v.t N)) (δ : ℝ) (hδ : 0≤δ)(hU : ∀ x,|U x|≤1) (h : chairCut v j U δ)(hW : carried U (ownPart (p:=p) v.t q))(Z : GeoM v.seam) :|partMean (gramPart Z) (packSecs v j U)|≤δ+bp (-(N:ℝ)/2) := byclassicallet P := packSecs v j Ulet Q := gramPart Z (N:=N)have hb := bp_pos (-(N:ℝ)/2)by_cases hp : ∃ x,Q x∧P x≠0· obtain ⟨x,hx,hP⟩ := hplet E := cantRail v jlet T (y : v.PackStack N) := traced y E (cantVec v j Z)have hg i : ind (Q i)*P i=ind (T i)*P i := byby_cases hh : P i=0· rw [hh,mul_zero,mul_zero]rw [show Q i=T i from propext(cant_bridge v j q Z x i (pack_gate v j q U hW hP) (pack_gate v j q U hW hh) hx)]change |avg unif (fun x => ind (Q x)*P x)|≤_simp_rw [hg]exact stip_mask E (cantVec v j Z) P δ hδ (global_quart v j U hU δ h) (cant_leak v j U hU)have hh (x) : ind (Q x)*P x=0 := byby_cases he : Q x <;> simp only [he,ind_true,ind_false,one_mul,zero_mul]exact not_ne_iff.mp (fun hx => hp ⟨x,he,hx⟩)change |avg unif (fun x=>ind (Q x)*P x)|≤_simp_rw [hh,avg_zero,abs_zero]exact add_nonneg hδ hb.leset_option maxHeartbeats 800000 intheorem pack_hot (v : Template p I) (j : I) (q : I→F) (U : Wgt (Keys (p:=p) v.t N))(δ : ℝ) (hδ : 0≤δ) (hU : ∀ x, |U x|≤1) (h : chairCut v j U δ)(hW : carried U (ownPart (p:=p) v.t q))(Z : GeoM v.seam) (k : ℝ) (hk : ∀ i,num (Port v.seam i)≤ k)(hN : 2*k-(N:ℝ) ≤ -1) :let W := netFact v.seam|avg (rackStation Z N) (packSecs v j U)|≤2*W*(num (Ports p)*(2*bp (k-N)))+W*(δ+bp (-(N:ℝ)/2)) := byclassicalintro Wlet B := pr unif (gramPart Z (N:=N))have hb := wave_norm Z N (fun i => by linarith only [hN,hk i])have h0 : 0<W := netFact_poshave he : 0<B := (inv_pos_of_pos h0).trans_le hblet V := packSecs v j Ulet D := avg (rackWave Z N) Vhave hl := lopsided v j q U δ hδ hU h hW Zrw [part_reset _ _ he,abs_mul,abs_of_nonneg he.le] at hlhave hh :|D| ≤ W*(δ+bp (-(N:ℝ)/2)) := byapply le_of_mul_le_mul_left _ (inv_pos_of_pos h0)exact (le_trans (mul_le_mul_of_nonneg_right hb (abs_nonneg _)) hl).trans_eq (by field_simp)let A := avg (rackStation Z N) Vhave hs := compare_station Z V (pack_bound v j U hU) k hk hNchange |A|≤_exact le_trans (by simpa only [sub_zero] using (abs_sub_le A D 0)) (add_le_add hs hh)end Templateend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101import OAI.Combinatorics.HadwigerCounterexample.UnseenCrossingFactorizationimport OAI.Combinatorics.HadwigerCounterexample.GramConditionedLawsnamespace OAI/-! # Conditional Four Corners -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Module LinearMap Function Filteropen scoped BigOperatorsvariable {p : Shape} {n N : ℕ} {I J : Type} [Fintype I] [DecidableEq I]set_option maxHeartbeats 600000 inprivate theorem stip_mask (E : Rail I) (t : Vec E) (p : Wgt (Rack I N)) (δ : ℝ)(hδ : 0≤δ) (hh : |avg unif p|≤δ) (h : ∀ f:Vec E,f≠0 →|avg unif (fun i=>phasedBy (ledgerM E f) i*p i)|≤bp (-(N:ℝ)/2)) :|partMean (fun x=>traced x E t) p|≤δ+bp (-(N:ℝ)/2) := byclassicalhave he (f : Vec E) :|vectorPhase f t*avg unif (fun i : Rack I N=>phasedBy (ledgerM E f) i*p i)|≤ δ+bp (-(N:ℝ)/2) := byrw [abs_mul,vectorPhase,wsign_abs,one_mul]by_cases hz : f=0· subst f; simpa only [ledger_zero,layer_zero,one_mul] using hh.trans (le_add_of_nonneg_right (bp_pos (-(N:ℝ)/2)).le)exact (h f hz).trans (le_add_of_nonneg_left hδ)have hf : partMean (fun x=>traced x E t) p=avg unif (fun f:Vec E => vectorPhase f t*avg unif(fun i:Rack I N=>phasedBy (ledgerM E f) i*p i)) := byunfold partMean; simp_rw [rail_expand,←avg_mul]rw [avg_avg]; simp_rw [←avg_mul']; exact avg_congr (fun i _=>avg_congr fun j _=>by ring)rw [hf]exact (abs_avg_le unif_law.nz).trans (unif_law.avg_le he)namespace Templatevariable (v : Template p I)theorem pack_bound (v : Template p I) (j : I) (U : Wgt (Keys (p:=p) v.t N))(hU : ∀ i, |U i|≤1) (i) : |packSecs v j U i| ≤1 := byunfold packSecs; rw [Finset.abs_prod]exact (Finset.prod_le_prod₀ (fun i _=>abs_nonneg _) (fun i _ => hU _)).trans_eq (by simp)set_option maxHeartbeats 800000 intheorem lopsided (v : Template p I) (j : I) (q : I→F)(U : Wgt (Keys (p:=p) v.t N)) (δ : ℝ) (hδ : 0≤δ)(hU : ∀ x,|U x|≤1) (h : chairCut v j U δ)(hW : carried U (ownPart (p:=p) v.t q))(Z : GeoM v.seam) :|partMean (gramPart Z) (packSecs v j U)|≤δ+bp (-(N:ℝ)/2) := byclassicallet P := packSecs v j Ulet Q := gramPart Z (N:=N)have hb := bp_pos (-(N:ℝ)/2)by_cases hp : ∃ x,Q x∧P x≠0· obtain ⟨x,hx,hP⟩ := hplet E := cantRail v jlet T (y : v.PackStack N) := traced y E (cantVec v j Z)have hg i : ind (Q i)*P i=ind (T i)*P i := byby_cases hh : P i=0· rw [hh,mul_zero,mul_zero]rw [show Q i=T i from propext(cant_bridge v j q Z x i (pack_gate v j q U hW hP) (pack_gate v j q U hW hh) hx)]change |avg unif (fun x => ind (Q x)*P x)|≤_simp_rw [hg]exact stip_mask E (cantVec v j Z) P δ hδ (global_quart v j U hU δ h) (cant_leak v j U hU)have hh (x) : ind (Q x)*P x=0 := byby_cases he : Q x <;> simp only [he,ind_true,ind_false,one_mul,zero_mul]exact not_ne_iff.mp (fun hx => hp ⟨x,he,hx⟩)change |avg unif (fun x=>ind (Q x)*P x)|≤_simp_rw [hh,avg_zero,abs_zero]exact add_nonneg hδ hb.leset_option maxHeartbeats 800000 intheorem pack_hot (v : Template p I) (j : I) (q : I→F) (U : Wgt (Keys (p:=p) v.t N))(δ : ℝ) (hδ : 0≤δ) (hU : ∀ x, |U x|≤1) (h : chairCut v j U δ)(hW : carried U (ownPart (p:=p) v.t q))(Z : GeoM v.seam) (k : ℝ) (hk : ∀ i,num (Port v.seam i)≤ k)(hN : 2*k-(N:ℝ) ≤ -1) :let W := netFact v.seam|avg (rackStation Z N) (packSecs v j U)|≤2*W*(num (Ports p)*(2*bp (k-N)))+W*(δ+bp (-(N:ℝ)/2)) := byclassicalintro Wlet B := pr unif (gramPart Z (N:=N))have hb := wave_norm Z N (fun i => by linarith only [hN,hk i])have h0 : 0<W := netFact_poshave he : 0<B := (inv_pos_of_pos h0).trans_le hblet V := packSecs v j Ulet D := avg (rackWave Z N) Vhave hl := lopsided v j q U δ hδ hU h hW Zrw [part_reset _ _ he,abs_mul,abs_of_nonneg he.le] at hlhave hh :|D| ≤ W*(δ+bp (-(N:ℝ)/2)) := byapply le_of_mul_le_mul_left _ (inv_pos_of_pos h0)exact (le_trans (mul_le_mul_of_nonneg_right hb (abs_nonneg _)) hl).trans_eq (by field_simp)let A := avg (rackStation Z N) Vhave hs := compare_station Z V (pack_bound v j U hU) k hk hNchange |A|≤_exact le_trans (by simpa only [sub_zero] using (abs_sub_le A D 0)) (add_le_add hs hh)end Templateend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import OAI.Combinatorics.HadwigerCounterexample.SimultaneousProjectionnamespace OAI/-! # Conditional Large Set Hits -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix LinearMap Functionopen scoped BigOperators Topologyopen Templatevariable {p:Shape} {M n N K r s0:ℕ}namespace StatusAnalysisnamespace Quillvariable {q:Format} {d:Rates} {b:Bool} (w:Quill p q d b) (t : Tagging p (Messenger q))(z:Messenger q→F) (m:Mixer p n)def prelim (K:ℕ) (s:Charts p n d) (i:Messenger q) :=d (parcel b i)≤ K^2 ∧ Injective (s (parcel b i)) ∧∀ x,totalRank (s (parcel b i) x)≤ Kdef sameInk (i:Messenger q) (v: Magazine p (d (parcel b i))) :=Appearance.nearly p (w.amp i).1 (w.amp i).2.1 vstructure steady (K:ℕ) (s:Charts p n d) (o: UnitType p n N) : Prop whereframe : PreparationParameters.frameSide p m osteadyAxes (i:Messenger q) : prelim (b:=b) K s ienough i : (w.amp i).1.diagO=(w.amp i).2.1.1sufficesP i :let j:= parcel b i; let x:=w.allure t z icarried (w.policies t z n i) (fun y=> w.sameInk i (x.profile j o m (s j) y) →x.profile j o m (s j) y=w.amp i)set_option maxHeartbeats 800000 intheorem thinGlaze (Y : Silhouette p N r) (o : UnitType p n N) (i : Messenger q)(s : Charts p n d) (k:AtomKey (p:=p) (t i) N){δ : ℝ} (hd:0<δ)(hw:w.moral t z) (hp : w.steady t z m K s o)(he : gauze p δ δ Y m K o) (ht : 1≤p.r) (hn : 2*p.r≤n) :let x:=w.allure t z iδ ≤ x.reference Y (Y (t i) (z i) k) →basebeta p K/2 ≤ w.seraph t z o m s Y i k := byclassicalintro x hlet j:=parcel b ilet z':= w.amp i; let a:=Y (t i) (z i) klet μ:=x.reflected Y j o m (s j) ahave hx : x.apt := w.allure_apt t z hw ihave hm : IsLaw μ:= x.reflectedLaw Y (Appearance.witLaw hx ht hn) _ _ _ _ _obtain ⟨h1,h2,h3⟩:=hp.steadyAxes ihave hh := x.demonstrates Y o (m:=m) (s j) K j a δ hd z'.1 z'.2.1.2 (hw.2.2 i)(hw.2.1 i) ht hn h (he _) h1 h2 h3have hq (y) (h:μ y≠0) (hz:w.sameInk i y): y=w.amp i := bylet P := fun x=>w.sameInk i x → x=w.amp ihave hb : carried μ P:= x.reflection_exact Y j o m (s j) a P (hp.sufficesP i)exact (show P y from not_not.mp fun hi=>h (hb y hi)) hzhave h4 : (z'.1.diagO,z'.2.1.2)=z'.2.1 := Prod.ext (hp.enough i) rflrw [h4] at hhexact hh.trans ((pr_on_mono hm.nz hq).trans_eq (pr_point' ..))theorem tinyCell_loss (Y:Silhouette p N r) {δ:ℝ} (hd:0≤δ) (i : Messenger q)(hN: 2*num (Messenger q×Toast p)-(N:ℝ)≤ -1)(hh:2*num (Toast p)-(N:ℝ)≤ -1) :let x:= w.allure t z ilet μ:=lawNu p N t zpr μ (fun y=> x.reference Y (Y (t i) (z i) (y i)) < δ) ≤r*δ+2*netFact (trayPort p t)*bp (-(N:ℝ)/2) := byclassicalintro a μlet I:=Messenger qlet Ω:=fun i=> lawOmega p N (t i) (z i)let S:=fun y=>a.reference Y (Y (t i) (z i) y)<δlet f : ∀ i:Messenger q,Wgt (AtomKey (p:=p) (t i) N) := fun j=>if h:j=i then h ▸ (fun x : AtomKey (p:=p) (t i) N=> ind (S x)) else fun _=>1have hi : f i=fun x=>ind (S x) := by unfold f; simphave hf j (h:j≠i) : f j=fun _ => 1 := by unfold f; simp [h]have hg j x : |f j x| ≤ 1 := byby_cases h:j=i· subst j; rw [hi]; exact (abs_of_nonneg (ind_nonneg _)).le.trans (ind_le_one _)rw [hf j h]; simphave he x : prodW f x= ind (S (x i)) := byunfold prodW; rw [Finset.prod_eq_single i _ (by simp),hi]intro b _ hb; rw [hf _ hb]have hR :∏ i,avg (Ω i) (f i) = pr (Ω i) S := byrw [Finset.prod_eq_single i _ (by simp),hi]; rflintro b _ hb; rw [hf _ hb,(omegaLaw _ _ _ hh).avg_const]let L:=2*netFact (trayPort p t)*bp (-(N:ℝ)/2)have hM : pr μ (fun x=> S (x i)) ≤ pr (Ω i) S+L := byhave hm := reference_product t z f hg hNchange |avg μ (prodW f)-∏ i,avg (Ω i) (f i)|≤L at hmrw [show prodW f=(fun x=>ind (S (x i))) from funext he,hR] at hmexact sub_le_iff_le_add'.mp ((abs_le.mp hm).2)have hZ : pr (Ω i) S ≤ r*δ := bylet Q:=fun x=> a.reference Y x < δrw [show pr (Ω i) S= pr (a.reference Y) Q from (mapW_pr (Ω i) (Y (t i) (z i)) Q).symm]exact haze_small _ δ hdexact hM.trans (add_le_add_left hZ _)end Quillend StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import OAI.Combinatorics.HadwigerCounterexample.SimultaneousProjectionnamespace OAI/-! # Conditional Large Set Hits -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix LinearMap Functionopen scoped BigOperators Topologyopen Templatevariable {p:Shape} {M n N K r s0:ℕ}namespace StatusAnalysisnamespace Quillvariable {q:Format} {d:Rates} {b:Bool} (w:Quill p q d b) (t : Tagging p (Messenger q))(z:Messenger q→F) (m:Mixer p n)def prelim (K:ℕ) (s:Charts p n d) (i:Messenger q) :=d (parcel b i)≤ K^2 ∧ Injective (s (parcel b i)) ∧∀ x,totalRank (s (parcel b i) x)≤ Kdef sameInk (i:Messenger q) (v: Magazine p (d (parcel b i))) :=Appearance.nearly p (w.amp i).1 (w.amp i).2.1 vstructure steady (K:ℕ) (s:Charts p n d) (o: UnitType p n N) : Prop whereframe : PreparationParameters.frameSide p m osteadyAxes (i:Messenger q) : prelim (b:=b) K s ienough i : (w.amp i).1.diagO=(w.amp i).2.1.1sufficesP i :let j:= parcel b i; let x:=w.allure t z icarried (w.policies t z n i) (fun y=> w.sameInk i (x.profile j o m (s j) y) →x.profile j o m (s j) y=w.amp i)set_option maxHeartbeats 800000 intheorem thinGlaze (Y : Silhouette p N r) (o : UnitType p n N) (i : Messenger q)(s : Charts p n d) (k:AtomKey (p:=p) (t i) N){δ : ℝ} (hd:0<δ)(hw:w.moral t z) (hp : w.steady t z m K s o)(he : gauze p δ δ Y m K o) (ht : 1≤p.r) (hn : 2*p.r≤n) :let x:=w.allure t z iδ ≤ x.reference Y (Y (t i) (z i) k) →basebeta p K/2 ≤ w.seraph t z o m s Y i k := byclassicalintro x hlet j:=parcel b ilet z':= w.amp i; let a:=Y (t i) (z i) klet μ:=x.reflected Y j o m (s j) ahave hx : x.apt := w.allure_apt t z hw ihave hm : IsLaw μ:= x.reflectedLaw Y (Appearance.witLaw hx ht hn) _ _ _ _ _obtain ⟨h1,h2,h3⟩:=hp.steadyAxes ihave hh := x.demonstrates Y o (m:=m) (s j) K j a δ hd z'.1 z'.2.1.2 (hw.2.2 i)(hw.2.1 i) ht hn h (he _) h1 h2 h3have hq (y) (h:μ y≠0) (hz:w.sameInk i y): y=w.amp i := bylet P := fun x=>w.sameInk i x → x=w.amp ihave hb : carried μ P:= x.reflection_exact Y j o m (s j) a P (hp.sufficesP i)exact (show P y from not_not.mp fun hi=>h (hb y hi)) hzhave h4 : (z'.1.diagO,z'.2.1.2)=z'.2.1 := Prod.ext (hp.enough i) rflrw [h4] at hhexact hh.trans ((pr_on_mono hm.nz hq).trans_eq (pr_point' ..))theorem tinyCell_loss (Y:Silhouette p N r) {δ:ℝ} (hd:0≤δ) (i : Messenger q)(hN: 2*num (Messenger q×Toast p)-(N:ℝ)≤ -1)(hh:2*num (Toast p)-(N:ℝ)≤ -1) :let x:= w.allure t z ilet μ:=lawNu p N t zpr μ (fun y=> x.reference Y (Y (t i) (z i) (y i)) < δ) ≤r*δ+2*netFact (trayPort p t)*bp (-(N:ℝ)/2) := byclassicalintro a μlet I:=Messenger qlet Ω:=fun i=> lawOmega p N (t i) (z i)let S:=fun y=>a.reference Y (Y (t i) (z i) y)<δlet f : ∀ i:Messenger q,Wgt (AtomKey (p:=p) (t i) N) := fun j=>if h:j=i then h ▸ (fun x : AtomKey (p:=p) (t i) N=> ind (S x)) else fun _=>1have hi : f i=fun x=>ind (S x) := by unfold f; simphave hf j (h:j≠i) : f j=fun _ => 1 := by unfold f; simp [h]have hg j x : |f j x| ≤ 1 := byby_cases h:j=i· subst j; rw [hi]; exact (abs_of_nonneg (ind_nonneg _)).le.trans (ind_le_one _)rw [hf j h]; simphave he x : prodW f x= ind (S (x i)) := byunfold prodW; rw [Finset.prod_eq_single i _ (by simp),hi]intro b _ hb; rw [hf _ hb]have hR :∏ i,avg (Ω i) (f i) = pr (Ω i) S := byrw [Finset.prod_eq_single i _ (by simp),hi]; rflintro b _ hb; rw [hf _ hb,(omegaLaw _ _ _ hh).avg_const]let L:=2*netFact (trayPort p t)*bp (-(N:ℝ)/2)have hM : pr μ (fun x=> S (x i)) ≤ pr (Ω i) S+L := byhave hm := reference_product t z f hg hNchange |avg μ (prodW f)-∏ i,avg (Ω i) (f i)|≤L at hmrw [show prodW f=(fun x=>ind (S (x i))) from funext he,hR] at hmexact sub_le_iff_le_add'.mp ((abs_le.mp hm).2)have hZ : pr (Ω i) S ≤ r*δ := bylet Q:=fun x=> a.reference Y x < δrw [show pr (Ω i) S= pr (a.reference Y) Q from (mapW_pr (Ω i) (Y (t i) (z i)) Q).symm]exact haze_small _ δ hdexact hM.trans (add_le_add_left hZ _)end Quillend StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioningnamespace OAI/-! # Conditional Product Laws -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsvariable {A B I : Type} [Fintype A] [Fintype B]theorem subLaw_pair {w : Wgt A} {v : Wgt B} (hw : SubLaw w) (hv : SubLaw v) :SubLaw (pairW w v) := byrefine ⟨fun x => mul_nonneg (hw.nz _) (hv.nz _),?_⟩rw [pairW_tot]exact (mul_le_mul hw.total hv.total (tot_nonneg hv.nz) (by norm_num)).trans_eq (one_mul _)theorem pair_unif :unif (α:=A×B) = pairW unif unif := byfunext x; simp [pairW,unif_apply,mul_comm]theorem unifOn_slice (p : A × B → Prop) (x : A) (y : B) :unifOn p (x,y) =mapW (unifOn p) Prod.fst x * unifOn (fun y => p (x,y)) y := byclassicalhave hm : mapW (unifOn p) Prod.fst x =nbr (fun y => p (x,y)) / nbr p := bysimp only [mapW,pr,avg,Fintype.sum_prod_type,unifOn_val, nbr,tot]rw [Finset.sum_eq_single x]· simp [ind_true,div_eq_mul_inv,Finset.sum_mul]· intro b _ hbsimp [ind,hb]· simprw [hm,unifOn_val,unifOn_val]by_cases h : p (x,y)· have hh {A : Type} [Fintype A] (p : A → Prop) (x : A) (hx : p x) : 0 < nbr p := byhave hp := weight_le_tot (fun y => ind_nonneg (p y)) xexact lt_of_lt_of_le (ind_one hx ▸ zero_lt_one) hprw [ind_one h]have hv := hh _ _ hhave hw := hh (fun y => p (x,y)) _ hfield_simp· rw [ind_zero h]ringtheorem unifOn_and (p q : A → Prop) :onW (unifOn p) q = unifOn (fun x => p x ∧ q x) := byclassicalhave hp : pr (unifOn p) q = nbr (fun x => p x ∧ q x) / nbr p := bysimp only [pr,avg,unifOn_val,div_eq_mul_inv,ind_and,nbr,tot,Finset.sum_mul]refine Finset.sum_congr rfl fun i _ => ?_ringfunext xrw [onW_val,hp,unifOn_val,unifOn_val,ind_and]by_cases h : p x· by_cases g : q x· have hl (p : A → Prop) (h : p x) : 0 < nbr p :=lt_of_lt_of_le (ind_one h ▸ zero_lt_one) (weight_le_tot (fun y => ind_nonneg (p y)) x)have hh := hl p hhave hg := hl (fun x => p x ∧ q x) ⟨h,g⟩field_simp· rw [ind_zero g]ring· rw [ind_zero h]ringtheorem unifOn_and_prod (p : A → Prop) (q : B → Prop) :unifOn (fun x : A × B => p x.1 ∧ q x.2) = pairW (unifOn p) (unifOn q) := byhave h :nbr (fun x : A × B => p x.1 ∧ q x.2) = nbr p * nbr q := bychange tot _ = _ * _simp_rw [ind_and]exact pairW_tot (fun x => ind (p x)) (fun y => ind (q y))funext xsimp only [pairW,unifOn_val,h,ind_and]ring_nftheorem pr_cap {w v : Wgt A} {c : ℝ} (h : ∀ x, w x ≤ c*v x) (p : A → Prop) :pr w p ≤ c*pr v p := calc_ ≤ pr (fun x => c*v x) p := pr_mono_left (w:=w) (v:=fun x => c*v x) h __ = _ := by simp only [pr,avg,Finset.mul_sum,mul_assoc]def semi (w : Wgt A) (k : A → Wgt B) : Wgt (A × B) := fun x => w x.1 * k x.1 x.2theorem semi_avg (w : Wgt A) (k : A → Wgt B) (f : A × B → ℝ) :avg (semi w k) f = avg w (fun x => avg (k x) (fun y => f (x,y))) := bysimp only [avg,semi,Fintype.sum_prod_type,Finset.mul_sum,mul_assoc]theorem pair_semi_avg (w w' : Wgt A) (k k' : A → Wgt B) (f : (A × B) × (A × B) → ℝ) :avg (pairW (semi w k) (semi w' k')) f =avg (pairW w w') (fun x =>avg (pairW (k x.1) (k' x.2)) (fun y => f ((x.1,y.1), (x.2,y.2)))) := bysimp only [pairW_avg, semi_avg]refine avg_congr fun x _ => ?_exact avg_avg _ _ _theorem pair_semi_pr (w w' : Wgt A) (k k' : A → Wgt B) (p : A × A → Prop) (q : B × B → Prop) :pr (pairW (semi w k) (semi w' k')) (fun x => p (x.1.1,x.2.1) ∧ q (x.1.2,x.2.2)) =avg (pairW w w') (fun x => ind (p x) * pr (pairW (k x.1) (k' x.2)) q) := byunfold prrw [pair_semi_avg]simp_rw [ind_and]refine avg_congr fun x _ => ?_exact avg_mul' _ _ _variable [Fintype I] [DecidableEq I]/-- Reassociate two arrays of independent columns into componentwise independent pairs. -/theorem prodW_pair_pr (w v : I → Wgt A) (p : I → A × A → Prop) :pr (pairW (prodW w) (prodW v)) (fun x => ∀ i, p i (x.1 i,x.2 i)) =∏ i, pr (pairW (w i) (v i)) (p i) := bysimp_rw [pr,ind_all,pairW_avg]have hx (x : I → A) :avg (prodW v) (fun y => ∏ i, ind (p i (x i,y i))) =∏ i, avg (v i) (fun y => ind (p i (x i,y))) :=prodW_avg _ (fun i y => ind (p i (x i,y)))simp_rw [hx]exact prodW_avg w (fun i x => avg (v i) (fun y => ind (p i (x,y))))end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioningnamespace OAI/-! # Conditional Product Laws -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsvariable {A B I : Type} [Fintype A] [Fintype B]theorem subLaw_pair {w : Wgt A} {v : Wgt B} (hw : SubLaw w) (hv : SubLaw v) :SubLaw (pairW w v) := byrefine ⟨fun x => mul_nonneg (hw.nz _) (hv.nz _),?_⟩rw [pairW_tot]exact (mul_le_mul hw.total hv.total (tot_nonneg hv.nz) (by norm_num)).trans_eq (one_mul _)theorem pair_unif :unif (α:=A×B) = pairW unif unif := byfunext x; simp [pairW,unif_apply,mul_comm]theorem unifOn_slice (p : A × B → Prop) (x : A) (y : B) :unifOn p (x,y) =mapW (unifOn p) Prod.fst x * unifOn (fun y => p (x,y)) y := byclassicalhave hm : mapW (unifOn p) Prod.fst x =nbr (fun y => p (x,y)) / nbr p := bysimp only [mapW,pr,avg,Fintype.sum_prod_type,unifOn_val, nbr,tot]rw [Finset.sum_eq_single x]· simp [ind_true,div_eq_mul_inv,Finset.sum_mul]· intro b _ hbsimp [ind,hb]· simprw [hm,unifOn_val,unifOn_val]by_cases h : p (x,y)· have hh {A : Type} [Fintype A] (p : A → Prop) (x : A) (hx : p x) : 0 < nbr p := byhave hp := weight_le_tot (fun y => ind_nonneg (p y)) xexact lt_of_lt_of_le (ind_one hx ▸ zero_lt_one) hprw [ind_one h]have hv := hh _ _ hhave hw := hh (fun y => p (x,y)) _ hfield_simp· rw [ind_zero h]ringtheorem unifOn_and (p q : A → Prop) :onW (unifOn p) q = unifOn (fun x => p x ∧ q x) := byclassicalhave hp : pr (unifOn p) q = nbr (fun x => p x ∧ q x) / nbr p := bysimp only [pr,avg,unifOn_val,div_eq_mul_inv,ind_and,nbr,tot,Finset.sum_mul]refine Finset.sum_congr rfl fun i _ => ?_ringfunext xrw [onW_val,hp,unifOn_val,unifOn_val,ind_and]by_cases h : p x· by_cases g : q x· have hl (p : A → Prop) (h : p x) : 0 < nbr p :=lt_of_lt_of_le (ind_one h ▸ zero_lt_one) (weight_le_tot (fun y => ind_nonneg (p y)) x)have hh := hl p hhave hg := hl (fun x => p x ∧ q x) ⟨h,g⟩field_simp· rw [ind_zero g]ring· rw [ind_zero h]ringtheorem unifOn_and_prod (p : A → Prop) (q : B → Prop) :unifOn (fun x : A × B => p x.1 ∧ q x.2) = pairW (unifOn p) (unifOn q) := byhave h :nbr (fun x : A × B => p x.1 ∧ q x.2) = nbr p * nbr q := bychange tot _ = _ * _simp_rw [ind_and]exact pairW_tot (fun x => ind (p x)) (fun y => ind (q y))funext xsimp only [pairW,unifOn_val,h,ind_and]ring_nftheorem pr_cap {w v : Wgt A} {c : ℝ} (h : ∀ x, w x ≤ c*v x) (p : A → Prop) :pr w p ≤ c*pr v p := calc_ ≤ pr (fun x => c*v x) p := pr_mono_left (w:=w) (v:=fun x => c*v x) h __ = _ := by simp only [pr,avg,Finset.mul_sum,mul_assoc]def semi (w : Wgt A) (k : A → Wgt B) : Wgt (A × B) := fun x => w x.1 * k x.1 x.2theorem semi_avg (w : Wgt A) (k : A → Wgt B) (f : A × B → ℝ) :avg (semi w k) f = avg w (fun x => avg (k x) (fun y => f (x,y))) := bysimp only [avg,semi,Fintype.sum_prod_type,Finset.mul_sum,mul_assoc]theorem pair_semi_avg (w w' : Wgt A) (k k' : A → Wgt B) (f : (A × B) × (A × B) → ℝ) :avg (pairW (semi w k) (semi w' k')) f =avg (pairW w w') (fun x =>avg (pairW (k x.1) (k' x.2)) (fun y => f ((x.1,y.1), (x.2,y.2)))) := bysimp only [pairW_avg, semi_avg]refine avg_congr fun x _ => ?_exact avg_avg _ _ _theorem pair_semi_pr (w w' : Wgt A) (k k' : A → Wgt B) (p : A × A → Prop) (q : B × B → Prop) :pr (pairW (semi w k) (semi w' k')) (fun x => p (x.1.1,x.2.1) ∧ q (x.1.2,x.2.2)) =avg (pairW w w') (fun x => ind (p x) * pr (pairW (k x.1) (k' x.2)) q) := byunfold prrw [pair_semi_avg]simp_rw [ind_and]refine avg_congr fun x _ => ?_exact avg_mul' _ _ _variable [Fintype I] [DecidableEq I]/-- Reassociate two arrays of independent columns into componentwise independent pairs. -/theorem prodW_pair_pr (w v : I → Wgt A) (p : I → A × A → Prop) :pr (pairW (prodW w) (prodW v)) (fun x => ∀ i, p i (x.1 i,x.2 i)) =∏ i, pr (pairW (w i) (v i)) (p i) := bysimp_rw [pr,ind_all,pairW_avg]have hx (x : I → A) :avg (prodW v) (fun y => ∏ i, ind (p i (x i,y i))) =∏ i, avg (v i) (fun y => ind (p i (x i,y))) :=prodW_avg _ (fun i y => ind (p i (x i,y)))simp_rw [hx]exact prodW_avg w (fun i x => avg (v i) (fun y => ind (p i (x,y))))end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import OAI.Combinatorics.HadwigerCounterexample.HistogramBoundsnamespace OAI/-! # Conditional Projection -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Real Functionopen scoped BigOperatorsvariable {A B C K : Type} [Fintype A] [Fintype B] [Fintype C]def dip (μ f g : Wgt A) := avg μ (fun i => f i*g i)def ode (μ f : Wgt A) := dip μ f fdef cashbook (μ : Wgt A) (f : A→B) (g : Wgt A) :=fun i => mapW (fun x => μ x*g x) f i / mapW μ f idef banner (μ : Wgt A) (f : A→B) (g : Wgt A) := cashbook μ f g ∘ ftheorem ode_nonneg {μ : Wgt A} (hμ : ∀ i,0 ≤ μ i) (f : Wgt A) : 0≤ ode μ f :=avg_nonneg hμ (fun _ => mul_self_nonneg _)theorem ode_upper {μ : Wgt A} (hμ : SubLaw μ) (f : Wgt A) (B : ℝ)(hf : ∀ i,|f i|≤B) : ode μ f ≤ B^2 := byapply hμ.avg_le (sq_nonneg _)intro iexact (le_of_eq (Eq.symm (pow_two _))).trans((le_of_eq (sq_abs (f i)).symm).trans (pow_le_pow_left₀ (abs_nonneg _) (hf i) 2))theorem dip_sym (μ f g : Wgt A) : dip μ f g=dip μ g f := by unfold dip; simp only [mul_comm]theorem dip_sub (μ f g h : Wgt A) :dip μ (fun i=> f i-g i) h=dip μ f h-dip μ g h := byunfold dip; simp only [sub_mul,avg_sub]omit [Fintype B] intheorem cashbook_bound (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A)(b : ℝ) (hb : 0≤b) (h : ∀ i,|g i|≤b) (i) : |cashbook μ f g i| ≤ b := byhave he : cashbook μ f g i=avg (onW μ (fun x=>f x=i)) g := byunfold cashbook onWrw [avg_norm,subW_tot]unfold mapW pr avg subW; congr 1exact Finset.sum_congr rfl fun j _ => by ringhave hw : SubLaw (onW μ (fun x=>f x=i)) := normW_subLaw (subW_nonneg hμ _)rw [he]exact (abs_avg_le hw.nz).trans (hw.avg_le hb h)theorem cash_orth (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A) (h : Wgt B) :dip μ (banner μ f g) (h ∘ f)=dip μ g (h ∘ f) := byclassicallet w := fun x=> μ x*g xhave he : pour μ f (mapW w f) = fun i => μ i*banner μ f g i := rflhave hz : lsupp w μ := fun _ hi => left_ne_zero_of_mul hihave ht := map_pour μ f _ (hz.map hμ f)rw [he] at hthave hi := congrArg (fun w' => avg w' h) htsimp_rw [mapW_avg] at hisimpa only [w,dip,avg,mul_assoc,Function.comp_apply] using hitheorem ode_step (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : Wgt A)(p : A→B) (q : B→C) :ode μ (banner μ p f)=ode μ (banner μ (q∘p) f)+ode μ (fun i => banner μ p f i - banner μ (q∘p) f i) := byclassicallet g := banner μ p f; let h := banner μ (q ∘ p) fhave hh : ode μ h=dip μ g h :=(cash_orth μ hμ (q∘p) f (cashbook μ (q∘p) f)).trans(cash_orth μ hμ p f (cashbook μ (q∘p) f ∘ q)).symmhave hi i : (g i - h i)*(g i-h i)=g i*g i - 2*(g i*h i)+h i*h i := by ringchange ode μ g=ode μ h+dip μ (fun i => g i-h i) (fun i=>g i-h i)unfold dipsimp_rw [hi,avg_add,avg_sub,avg_mul']change ode μ g=ode μ h+(ode μ g-2*dip μ g h + ode μ h)linarith only [hh]theorem archive_gain {μ : Wgt A} (hw : SubLaw μ) (f : Wgt A)(p : A→B) (q : B→ C)(h : Wgt B) (hh : ∀ i:A,|h (p i)| ≤1) :(dip μ (fun i => f i - banner μ (q∘p) f i) (h ∘ p))^2 ≤ode μ (banner μ p f)-ode μ (banner μ (q∘p) f) := bylet u := banner μ p f; let v := banner μ (q∘p) flet w i := u i-v irw [ode_step μ hw.nz f p q]have he : dip μ (fun i=> f i - banner μ (q∘p) f i) (h∘p)=dip μ w (h∘p) := byunfold wrw [dip_sub,dip_sub,cash_orth μ hw.nz p f h]have ht : ode μ (h∘p) ≤ 1 := (ode_upper hw (h∘p) 1 hh).trans_eq (by ring)have hq : dip μ w (h∘p)^2≤ode μ w*ode μ (h∘p) := bysimpa only [ode,dip,pow_two] using avg_CS hw.nz w (h∘p)rw [he]apply le_trans hqrefine (mul_le_mul_of_nonneg_left ht (ode_nonneg hw.nz w)).trans_eq ?_unfold w u vringend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import OAI.Combinatorics.HadwigerCounterexample.HistogramBoundsnamespace OAI/-! # Conditional Projection -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Real Functionopen scoped BigOperatorsvariable {A B C K : Type} [Fintype A] [Fintype B] [Fintype C]def dip (μ f g : Wgt A) := avg μ (fun i => f i*g i)def ode (μ f : Wgt A) := dip μ f fdef cashbook (μ : Wgt A) (f : A→B) (g : Wgt A) :=fun i => mapW (fun x => μ x*g x) f i / mapW μ f idef banner (μ : Wgt A) (f : A→B) (g : Wgt A) := cashbook μ f g ∘ ftheorem ode_nonneg {μ : Wgt A} (hμ : ∀ i,0 ≤ μ i) (f : Wgt A) : 0≤ ode μ f :=avg_nonneg hμ (fun _ => mul_self_nonneg _)theorem ode_upper {μ : Wgt A} (hμ : SubLaw μ) (f : Wgt A) (B : ℝ)(hf : ∀ i,|f i|≤B) : ode μ f ≤ B^2 := byapply hμ.avg_le (sq_nonneg _)intro iexact (le_of_eq (Eq.symm (pow_two _))).trans((le_of_eq (sq_abs (f i)).symm).trans (pow_le_pow_left₀ (abs_nonneg _) (hf i) 2))theorem dip_sym (μ f g : Wgt A) : dip μ f g=dip μ g f := by unfold dip; simp only [mul_comm]theorem dip_sub (μ f g h : Wgt A) :dip μ (fun i=> f i-g i) h=dip μ f h-dip μ g h := byunfold dip; simp only [sub_mul,avg_sub]omit [Fintype B] intheorem cashbook_bound (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A)(b : ℝ) (hb : 0≤b) (h : ∀ i,|g i|≤b) (i) : |cashbook μ f g i| ≤ b := byhave he : cashbook μ f g i=avg (onW μ (fun x=>f x=i)) g := byunfold cashbook onWrw [avg_norm,subW_tot]unfold mapW pr avg subW; congr 1exact Finset.sum_congr rfl fun j _ => by ringhave hw : SubLaw (onW μ (fun x=>f x=i)) := normW_subLaw (subW_nonneg hμ _)rw [he]exact (abs_avg_le hw.nz).trans (hw.avg_le hb h)theorem cash_orth (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A) (h : Wgt B) :dip μ (banner μ f g) (h ∘ f)=dip μ g (h ∘ f) := byclassicallet w := fun x=> μ x*g xhave he : pour μ f (mapW w f) = fun i => μ i*banner μ f g i := rflhave hz : lsupp w μ := fun _ hi => left_ne_zero_of_mul hihave ht := map_pour μ f _ (hz.map hμ f)rw [he] at hthave hi := congrArg (fun w' => avg w' h) htsimp_rw [mapW_avg] at hisimpa only [w,dip,avg,mul_assoc,Function.comp_apply] using hitheorem ode_step (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : Wgt A)(p : A→B) (q : B→C) :ode μ (banner μ p f)=ode μ (banner μ (q∘p) f)+ode μ (fun i => banner μ p f i - banner μ (q∘p) f i) := byclassicallet g := banner μ p f; let h := banner μ (q ∘ p) fhave hh : ode μ h=dip μ g h :=(cash_orth μ hμ (q∘p) f (cashbook μ (q∘p) f)).trans(cash_orth μ hμ p f (cashbook μ (q∘p) f ∘ q)).symmhave hi i : (g i - h i)*(g i-h i)=g i*g i - 2*(g i*h i)+h i*h i := by ringchange ode μ g=ode μ h+dip μ (fun i => g i-h i) (fun i=>g i-h i)unfold dipsimp_rw [hi,avg_add,avg_sub,avg_mul']change ode μ g=ode μ h+(ode μ g-2*dip μ g h + ode μ h)linarith only [hh]theorem archive_gain {μ : Wgt A} (hw : SubLaw μ) (f : Wgt A)(p : A→B) (q : B→ C)(h : Wgt B) (hh : ∀ i:A,|h (p i)| ≤1) :(dip μ (fun i => f i - banner μ (q∘p) f i) (h ∘ p))^2 ≤ode μ (banner μ p f)-ode μ (banner μ (q∘p) f) := bylet u := banner μ p f; let v := banner μ (q∘p) flet w i := u i-v irw [ode_step μ hw.nz f p q]have he : dip μ (fun i=> f i - banner μ (q∘p) f i) (h∘p)=dip μ w (h∘p) := byunfold wrw [dip_sub,dip_sub,cash_orth μ hw.nz p f h]have ht : ode μ (h∘p) ≤ 1 := (ode_upper hw (h∘p) 1 hh).trans_eq (by ring)have hq : dip μ w (h∘p)^2≤ode μ w*ode μ (h∘p) := bysimpa only [ode,dip,pow_two] using avg_CS hw.nz w (h∘p)rw [he]apply le_trans hqrefine (mul_le_mul_of_nonneg_left ht (ode_nonneg hw.nz w)).trans_eq ?_unfold w u vringend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110import OAI.Combinatorics.HadwigerCounterexample.CellPositivityScalesnamespace OAI/-! # Conditional Signature Positivity -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix Functionopen scoped BigOperators Topologyvariable {p:Shape} {n N K r d : ℕ}namespace StatusAnalysisopen Templatenamespace Appearancevariable (x : Appearance p) (Y : Silhouette p N r)theorem smudges (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d) (i:Nodes) (j : Knobs p.g n) :(x.profile i o m v j).2.1=((scan p x.l x.f j).diagO,stains x.trot m v j) := byapply Prod.ext· exact role_scan p _ _ _ _funext i; exact T_swap m _ _def nearly (p: Shape) (z: Digest p.g) (u: Par d) (x: Magazine p d) :=x.1=z∧ x.2.1=uset_option maxHeartbeats 800000 intheorem demonstrates (o : UnitType p n N) {m : Mixer p n}(v : Ax p n d) (K:ℕ) (i:Nodes) (j:Fin r) (δ : ℝ) (hd:0<δ)(z : Digest p.g) (u:Cell d)(he : z.feasible x.l x.f) (hf : z.sumBit=x.q) (ht : 1≤p.r) (hn : 2*p.r≤n)(hh : δ≤ x.reference Y j)(hs : smoothSilk p δ δ Y m K (onSide o i)) (hK : d≤K^2)(hV : Injective v) (hv : ∀ x,totalRank (v x) ≤ K) :basebeta p K/2 ≤ pr (x.reflected Y i o m v j) (nearly p z (z.diagO,u)) := byclassicalhave ha : x.apt := ⟨z,he,hf⟩let μ:= x.reference Y jlet f := onSide o iobtain ⟨hM,hB⟩:= hs xspecialize hM haspecialize hB z j he hf hhlet U (y:AtomKey (p:=p) (x.trot.t ()) N) := Y x.l x.q y=jhave hm : basebeta p K*μ ≤pr (x.wit n) (fun y=> (scan p x.l x.f y=z∧Y x.l x.q (x.face f y)=j) ∧stains x.trot m v y=u) := bylet h := patrol_beta x.trot U m K z he ht hn fdsimp only at hrw [hf] at hexact h hB d hK v hV hv ulet w := nearly p z (z.diagO,u)have hq (y : Knobs p.g n) :(scan p x.l x.f y=z ∧ Y x.l x.q (x.face f y)=j) ∧ stains x.trot m v y=u →x.showTag Y (onSide o i) y=j∧ w (x.profile i o m v y) := byrintro ⟨⟨h,h1⟩,h2⟩refine ⟨h1,h,?_⟩; rw [smudges,h,h2]have hW := witLaw ha ht hnhave heq := (hm.trans (pr_mono hW.nz hq)).trans_eq (x.show_pr Y i o m v hW j w)let ν:= x.empirical Y f jhave h2 : ν ≤ 2*μ := byhave hz : |μ-ν|≤δ := le_trans(Finset.single_le_sum (fun k _ => abs_nonneg (x.reference Y k-x.empirical Y f k))(Finset.mem_univ j)) hMchange δ≤ μ at hhlinarith [(abs_le.mp hz).1]let Q := pr (x.reflected Y i o m v j) whave h3 : basebeta p K*μ≤ ν*Q := heqhave ht := mul_le_mul_of_nonneg_right h2(show 0≤ Q from pr_nonneg (x.reflectedLaw Y hW i o m v j).nz)apply le_of_mul_le_mul_right _ (hd.trans_le hh)change _*μ ≤ Q*μlinarith only [h3,ht]def fitsink (x : Appearance p) (w : Magazine p d) :=w.1.feasible x.l x.f ∧ w.1.sumBit=x.q ∧ w.1.diagO=w.2.1.1theorem rawink (x : Appearance p) (m : Mixer p n) (i : Nodes) (o : UnitType p n N)(v : Ax p n d) :carried (x.wit n) (x.fitsink ∘ x.profile i o m v) := bylet w:=x.wit nhave hC : carried w (fun y=>dialed p x.l x.f y=x.q) :=normW_carried (subW_carried (spins p n) _)intro y hirefine hC y (fun h=>?_); apply hirefine ⟨?_,h, (role_scan p _ _ _ _).symm⟩intro j hjunfold profile; change scan p x.l x.f y j=0unfold scansimp [hj]theorem refInk (i : Nodes) (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d)(j:Fin r) : carried (x.reflected Y i o m v j) x.fitsink :=reflection_exact x Y i o m v j _ (rawink x m i o v)end Appearancetheorem haze_small (w : Wgt (Fin r)) (δ : ℝ) (hδ : 0≤δ) :pr w (fun x=> w x < δ) ≤ r*δ := byclassicalunfold pr avgrefine (Finset.sum_le_sum (s:=Finset.univ) (g:=fun _=>δ) (fun i _=>?_)).trans_eq (by simp)dsimp onlyby_cases h:w i<δ· rw [ind_one h,mul_one]; exact h.lerw [ind_zero h,mul_zero]; exact hδend StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110import OAI.Combinatorics.HadwigerCounterexample.CellPositivityScalesnamespace OAI/-! # Conditional Signature Positivity -/noncomputable sectionnamespace HadwigerCounterexampleopen Filter Finset Matrix Functionopen scoped BigOperators Topologyvariable {p:Shape} {n N K r d : ℕ}namespace StatusAnalysisopen Templatenamespace Appearancevariable (x : Appearance p) (Y : Silhouette p N r)theorem smudges (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d) (i:Nodes) (j : Knobs p.g n) :(x.profile i o m v j).2.1=((scan p x.l x.f j).diagO,stains x.trot m v j) := byapply Prod.ext· exact role_scan p _ _ _ _funext i; exact T_swap m _ _def nearly (p: Shape) (z: Digest p.g) (u: Par d) (x: Magazine p d) :=x.1=z∧ x.2.1=uset_option maxHeartbeats 800000 intheorem demonstrates (o : UnitType p n N) {m : Mixer p n}(v : Ax p n d) (K:ℕ) (i:Nodes) (j:Fin r) (δ : ℝ) (hd:0<δ)(z : Digest p.g) (u:Cell d)(he : z.feasible x.l x.f) (hf : z.sumBit=x.q) (ht : 1≤p.r) (hn : 2*p.r≤n)(hh : δ≤ x.reference Y j)(hs : smoothSilk p δ δ Y m K (onSide o i)) (hK : d≤K^2)(hV : Injective v) (hv : ∀ x,totalRank (v x) ≤ K) :basebeta p K/2 ≤ pr (x.reflected Y i o m v j) (nearly p z (z.diagO,u)) := byclassicalhave ha : x.apt := ⟨z,he,hf⟩let μ:= x.reference Y jlet f := onSide o iobtain ⟨hM,hB⟩:= hs xspecialize hM haspecialize hB z j he hf hhlet U (y:AtomKey (p:=p) (x.trot.t ()) N) := Y x.l x.q y=jhave hm : basebeta p K*μ ≤pr (x.wit n) (fun y=> (scan p x.l x.f y=z∧Y x.l x.q (x.face f y)=j) ∧stains x.trot m v y=u) := bylet h := patrol_beta x.trot U m K z he ht hn fdsimp only at hrw [hf] at hexact h hB d hK v hV hv ulet w := nearly p z (z.diagO,u)have hq (y : Knobs p.g n) :(scan p x.l x.f y=z ∧ Y x.l x.q (x.face f y)=j) ∧ stains x.trot m v y=u →x.showTag Y (onSide o i) y=j∧ w (x.profile i o m v y) := byrintro ⟨⟨h,h1⟩,h2⟩refine ⟨h1,h,?_⟩; rw [smudges,h,h2]have hW := witLaw ha ht hnhave heq := (hm.trans (pr_mono hW.nz hq)).trans_eq (x.show_pr Y i o m v hW j w)let ν:= x.empirical Y f jhave h2 : ν ≤ 2*μ := byhave hz : |μ-ν|≤δ := le_trans(Finset.single_le_sum (fun k _ => abs_nonneg (x.reference Y k-x.empirical Y f k))(Finset.mem_univ j)) hMchange δ≤ μ at hhlinarith [(abs_le.mp hz).1]let Q := pr (x.reflected Y i o m v j) whave h3 : basebeta p K*μ≤ ν*Q := heqhave ht := mul_le_mul_of_nonneg_right h2(show 0≤ Q from pr_nonneg (x.reflectedLaw Y hW i o m v j).nz)apply le_of_mul_le_mul_right _ (hd.trans_le hh)change _*μ ≤ Q*μlinarith only [h3,ht]def fitsink (x : Appearance p) (w : Magazine p d) :=w.1.feasible x.l x.f ∧ w.1.sumBit=x.q ∧ w.1.diagO=w.2.1.1theorem rawink (x : Appearance p) (m : Mixer p n) (i : Nodes) (o : UnitType p n N)(v : Ax p n d) :carried (x.wit n) (x.fitsink ∘ x.profile i o m v) := bylet w:=x.wit nhave hC : carried w (fun y=>dialed p x.l x.f y=x.q) :=normW_carried (subW_carried (spins p n) _)intro y hirefine hC y (fun h=>?_); apply hirefine ⟨?_,h, (role_scan p _ _ _ _).symm⟩intro j hjunfold profile; change scan p x.l x.f y j=0unfold scansimp [hj]theorem refInk (i : Nodes) (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d)(j:Fin r) : carried (x.reflected Y i o m v j) x.fitsink :=reflection_exact x Y i o m v j _ (rawink x m i o v)end Appearancetheorem haze_small (w : Wgt (Fin r)) (δ : ℝ) (hδ : 0≤δ) :pr w (fun x=> w x < δ) ≤ r*δ := byclassicalunfold pr avgrefine (Finset.sum_le_sum (s:=Finset.univ) (g:=fun _=>δ) (fun i _=>?_)).trans_eq (by simp)dsimp onlyby_cases h:w i<δ· rw [ind_one h,mul_one]; exact h.lerw [ind_zero h,mul_zero]; exact hδend StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198import OAI.Combinatorics.HadwigerCounterexample.IndependentWeightCorrelationnamespace OAI/-! # Conditioned Batch Laws -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Module LinearMap Submodule Function Finsetvariable {I J G H : Type} [Fintype I] [Fintype J] [Fintype G] [Fintype H]variable [DecidableEq I] [DecidableEq J] [DecidableEq G]variable {N : ℕ}def street (g : Route (I×J) G) (i : I) : Route J G := fun j => g (i,j)def condLane (g : Route (I×J) G) (i : I) (z : G) (k : Port (street g i) z) :Port g z := ⟨(i,k.val),k.property⟩def laneM {g : Route (I×J) G} (Z : GeoM g) (i : I) :GeoM (street g i) :=fun z => (Z z).submatrix (condLane g i z) (condLane g i z)private theorem cut_inj {I J : Type} [Fintype I] [Fintype J] [DecidableEq I](A : PlusRack I N) (h : Injective A.mulVec) {g : J→I} (hg : Injective g) :Injective (A.submatrix _root_.id g).mulVec := byrw [← mul_embedMat]exact inj_comp_mat _ _ h (embedMat_inj hg)variable {g : Route (I×J) G}omit [Fintype G] inset_option maxHeartbeats 600000 intheorem laneGram (Z : GeoM g) (x : Rack (I × J) N) (h : bothPart Z x) (i : I) :bothPart (laneM Z i) (led i x) := byclassicalobtain ⟨hh,hj⟩ := (both_test ..).mp happly (both_test ..).mprconstructor· refine (part_scores ..).mpr fun q a b => ?_exact (part_scores ..).mp hh q (condLane g i q a) (condLane g i q b)intro jlet f := condLane g i jhave he : Injective f := by intro a b h; exact Subtype.ext (congrArg(fun x : Port g j => x.val.2) h)exact ⟨cut_inj (rackEquiv g N x j).1 (hj j).1 he,cut_inj (rackEquiv g N x j).2 (hj j).2 he⟩def crossroads (g : Route (I×J) G) :=(crowded g)\(cInside g)def outsideZ (Z : GeoM g) : Vec (crossroads g) :=fun x => directions g Z ⟨x.val,Finset.sdiff_subset x.property⟩omit [Fintype G] inprivate theorem road_iff (Z : GeoM g) (x : Rack (I×J) N) :bothPart Z x ↔ (traced x (crossroads g) (outsideZ Z) ∧(∀ i,bothPart (laneM Z i) (led i x))) ∧injPart g x := byclassicalconstructor· intro hhave ht := (both_test ..).mp hrefine ⟨⟨?_,laneGram Z x h⟩,ht.2⟩funext iexact congr_fun ((match_crowd x g Z).mpr ht.1) (⟨i.val,Finset.sdiff_subset i.property⟩ :↑(crowded g))rintro ⟨⟨ht,hH⟩,hf⟩refine (both_test ..).mpr ⟨(part_scores ..).mpr ?_,hf⟩intro i a brcases a with ⟨⟨l,x'⟩,hl⟩rcases b with ⟨⟨t,y⟩,hr⟩subst ilet j := g (l,x')by_cases hh : l=t· subst tlet a : Port (street g l) j := ⟨x',rfl⟩let b : Port (street g l) j := ⟨y,hr⟩exact (part_scores ..).mp ((both_test ..).mp (hH l)).1 j a blet z : I×J := (l,x')let v : I×J := (t,y)have hv : (z,v)∈crossroads g := Finset.mem_sdiff.mpr⟨Finset.mem_filter.mpr ⟨mem_univ _,hr.symm⟩,fun h => hh (mem_filter.mp h).2⟩exact congr_fun ht (⟨(z,v),hv⟩ : ↑(crossroads g))private def condMean (p : H→Prop) (f : Wgt H) :=avg unif (fun x => ind (p x)*f x)private theorem cond_reset [Nonempty H] (p : H→Prop) (f : Wgt H) (h : 0<pr unif p) :condMean p f=pr unif p * avg (unifOn p) f := byrw [←on_unif]; unfold onWrw [avg_norm,subW_tot]have he : condMean p f = avg (subW unif p) f := by simp only [avg,subW,mul_assoc]; rflrw [he]field_simpdef twinkle (_ : Route (I×J) G) (k : ℝ) (N : ℕ) :=num G * (2*bp (k-N))+bp (-(N:ℝ)/2)set_option maxHeartbeats 800000 inprivate theorem lane_means (Z : GeoM g) (f : I → Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)(k : ℝ) (hk : ∀ i,num (Port g i)≤k) :|condMean (bothPart Z) (brightProd f) - bp (-( (crossroads g).card:ℝ)) *∏ i,condMean (bothPart (laneM Z i)) (f i)|≤twinkle g k N := byclassicallet E := crossroads glet F i (x : Rack J N) := ind (bothPart (laneM Z i) x)*f i xhave hF i x : |F i x|≤1 := byunfold F; by_cases h : bothPart (laneM Z i) x <;> simp only [h,ind_true,ind_false,one_mul,zero_mul]; exact hf i x; norm_numhave hE i (h : i∈E) : i.1.1≠i.2.1 := fun he =>(mem_sdiff.mp h).2 (mem_filter.mpr ⟨(mem_sdiff.mp h).1,he⟩)have ht := speed_expand F hF E (outsideZ Z) hEhave hP : avg unif (brightProd F)=∏ i, condMean (bothPart (laneM Z i)) (f i) :=(led_uniform (prodW F)).trans (prodW_avg _ _)let A x := ind (traced x E (outsideZ Z))*brightProd F xhave hA x : |A x|≤1 := byby_cases h : traced x E (outsideZ Z)· unfold A; rw [ind_one h,one_mul]; exact lane_abs F hF _ xunfold A; rw [ind_zero h,zero_mul]; norm_numhave hi x :ind (bothPart Z x) * brightProd f x= ind (injPart g x) * A x := byrw [road_iff]; unfold A Fsimp only [ind_and, ind_all,brightProd,Finset.prod_mul_distrib]ringhave hg :|condMean (bothPart Z) (brightProd f) - avg unif A|≤ num G*(2*bp (k-N)) := byunfold condMeansimp_rw [hi]rw [← avg_sub]refine (abs_avg_le unif_law.nz).trans ((avg_mono unif_law.nz (g:=fun x =>ind (¬injPart g x)) fun i => ?_).trans (injPart_failure g N k hk))by_cases h : injPart g i <;>simp only [h,ind_true,not_true,ind_false,one_mul,sub_self,abs_zero,zero_mul,zero_sub,abs_neg,not_false_eq_true]; exact le_rfl; exact hA _rw [hP] at htunfold twinkleapply le_trans _ (add_le_add hg ht)exact abs_sub_le ..omit [DecidableEq I] intheorem lane_norm (Z : GeoM g) (hN : ∀ i, 2*num (Port g i)-(N:ℝ)≤ -1)(i : I) : 0<pr unif (bothPart (laneM Z i) (N:=N)) := byhave he j : Injective (condLane g i j) := by intro a b h; exact Subtype.ext (congrArg(fun x : Port g j => x.val.2) h)have hx j : num (Port (street g i) j)≤num (Port g j) := byexact_mod_cast Fintype.card_le_of_injective _ (he j)refine lt_of_lt_of_le (inv_pos_of_pos netFact_pos) (net_norm (laneM Z i) N (fun j => ?_)).1linarith only [hx j,hN j]set_option maxHeartbeats 800000 intheorem compare_lanes (Z : GeoM g) (f : I→ Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)(k : ℝ) (hk : ∀ i,num (Port g i)≤k) (hN : ∀ i,2*num (Port g i)-(N:ℝ)≤ -1) :|avg (rackStation Z N) (brightProd f)- ∏ i,avg (rackStation (laneM Z i) N) (f i)|≤2*netFact g*twinkle g k N := byclassicallet A := pr unif (bothPart (N:=N) Z)let B i := pr unif (bothPart (N:=N) (laneM Z i))let u := avg (rackStation Z N) (brightProd f)let v i := avg (rackStation (laneM Z i) N) (f i)let P := bp (- ((crossroads g).card:ℝ))*(∏ i, B i)let V := ∏ i,v ihave hV : |V|≤1 := byunfold Vrw [Finset.abs_prod]have he (i) :SubLaw (rackStation (laneM Z i) N) := unifOn_sub _refine (Finset.prod_le_prod₀ (fun i _ => abs_nonneg _)(fun i _ => (abs_avg_le (he i).nz).trans ((he i).avg_le zero_le_one (hf i)))).trans_eq ?_simphave hh := net_norm Z N hNhave h0 : 0<A := (inv_pos_of_pos netFact_pos).trans_le hh.1have h1 : |A*u-P*V|≤twinkle g k N := byhave hb := lane_norm (N:=N) Z hNhave ht := lane_means Z f hf k hkrw [cond_reset (bothPart (N:=N) Z) _ h0] at htsimp_rw [cond_reset _ _ (hb _)] at ht; rw [Finset.prod_mul_distrib] at htsimpa only [A,B,u,v,P,V,rackStation,mul_assoc] using hthave h2 : |A-P|≤ twinkle g k N := bylet F (i:I) := fun _ : Rack J N => (1:ℝ)have ht := lane_means Z F (by intro i x; simp [F]) k hkhave he (i : I) :condMean (bothPart (laneM Z i)) (F i)=B i := by simp only [F,condMean,mul_one]; rflhave hx :condMean (bothPart (N:=N) Z) (brightProd F)=A := bysimp only [F,brightProd,condMean,Finset.prod_const_one,mul_one,A,pr]simp_rw [he,hx] at ht; exact hthave hg : A * |u-V|≤2*twinkle g k N := byhave hh : |(A-P)*V|≤twinkle g k N := byrw [abs_mul]; exact ((mul_le_mul_of_nonneg_left hV (abs_nonneg _)).trans_eq (mul_one _)).trans h2calc A*|u-V|= |(A*u-P*V)-(A-P)*V| := byrw [show A*u-P*V-(A-P)*V=(A*(u-V)) by ring,abs_mul,abs_of_nonneg h0.le]_ ≤ _ := ((abs_sub ..).trans (add_le_add h1 hh)).trans_eq (two_mul _).symmapply le_of_mul_le_mul_left _ (inv_pos_of_pos (netFact_pos (f:=g)))exact ((mul_le_mul_of_nonneg_right hh.1 (abs_nonneg _)).trans hg).trans_eq (byhave h := netFact_pos (f:=g)field_simp)end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198import OAI.Combinatorics.HadwigerCounterexample.IndependentWeightCorrelationnamespace OAI/-! # Conditioned Batch Laws -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Module LinearMap Submodule Function Finsetvariable {I J G H : Type} [Fintype I] [Fintype J] [Fintype G] [Fintype H]variable [DecidableEq I] [DecidableEq J] [DecidableEq G]variable {N : ℕ}def street (g : Route (I×J) G) (i : I) : Route J G := fun j => g (i,j)def condLane (g : Route (I×J) G) (i : I) (z : G) (k : Port (street g i) z) :Port g z := ⟨(i,k.val),k.property⟩def laneM {g : Route (I×J) G} (Z : GeoM g) (i : I) :GeoM (street g i) :=fun z => (Z z).submatrix (condLane g i z) (condLane g i z)private theorem cut_inj {I J : Type} [Fintype I] [Fintype J] [DecidableEq I](A : PlusRack I N) (h : Injective A.mulVec) {g : J→I} (hg : Injective g) :Injective (A.submatrix _root_.id g).mulVec := byrw [← mul_embedMat]exact inj_comp_mat _ _ h (embedMat_inj hg)variable {g : Route (I×J) G}omit [Fintype G] inset_option maxHeartbeats 600000 intheorem laneGram (Z : GeoM g) (x : Rack (I × J) N) (h : bothPart Z x) (i : I) :bothPart (laneM Z i) (led i x) := byclassicalobtain ⟨hh,hj⟩ := (both_test ..).mp happly (both_test ..).mprconstructor· refine (part_scores ..).mpr fun q a b => ?_exact (part_scores ..).mp hh q (condLane g i q a) (condLane g i q b)intro jlet f := condLane g i jhave he : Injective f := by intro a b h; exact Subtype.ext (congrArg(fun x : Port g j => x.val.2) h)exact ⟨cut_inj (rackEquiv g N x j).1 (hj j).1 he,cut_inj (rackEquiv g N x j).2 (hj j).2 he⟩def crossroads (g : Route (I×J) G) :=(crowded g)\(cInside g)def outsideZ (Z : GeoM g) : Vec (crossroads g) :=fun x => directions g Z ⟨x.val,Finset.sdiff_subset x.property⟩omit [Fintype G] inprivate theorem road_iff (Z : GeoM g) (x : Rack (I×J) N) :bothPart Z x ↔ (traced x (crossroads g) (outsideZ Z) ∧(∀ i,bothPart (laneM Z i) (led i x))) ∧injPart g x := byclassicalconstructor· intro hhave ht := (both_test ..).mp hrefine ⟨⟨?_,laneGram Z x h⟩,ht.2⟩funext iexact congr_fun ((match_crowd x g Z).mpr ht.1) (⟨i.val,Finset.sdiff_subset i.property⟩ :↑(crowded g))rintro ⟨⟨ht,hH⟩,hf⟩refine (both_test ..).mpr ⟨(part_scores ..).mpr ?_,hf⟩intro i a brcases a with ⟨⟨l,x'⟩,hl⟩rcases b with ⟨⟨t,y⟩,hr⟩subst ilet j := g (l,x')by_cases hh : l=t· subst tlet a : Port (street g l) j := ⟨x',rfl⟩let b : Port (street g l) j := ⟨y,hr⟩exact (part_scores ..).mp ((both_test ..).mp (hH l)).1 j a blet z : I×J := (l,x')let v : I×J := (t,y)have hv : (z,v)∈crossroads g := Finset.mem_sdiff.mpr⟨Finset.mem_filter.mpr ⟨mem_univ _,hr.symm⟩,fun h => hh (mem_filter.mp h).2⟩exact congr_fun ht (⟨(z,v),hv⟩ : ↑(crossroads g))private def condMean (p : H→Prop) (f : Wgt H) :=avg unif (fun x => ind (p x)*f x)private theorem cond_reset [Nonempty H] (p : H→Prop) (f : Wgt H) (h : 0<pr unif p) :condMean p f=pr unif p * avg (unifOn p) f := byrw [←on_unif]; unfold onWrw [avg_norm,subW_tot]have he : condMean p f = avg (subW unif p) f := by simp only [avg,subW,mul_assoc]; rflrw [he]field_simpdef twinkle (_ : Route (I×J) G) (k : ℝ) (N : ℕ) :=num G * (2*bp (k-N))+bp (-(N:ℝ)/2)set_option maxHeartbeats 800000 inprivate theorem lane_means (Z : GeoM g) (f : I → Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)(k : ℝ) (hk : ∀ i,num (Port g i)≤k) :|condMean (bothPart Z) (brightProd f) - bp (-( (crossroads g).card:ℝ)) *∏ i,condMean (bothPart (laneM Z i)) (f i)|≤twinkle g k N := byclassicallet E := crossroads glet F i (x : Rack J N) := ind (bothPart (laneM Z i) x)*f i xhave hF i x : |F i x|≤1 := byunfold F; by_cases h : bothPart (laneM Z i) x <;> simp only [h,ind_true,ind_false,one_mul,zero_mul]; exact hf i x; norm_numhave hE i (h : i∈E) : i.1.1≠i.2.1 := fun he =>(mem_sdiff.mp h).2 (mem_filter.mpr ⟨(mem_sdiff.mp h).1,he⟩)have ht := speed_expand F hF E (outsideZ Z) hEhave hP : avg unif (brightProd F)=∏ i, condMean (bothPart (laneM Z i)) (f i) :=(led_uniform (prodW F)).trans (prodW_avg _ _)let A x := ind (traced x E (outsideZ Z))*brightProd F xhave hA x : |A x|≤1 := byby_cases h : traced x E (outsideZ Z)· unfold A; rw [ind_one h,one_mul]; exact lane_abs F hF _ xunfold A; rw [ind_zero h,zero_mul]; norm_numhave hi x :ind (bothPart Z x) * brightProd f x= ind (injPart g x) * A x := byrw [road_iff]; unfold A Fsimp only [ind_and, ind_all,brightProd,Finset.prod_mul_distrib]ringhave hg :|condMean (bothPart Z) (brightProd f) - avg unif A|≤ num G*(2*bp (k-N)) := byunfold condMeansimp_rw [hi]rw [← avg_sub]refine (abs_avg_le unif_law.nz).trans ((avg_mono unif_law.nz (g:=fun x =>ind (¬injPart g x)) fun i => ?_).trans (injPart_failure g N k hk))by_cases h : injPart g i <;>simp only [h,ind_true,not_true,ind_false,one_mul,sub_self,abs_zero,zero_mul,zero_sub,abs_neg,not_false_eq_true]; exact le_rfl; exact hA _rw [hP] at htunfold twinkleapply le_trans _ (add_le_add hg ht)exact abs_sub_le ..omit [DecidableEq I] intheorem lane_norm (Z : GeoM g) (hN : ∀ i, 2*num (Port g i)-(N:ℝ)≤ -1)(i : I) : 0<pr unif (bothPart (laneM Z i) (N:=N)) := byhave he j : Injective (condLane g i j) := by intro a b h; exact Subtype.ext (congrArg(fun x : Port g j => x.val.2) h)have hx j : num (Port (street g i) j)≤num (Port g j) := byexact_mod_cast Fintype.card_le_of_injective _ (he j)refine lt_of_lt_of_le (inv_pos_of_pos netFact_pos) (net_norm (laneM Z i) N (fun j => ?_)).1linarith only [hx j,hN j]set_option maxHeartbeats 800000 intheorem compare_lanes (Z : GeoM g) (f : I→ Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)(k : ℝ) (hk : ∀ i,num (Port g i)≤k) (hN : ∀ i,2*num (Port g i)-(N:ℝ)≤ -1) :|avg (rackStation Z N) (brightProd f)- ∏ i,avg (rackStation (laneM Z i) N) (f i)|≤2*netFact g*twinkle g k N := byclassicallet A := pr unif (bothPart (N:=N) Z)let B i := pr unif (bothPart (N:=N) (laneM Z i))let u := avg (rackStation Z N) (brightProd f)let v i := avg (rackStation (laneM Z i) N) (f i)let P := bp (- ((crossroads g).card:ℝ))*(∏ i, B i)let V := ∏ i,v ihave hV : |V|≤1 := byunfold Vrw [Finset.abs_prod]have he (i) :SubLaw (rackStation (laneM Z i) N) := unifOn_sub _refine (Finset.prod_le_prod₀ (fun i _ => abs_nonneg _)(fun i _ => (abs_avg_le (he i).nz).trans ((he i).avg_le zero_le_one (hf i)))).trans_eq ?_simphave hh := net_norm Z N hNhave h0 : 0<A := (inv_pos_of_pos netFact_pos).trans_le hh.1have h1 : |A*u-P*V|≤twinkle g k N := byhave hb := lane_norm (N:=N) Z hNhave ht := lane_means Z f hf k hkrw [cond_reset (bothPart (N:=N) Z) _ h0] at htsimp_rw [cond_reset _ _ (hb _)] at ht; rw [Finset.prod_mul_distrib] at htsimpa only [A,B,u,v,P,V,rackStation,mul_assoc] using hthave h2 : |A-P|≤ twinkle g k N := bylet F (i:I) := fun _ : Rack J N => (1:ℝ)have ht := lane_means Z F (by intro i x; simp [F]) k hkhave he (i : I) :condMean (bothPart (laneM Z i)) (F i)=B i := by simp only [F,condMean,mul_one]; rflhave hx :condMean (bothPart (N:=N) Z) (brightProd F)=A := bysimp only [F,brightProd,condMean,Finset.prod_const_one,mul_one,A,pr]simp_rw [he,hx] at ht; exact hthave hg : A * |u-V|≤2*twinkle g k N := byhave hh : |(A-P)*V|≤twinkle g k N := byrw [abs_mul]; exact ((mul_le_mul_of_nonneg_left hV (abs_nonneg _)).trans_eq (mul_one _)).trans h2calc A*|u-V|= |(A*u-P*V)-(A-P)*V| := byrw [show A*u-P*V-(A-P)*V=(A*(u-V)) by ring,abs_mul,abs_of_nonneg h0.le]_ ≤ _ := ((abs_sub ..).trans (add_le_add h1 hh)).trans_eq (two_mul _).symmapply le_of_mul_le_mul_left _ (inv_pos_of_pos (netFact_pos (f:=g)))exact ((mul_le_mul_of_nonneg_right hh.1 (abs_nonneg _)).trans hg).trans_eq (byhave h := netFact_pos (f:=g)field_simp)end HadwigerCounterexampleendend OAI
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import OAI.Combinatorics.HadwigerCounterexample.BilinearBlockCorrelationnamespace OAI/-! # Conditioned Correlations -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Real Filter Matrix LinearMap Functionopen scoped BigOperatorsvariable {p : Shape} {I A : Type} [Fintype I] [Fintype A]variable {n : ℕ}set_option maxHeartbeats 600000 intheorem spark_condition (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i|≤1) (hu : ∀ i,|u i|≤1)(μ δ : Wgt (Knobs p.g n)) (hμ : IsLaw μ) (hδ : IsLaw δ)(C : ℝ) (hC : 0<C)(hc : ∀ i,μ i ≤ C*unif i) (hc' : ∀ i,δ i ≤ C*unif i)(hM : n ≤ 5*blockRank B s t M) :let Q i z := evmat M (spring p l s f i) (spring p j t g z)|avg (pairW μ δ) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤C^2*bp (-(n:ℝ)/10) := byclassicalintro Qlet V := Knobs p.g nlet fit (f p : Wgt V) := fun i => p i*f i/(C*unif i)have h0 (i : V) : 0<C*unif i := by rw [unif_apply]; positivityhave hh (t p : Wgt V) (ht : ∀ i, |t i|≤1) (hp : IsLaw p) (h : ∀ i,p i≤C*unif i) i :|fit t p i|≤1 := byunfold fit; rw [abs_div,abs_of_pos (h0 i),abs_mul,abs_of_nonneg (hp.nz _)]refine (div_le_one (h0 i)).mpr ?_exact ((mul_le_mul_of_nonneg_left (ht _) (hp.nz _)).trans_eq (mul_one _)).trans (h _)let F (x : V×V) := wsign (Q x.1 x.2)*(w x.1*u x.2)let Z (x : V×V) := wsign (Q x.1 x.2)*(fit w μ x.1*fit u δ x.2)have he :avg (pairW μ δ) F=C^2 * avg (pairW unif unif) Z := byunfold avg; rw [Finset.mul_sum]refine sum_congr rfl fun i _ => ?_unfold Z F fit pairWhave h1 := h0 i.1; have h2 := h0 i.2have h3 : unif i.1 ≠ 0 := by rw [unif_apply]; positivityhave h4 : unif i.2 ≠ 0 := by rw [unif_apply]; positivityfield_simpchange |avg (pairW μ δ) F|≤_rw [he,abs_mul,abs_of_nonneg (sq_nonneg _)]have hi : (n:ℝ)≤5*blockRank B s t M := by exact_mod_cast hMexact mul_le_mul_of_nonneg_left ((spark_uncap p M s t l j f g B hB hB'_ _ (hh w μ hw hμ hc) (hh u δ hu hδ hc')).trans (bp_le (by linarith only [hi]))) (sq_nonneg _)def litFire (p : Shape) {n N : ℕ} (x : UnitType p n N) :=∀ (s t : Label p.b) (c : Vec (Notches p)), c≠0 →n≤5*blockRank Block.Z s t (issue p c x)theorem litFire_calendar (p : Shape) (C : ℝ) (M : ℕ) (hM : 4≤M) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n), 2*num (Full p n)<N →∀ w : Wgt (UnitType p n N),(∀ i,w i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →pr w (fun i => ¬litFire p i) ≤ bp (-(n:ℝ)*n/8) := byclassicallet I := Label p.b × Label p.b × Vec (Notches p)have ht := bp_poly_dom_nat (a:=1) zero_lt_one (num I) 0filter_upwards [issue_live p,ht,(tendsto_natCast_atTop_atTop (R:=ℝ)).eventually(eventually_ge_atTop (8*(C*M+1)))]with n hn hp hab N m hN w hchange 8*(C*M+1)≤ (n:ℝ) at habrefine (pr_cap h _).trans ?_let Q (i : I) (x : UnitType p n N) :=i.2.2≠0 ∧ 5*blockRank Block.Z i.1 i.2.1 (issue p i.2.2 x)<nlet v := pairW (raw m N) (raw m N)have hv : IsLaw v := pairW_law (raw_law m hN) (raw_law m hN)have he (i : I) : pr v (Q i)≤bp (-(n:ℝ)*n/4) := byby_cases h : i.2.2=0· simp only [Q,h,ne_eq,not_true,false_and,pr_false]; exact (bp_pos _).leexact (pr_mono hv.nz fun x h => h.2).trans(hn N (by unfold N; nlinarith only [Nat.mul_le_mul_right n hM]) hN m _ _ i.2.2 h)have hh (x : UnitType p n N) (h : ¬litFire p x) : ∃ i,Q i x := byunfold litFire at hpush Not at hobtain ⟨s,t,c,hc,h⟩ := h; exact ⟨(s,t,c),hc,h⟩have hi : pr v (fun x=> ¬litFire p x) ≤ num I*bp (-(n:ℝ)*n/4) :=(le_trans (pr_mono hv.nz hh) (pr_exists_le hv.nz Q)).trans ((sum_le_sumfun i _ => he i).trans_eq (by simp [num]))refine (mul_le_mul_of_nonneg_left hi (bp_pos _).le).trans ?_simp only [pow_zero,mul_one,one_mul] at hpapply (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hp.le(bp_pos (-(n:ℝ)*n/4)).le) (bp_pos (C*N)).le).transrw [← bp_add,← bp_add]apply bp_leunfold N; push_castnlinarith only [mul_le_mul_of_nonneg_right hab (Nat.cast_nonneg n : 0≤(n:ℝ))]end HadwigerCounterexampleendend OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import OAI.Combinatorics.HadwigerCounterexample.BilinearBlockCorrelationnamespace OAI/-! # Conditioned Correlations -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Real Filter Matrix LinearMap Functionopen scoped BigOperatorsvariable {p : Shape} {I A : Type} [Fintype I] [Fintype A]variable {n : ℕ}set_option maxHeartbeats 600000 intheorem spark_condition (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i|≤1) (hu : ∀ i,|u i|≤1)(μ δ : Wgt (Knobs p.g n)) (hμ : IsLaw μ) (hδ : IsLaw δ)(C : ℝ) (hC : 0<C)(hc : ∀ i,μ i ≤ C*unif i) (hc' : ∀ i,δ i ≤ C*unif i)(hM : n ≤ 5*blockRank B s t M) :let Q i z := evmat M (spring p l s f i) (spring p j t g z)|avg (pairW μ δ) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤C^2*bp (-(n:ℝ)/10) := byclassicalintro Qlet V := Knobs p.g nlet fit (f p : Wgt V) := fun i => p i*f i/(C*unif i)have h0 (i : V) : 0<C*unif i := by rw [unif_apply]; positivityhave hh (t p : Wgt V) (ht : ∀ i, |t i|≤1) (hp : IsLaw p) (h : ∀ i,p i≤C*unif i) i :|fit t p i|≤1 := byunfold fit; rw [abs_div,abs_of_pos (h0 i),abs_mul,abs_of_nonneg (hp.nz _)]refine (div_le_one (h0 i)).mpr ?_exact ((mul_le_mul_of_nonneg_left (ht _) (hp.nz _)).trans_eq (mul_one _)).trans (h _)let F (x : V×V) := wsign (Q x.1 x.2)*(w x.1*u x.2)let Z (x : V×V) := wsign (Q x.1 x.2)*(fit w μ x.1*fit u δ x.2)have he :avg (pairW μ δ) F=C^2 * avg (pairW unif unif) Z := byunfold avg; rw [Finset.mul_sum]refine sum_congr rfl fun i _ => ?_unfold Z F fit pairWhave h1 := h0 i.1; have h2 := h0 i.2have h3 : unif i.1 ≠ 0 := by rw [unif_apply]; positivityhave h4 : unif i.2 ≠ 0 := by rw [unif_apply]; positivityfield_simpchange |avg (pairW μ δ) F|≤_rw [he,abs_mul,abs_of_nonneg (sq_nonneg _)]have hi : (n:ℝ)≤5*blockRank B s t M := by exact_mod_cast hMexact mul_le_mul_of_nonneg_left ((spark_uncap p M s t l j f g B hB hB'_ _ (hh w μ hw hμ hc) (hh u δ hu hδ hc')).trans (bp_le (by linarith only [hi]))) (sq_nonneg _)def litFire (p : Shape) {n N : ℕ} (x : UnitType p n N) :=∀ (s t : Label p.b) (c : Vec (Notches p)), c≠0 →n≤5*blockRank Block.Z s t (issue p c x)theorem litFire_calendar (p : Shape) (C : ℝ) (M : ℕ) (hM : 4≤M) :∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n), 2*num (Full p n)<N →∀ w : Wgt (UnitType p n N),(∀ i,w i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →pr w (fun i => ¬litFire p i) ≤ bp (-(n:ℝ)*n/8) := byclassicallet I := Label p.b × Label p.b × Vec (Notches p)have ht := bp_poly_dom_nat (a:=1) zero_lt_one (num I) 0filter_upwards [issue_live p,ht,(tendsto_natCast_atTop_atTop (R:=ℝ)).eventually(eventually_ge_atTop (8*(C*M+1)))]with n hn hp hab N m hN w hchange 8*(C*M+1)≤ (n:ℝ) at habrefine (pr_cap h _).trans ?_let Q (i : I) (x : UnitType p n N) :=i.2.2≠0 ∧ 5*blockRank Block.Z i.1 i.2.1 (issue p i.2.2 x)<nlet v := pairW (raw m N) (raw m N)have hv : IsLaw v := pairW_law (raw_law m hN) (raw_law m hN)have he (i : I) : pr v (Q i)≤bp (-(n:ℝ)*n/4) := byby_cases h : i.2.2=0· simp only [Q,h,ne_eq,not_true,false_and,pr_false]; exact (bp_pos _).leexact (pr_mono hv.nz fun x h => h.2).trans(hn N (by unfold N; nlinarith only [Nat.mul_le_mul_right n hM]) hN m _ _ i.2.2 h)have hh (x : UnitType p n N) (h : ¬litFire p x) : ∃ i,Q i x := byunfold litFire at hpush Not at hobtain ⟨s,t,c,hc,h⟩ := h; exact ⟨(s,t,c),hc,h⟩have hi : pr v (fun x=> ¬litFire p x) ≤ num I*bp (-(n:ℝ)*n/4) :=(le_trans (pr_mono hv.nz hh) (pr_exists_le hv.nz Q)).trans ((sum_le_sumfun i _ => he i).trans_eq (by simp [num]))refine (mul_le_mul_of_nonneg_left hi (bp_pos _).le).trans ?_simp only [pow_zero,mul_one,one_mul] at hpapply (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hp.le(bp_pos (-(n:ℝ)*n/4)).le) (bp_pos (C*N)).le).transrw [← bp_add,← bp_add]apply bp_leunfold N; push_castnlinarith only [mul_le_mul_of_nonneg_right hab (Nat.cast_nonneg n : 0≤(n:ℝ))]end HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100import OAI.Combinatorics.HadwigerCounterexample.RawFrameLawsnamespace OAI/-! # Construction Scales -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Filtertheorem card_full (p : Shape) (n : ℕ) :Fintype.card (Full p n) = psize p * (1+(p.g*p.g+3)*n) + p.h := bycalc_ = Fintype.card (Row p n) + Fintype.card (Fin p.h) :=Fintype.card_sum .._ = _ := by rw [card_row, Fintype.card_fin]theorem full_linear (p : Shape) : ∃ B : ℝ, 0 ≤ B ∧ ∀ n : ℕ, 0 < n →num (Full p n) ≤ B*n := bylet b := psize p*(1+(p.g*p.g+3)) + p.hrefine ⟨↑b,Nat.cast_nonneg b, fun n hn => ?_⟩have h1 : 1 ≤ n := hnhave h2 : Fintype.card (Full p n) ≤ b*n := byrw [card_full]unfold bcalc _ ≤ psize p * (n+(p.g*p.g+3)*n) + p.h*n :=add_le_add (Nat.mul_le_mul_left _ (by omega)) (by nlinarith)_ = _ := by ringexact_mod_cast h2theorem unit_size (p : Shape) (n N : ℕ) :num (UnitType p n N) = bp (num (Comp p.g) * 4 * N * num (Full p n)) := byhave hc :(Fintype.card (UnitType p n N)) =((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) *((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) := bysimp [UnitType, Orient, Oframe, RawFrame, pow_two]unfold numrw [hc]push_castrw [card_space,dim_mat,Fintype.card_fin]push_castsimp only [← bp_mul_nat,← bp_add]push_cast; ring_nf/-- Fixed linear and constant expenses become any fixed small fraction of N. -/theorem have_budget {δ : ℝ} (hd : 0 < δ) (a b : ℝ) (hb : 0 ≤ b) :∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n → a*n+b ≤ δ*(M*n : ℕ) := byhave h : Tendsto (fun M : ℕ => δ*M) atTop atTop :=(tendsto_const_mul_atTop_of_pos hd).mpr tendsto_natCast_atTop_atTopfilter_upwards [h.eventually (eventually_ge_atTop (a+b))] with M hM n hnchange a+b ≤ δ*M at hMpush_casthave hn' : 1 ≤ (n:ℝ) := by exact_mod_cast hnnlinarith only [mul_le_mul_of_nonneg_right hM (Nat.cast_nonneg n : (0:ℝ)≤n),mul_le_mul_of_nonneg_right hn' hb]theorem columns_budget (p : Shape) {δ : ℝ} (hd : 0 < δ) (a b : ℝ)(ha : 0 ≤ a) (hb : 0 ≤ b) :∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n →a*num (Full p n) + b ≤ δ*(M*n:ℕ) := byobtain ⟨B,hB,h⟩ := full_linear pfilter_upwards [have_budget hd (a*B) b hb] with M hM n hnrefine le_trans ?_ (hM n hn)rw [mul_assoc]exact add_le_add_left (mul_le_mul_of_nonneg_left (h _ hn) ha) _theorem raw_ready (p : Shape) {δ : ℝ} (hd : 0 < δ) :∀ᶠ M : ℕ in atTop, ∀ᶠ n : ℕ in atTop, let N := M*n;num (UnitType p n N) ≤ bp ((4*num (Comp p.g))*N^ (2 : ℕ)) ∧∀ m : Mixer p n, IsLaw (raw m N) ∧ ∀ a : Pin p n N,pr (pairW (raw m N) (raw m N)) a.agree ≤ bp (-(1-δ)*(planRank a.sp)*N) := byhave hd' : 0 < δ/2 := by positivityfilter_upwards [columns_budget p hd' 2 (4*num (Comp p.g)) (by norm_num)(by unfold num; positivity),columns_budget p (δ:=1) (by norm_num) 2 1 (by norm_num) (by norm_num)] with M ha hbfilter_upwards [eventually_ge_atTop 1] with n hnspecialize ha n hnspecialize hb n hnlet N := M*nhave hi : 0 ≤ num (Comp p.g) := Nat.cast_nonneg _have hj : 0 ≤ num (Full p n) := Nat.cast_nonneg _rw [one_mul] at hbhave hh : 2*num (Full p n)<N := by unfold N; linarith only [hb]dsimp onlyconstructor· rw [unit_size]apply bp_lehave hf : num (Full p n) ≤ N := by linarithexact le_trans (mul_le_mul_of_nonneg_left hf (by positivity))(le_of_eq (by unfold N; push_cast; ring))· intro mrefine ⟨raw_law m hh, fun a => reference_cap _ a hd ?_ ?_ ?_⟩ <;> linarithend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100import OAI.Combinatorics.HadwigerCounterexample.RawFrameLawsnamespace OAI/-! # Construction Scales -/noncomputable sectionnamespace HadwigerCounterexampleopen scoped BigOperatorsopen Matrix Filtertheorem card_full (p : Shape) (n : ℕ) :Fintype.card (Full p n) = psize p * (1+(p.g*p.g+3)*n) + p.h := bycalc_ = Fintype.card (Row p n) + Fintype.card (Fin p.h) :=Fintype.card_sum .._ = _ := by rw [card_row, Fintype.card_fin]theorem full_linear (p : Shape) : ∃ B : ℝ, 0 ≤ B ∧ ∀ n : ℕ, 0 < n →num (Full p n) ≤ B*n := bylet b := psize p*(1+(p.g*p.g+3)) + p.hrefine ⟨↑b,Nat.cast_nonneg b, fun n hn => ?_⟩have h1 : 1 ≤ n := hnhave h2 : Fintype.card (Full p n) ≤ b*n := byrw [card_full]unfold bcalc _ ≤ psize p * (n+(p.g*p.g+3)*n) + p.h*n :=add_le_add (Nat.mul_le_mul_left _ (by omega)) (by nlinarith)_ = _ := by ringexact_mod_cast h2theorem unit_size (p : Shape) (n N : ℕ) :num (UnitType p n N) = bp (num (Comp p.g) * 4 * N * num (Full p n)) := byhave hc :(Fintype.card (UnitType p n N)) =((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) *((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) := bysimp [UnitType, Orient, Oframe, RawFrame, pow_two]unfold numrw [hc]push_castrw [card_space,dim_mat,Fintype.card_fin]push_castsimp only [← bp_mul_nat,← bp_add]push_cast; ring_nf/-- Fixed linear and constant expenses become any fixed small fraction of N. -/theorem have_budget {δ : ℝ} (hd : 0 < δ) (a b : ℝ) (hb : 0 ≤ b) :∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n → a*n+b ≤ δ*(M*n : ℕ) := byhave h : Tendsto (fun M : ℕ => δ*M) atTop atTop :=(tendsto_const_mul_atTop_of_pos hd).mpr tendsto_natCast_atTop_atTopfilter_upwards [h.eventually (eventually_ge_atTop (a+b))] with M hM n hnchange a+b ≤ δ*M at hMpush_casthave hn' : 1 ≤ (n:ℝ) := by exact_mod_cast hnnlinarith only [mul_le_mul_of_nonneg_right hM (Nat.cast_nonneg n : (0:ℝ)≤n),mul_le_mul_of_nonneg_right hn' hb]theorem columns_budget (p : Shape) {δ : ℝ} (hd : 0 < δ) (a b : ℝ)(ha : 0 ≤ a) (hb : 0 ≤ b) :∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n →a*num (Full p n) + b ≤ δ*(M*n:ℕ) := byobtain ⟨B,hB,h⟩ := full_linear pfilter_upwards [have_budget hd (a*B) b hb] with M hM n hnrefine le_trans ?_ (hM n hn)rw [mul_assoc]exact add_le_add_left (mul_le_mul_of_nonneg_left (h _ hn) ha) _theorem raw_ready (p : Shape) {δ : ℝ} (hd : 0 < δ) :∀ᶠ M : ℕ in atTop, ∀ᶠ n : ℕ in atTop, let N := M*n;num (UnitType p n N) ≤ bp ((4*num (Comp p.g))*N^ (2 : ℕ)) ∧∀ m : Mixer p n, IsLaw (raw m N) ∧ ∀ a : Pin p n N,pr (pairW (raw m N) (raw m N)) a.agree ≤ bp (-(1-δ)*(planRank a.sp)*N) := byhave hd' : 0 < δ/2 := by positivityfilter_upwards [columns_budget p hd' 2 (4*num (Comp p.g)) (by norm_num)(by unfold num; positivity),columns_budget p (δ:=1) (by norm_num) 2 1 (by norm_num) (by norm_num)] with M ha hbfilter_upwards [eventually_ge_atTop 1] with n hnspecialize ha n hnspecialize hb n hnlet N := M*nhave hi : 0 ≤ num (Comp p.g) := Nat.cast_nonneg _have hj : 0 ≤ num (Full p n) := Nat.cast_nonneg _rw [one_mul] at hbhave hh : 2*num (Full p n)<N := by unfold N; linarith only [hb]dsimp onlyconstructor· rw [unit_size]apply bp_lehave hf : num (Full p n) ≤ N := by linarithexact le_trans (mul_le_mul_of_nonneg_left hf (by positivity))(le_of_eq (by unfold N; push_cast; ring))· intro mrefine ⟨raw_law m hh, fun a => reference_cap _ a hd ?_ ?_ ?_⟩ <;> linarithend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import OAI.Combinatorics.HadwigerCounterexample.BooleanLabelsimport OAI.Combinatorics.HadwigerCounterexample.QuadraticTestersimport OAI.Combinatorics.HadwigerCounterexample.CoordinateEmbeddingsnamespace OAI/-! # Coordinate Blocks -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrixopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}def blockA (p : Shape) (n : ℕ) (B : Block p.g) : Mat (AIdx p.g n) (Fin n) :=embedMat (fun i => some (B,i))def blockRay (p : Shape) (n : ℕ) (s : Label p.b) (B : Block p.g) : Mat (Row p n) (Fin n) :=labMat p n s * blockA p n Btheorem lab_inj (s : Label p.b) : Function.Injective (labMat p n s).mulVec := byintro x y hefunext irw [labMat_act,labMat_act] at hehave h := congr_fun he (emptySel,i)simpa [putLab,selV,emptySel] using htheorem joined_lab_inj {s t : Label p.b} (hj : 1≤p.j) (hs : s≠t) :Function.Injective (fromCols (labMat p n s) (labMat p n t)).mulVec := byapply inj_fromCols (lab_inj _) (lab_inj _)classicalrw [disjoint_iff_inf_le]rintro x ⟨⟨v,rfl⟩,w,h⟩simp only [mulVecLin_apply,labMat_act] at hlet Z : Label p.b → Vec (AIdx p.g n) := fun i => if i=s then v else -whave he : ∑ i ∈ ({s,t} : Finset _), putLab p n i (Z i)=0 := bysimp [Z,hs,hs.symm,map_neg,h]have hi : ({s,t}:Finset _).card ≤ p.j+1 := byhave hh : ({s,t}:Finset _).card=2 := by simp [hs]omegahave hg := ray_indep _ _ hi he s (by simp)have hv : v=0 := by simpa [Z] using hgrw [hv,map_zero]; exact Submodule.zero_mem _theorem block_inj (B : Block p.g) : Function.Injective (blockA p n B).mulVec :=embedMat_inj (show Function.Injective (fun i => some (B,i)) fromfun _ _ h => congrArg Prod.snd (Option.some.inj h))theorem blockRay_inj (p : Shape) (n) (s) (B) :Function.Injective (blockRay p n s B).mulVec :=inj_comp_mat _ _ (lab_inj _) (block_inj B)theorem joined_block_inj {s t : Label p.b} (hj : 1 ≤ p.j) (hs : s ≠ t) (B : Block p.g) :Function.Injective (fromCols (blockRay p n s B) (blockRay p n t B)).mulVec := byclassicalapply inj_fromCols (blockRay_inj ..) (blockRay_inj ..)rw [disjoint_iff_inf_le]rintro x ⟨⟨v,rfl⟩,w,h⟩simp only [Matrix.mulVecLin_apply,blockRay,← Matrix.mulVec_mulVec] at hlet a := Sum.elim (blockA p n B *ᵥ v) (0 : Vec (AIdx p.g n))let b := Sum.elim (0 : Vec (AIdx p.g n)) (blockA p n B *ᵥ w)have heq : a=b := joined_lab_inj hj hs (bydsimp only [a,b]rw [fromCols_mulVec_sumElim,fromCols_mulVec_sumElim,Matrix.mulVec_zero,Matrix.mulVec_zero,zero_add,add_zero,h])have hg : blockA p n B *ᵥ v = 0 := funext (fun x => congr_fun heq (.inl x))change blockRay p n s B *ᵥ v ∈ _rw [blockRay,← Matrix.mulVec_mulVec,hg,Matrix.mulVec_zero]exact Submodule.zero_mem _theorem blockRay_eval (p : Shape) (s : Label p.b) (B) (i) (j : Fin n) :blockRay p n s B i j = if i.2=some (B,j) then monoBit s i.1.val else 0 := byrw [blockRay,blockA,mul_embedMat]; rfltheorem project_pick {d B : Block p.g} (hd : d ≠ B) (a) (s) (i) :(blockRay p n s B)ᵀ *ᵥ pick p n a d i = 0 := byclassicalunfold picksplit· rename_i hirw [Matrix.mulVec_single_one]ext jchange blockRay p n s B (a,some (d,⟨i,hi⟩)) j=0simp [blockRay_eval,hd]rw [Matrix.mulVec_zero]theorem project_same (B : Block p.g) (a s) (i : Fin n) :(blockRay p n s B)ᵀ *ᵥ pick p n a B i.val = Pi.single i (monoBit s a.val) := byclassicalrw [pick,dite_eq_left i.isLt,Matrix.mulVec_single_one]ext jchange blockRay p n s B _ j=_rw [blockRay_eval]simp [Pi.single_apply, eq_comm]def pullM {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I) (Q : Mat U J) :Mat V U →ₗ[F] Mat I J := liftM Pᵀ Qᵀtheorem pullM_def {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I)(Q : Mat U J) (M : Mat V U) : pullM P Q M=Pᵀ*M*Q := rfltheorem pull_test {d B : Block p.g} (h : d≠B) (s s') :pullM (blockRay p n s B) (blockRay p n s' B) (testM p n d) = 0 := byunfold testM pullMsimp only [map_sum,liftM_outer,project_pick h]simptheorem pull_self_Z (M) (s s' : Label p.b) :pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z) (selfM p n M)=0 := bylet L := pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z)have hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)(B:=Block.Z) (by simp [Block.O,Block.Z]) s s'have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.Z) (by simp [Block.S,Block.Z]) s s'have h (a : SelIdx p.b p.j) (s : Label p.b) (i) :=project_pick (n:=n) (p:=p) (d:=Block.sharp) (B:=Block.Z) (by simp [Block.sharp,Block.Z]) a s irw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]unfold sharpM sharpPick pullMby_cases he : 1 ≤ p.j· simp only [map_sum,map_smul,map_add, dite_eq_left he,liftM_outer,h]simp· simp only [dite_eq_right he]; simptheorem pull_self_sharp (M) (s s' : Label p.b) (hj : 1≤p.j) :pullM (blockRay p n s Block.sharp) (blockRay p n s' Block.sharp) (selfM p n M) =∑ i, (s i+s' i) • M i := byclassicalhave hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)(B:=Block.sharp) (by simp [Block.O,Block.sharp]) s s'have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.sharp) (by simp [Block.S,Block.sharp]) s s'rw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]unfold sharpM sharpPick pullMsimp only [map_sum,map_add,map_smul, dite_eq_left hj,liftM_outer,project_same]refine Finset.sum_congr rfl fun i _ => ?_ext a bsimp only [Matrix.sum_apply,Matrix.add_apply,Matrix.smul_apply,smul_eq_mul,vecMulVec_apply,monoBit,emptySel,Finset.prod_empty,Finset.prod_singleton,Pi.single_apply]rw [Finset.sum_eq_single a]· rw [Finset.sum_eq_single b]· simp; ring· intro j _ h; simp [h.symm]· simp· intro j _ h; simp [h.symm]simpend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import OAI.Combinatorics.HadwigerCounterexample.BooleanLabelsimport OAI.Combinatorics.HadwigerCounterexample.QuadraticTestersimport OAI.Combinatorics.HadwigerCounterexample.CoordinateEmbeddingsnamespace OAI/-! # Coordinate Blocks -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrixopen scoped BigOperatorsvariable {p : Shape} {n : ℕ}def blockA (p : Shape) (n : ℕ) (B : Block p.g) : Mat (AIdx p.g n) (Fin n) :=embedMat (fun i => some (B,i))def blockRay (p : Shape) (n : ℕ) (s : Label p.b) (B : Block p.g) : Mat (Row p n) (Fin n) :=labMat p n s * blockA p n Btheorem lab_inj (s : Label p.b) : Function.Injective (labMat p n s).mulVec := byintro x y hefunext irw [labMat_act,labMat_act] at hehave h := congr_fun he (emptySel,i)simpa [putLab,selV,emptySel] using htheorem joined_lab_inj {s t : Label p.b} (hj : 1≤p.j) (hs : s≠t) :Function.Injective (fromCols (labMat p n s) (labMat p n t)).mulVec := byapply inj_fromCols (lab_inj _) (lab_inj _)classicalrw [disjoint_iff_inf_le]rintro x ⟨⟨v,rfl⟩,w,h⟩simp only [mulVecLin_apply,labMat_act] at hlet Z : Label p.b → Vec (AIdx p.g n) := fun i => if i=s then v else -whave he : ∑ i ∈ ({s,t} : Finset _), putLab p n i (Z i)=0 := bysimp [Z,hs,hs.symm,map_neg,h]have hi : ({s,t}:Finset _).card ≤ p.j+1 := byhave hh : ({s,t}:Finset _).card=2 := by simp [hs]omegahave hg := ray_indep _ _ hi he s (by simp)have hv : v=0 := by simpa [Z] using hgrw [hv,map_zero]; exact Submodule.zero_mem _theorem block_inj (B : Block p.g) : Function.Injective (blockA p n B).mulVec :=embedMat_inj (show Function.Injective (fun i => some (B,i)) fromfun _ _ h => congrArg Prod.snd (Option.some.inj h))theorem blockRay_inj (p : Shape) (n) (s) (B) :Function.Injective (blockRay p n s B).mulVec :=inj_comp_mat _ _ (lab_inj _) (block_inj B)theorem joined_block_inj {s t : Label p.b} (hj : 1 ≤ p.j) (hs : s ≠ t) (B : Block p.g) :Function.Injective (fromCols (blockRay p n s B) (blockRay p n t B)).mulVec := byclassicalapply inj_fromCols (blockRay_inj ..) (blockRay_inj ..)rw [disjoint_iff_inf_le]rintro x ⟨⟨v,rfl⟩,w,h⟩simp only [Matrix.mulVecLin_apply,blockRay,← Matrix.mulVec_mulVec] at hlet a := Sum.elim (blockA p n B *ᵥ v) (0 : Vec (AIdx p.g n))let b := Sum.elim (0 : Vec (AIdx p.g n)) (blockA p n B *ᵥ w)have heq : a=b := joined_lab_inj hj hs (bydsimp only [a,b]rw [fromCols_mulVec_sumElim,fromCols_mulVec_sumElim,Matrix.mulVec_zero,Matrix.mulVec_zero,zero_add,add_zero,h])have hg : blockA p n B *ᵥ v = 0 := funext (fun x => congr_fun heq (.inl x))change blockRay p n s B *ᵥ v ∈ _rw [blockRay,← Matrix.mulVec_mulVec,hg,Matrix.mulVec_zero]exact Submodule.zero_mem _theorem blockRay_eval (p : Shape) (s : Label p.b) (B) (i) (j : Fin n) :blockRay p n s B i j = if i.2=some (B,j) then monoBit s i.1.val else 0 := byrw [blockRay,blockA,mul_embedMat]; rfltheorem project_pick {d B : Block p.g} (hd : d ≠ B) (a) (s) (i) :(blockRay p n s B)ᵀ *ᵥ pick p n a d i = 0 := byclassicalunfold picksplit· rename_i hirw [Matrix.mulVec_single_one]ext jchange blockRay p n s B (a,some (d,⟨i,hi⟩)) j=0simp [blockRay_eval,hd]rw [Matrix.mulVec_zero]theorem project_same (B : Block p.g) (a s) (i : Fin n) :(blockRay p n s B)ᵀ *ᵥ pick p n a B i.val = Pi.single i (monoBit s a.val) := byclassicalrw [pick,dite_eq_left i.isLt,Matrix.mulVec_single_one]ext jchange blockRay p n s B _ j=_rw [blockRay_eval]simp [Pi.single_apply, eq_comm]def pullM {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I) (Q : Mat U J) :Mat V U →ₗ[F] Mat I J := liftM Pᵀ Qᵀtheorem pullM_def {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I)(Q : Mat U J) (M : Mat V U) : pullM P Q M=Pᵀ*M*Q := rfltheorem pull_test {d B : Block p.g} (h : d≠B) (s s') :pullM (blockRay p n s B) (blockRay p n s' B) (testM p n d) = 0 := byunfold testM pullMsimp only [map_sum,liftM_outer,project_pick h]simptheorem pull_self_Z (M) (s s' : Label p.b) :pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z) (selfM p n M)=0 := bylet L := pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z)have hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)(B:=Block.Z) (by simp [Block.O,Block.Z]) s s'have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.Z) (by simp [Block.S,Block.Z]) s s'have h (a : SelIdx p.b p.j) (s : Label p.b) (i) :=project_pick (n:=n) (p:=p) (d:=Block.sharp) (B:=Block.Z) (by simp [Block.sharp,Block.Z]) a s irw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]unfold sharpM sharpPick pullMby_cases he : 1 ≤ p.j· simp only [map_sum,map_smul,map_add, dite_eq_left he,liftM_outer,h]simp· simp only [dite_eq_right he]; simptheorem pull_self_sharp (M) (s s' : Label p.b) (hj : 1≤p.j) :pullM (blockRay p n s Block.sharp) (blockRay p n s' Block.sharp) (selfM p n M) =∑ i, (s i+s' i) • M i := byclassicalhave hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)(B:=Block.sharp) (by simp [Block.O,Block.sharp]) s s'have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.sharp) (by simp [Block.S,Block.sharp]) s s'rw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]unfold sharpM sharpPick pullMsimp only [map_sum,map_add,map_smul, dite_eq_left hj,liftM_outer,project_same]refine Finset.sum_congr rfl fun i _ => ?_ext a bsimp only [Matrix.sum_apply,Matrix.add_apply,Matrix.smul_apply,smul_eq_mul,vecMulVec_apply,monoBit,emptySel,Finset.prod_empty,Finset.prod_singleton,Pi.single_apply]rw [Finset.sum_eq_single a]· rw [Finset.sum_eq_single b]· simp; ring· intro j _ h; simp [h.symm]· simp· intro j _ h; simp [h.symm]simpend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687import OAI.Combinatorics.HadwigerCounterexample.ScalarStatusAlgebranamespace OAI/-! # Coordinate Duality -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Module LinearMap Submodule Functionopen scoped BigOperatorsnamespace StatusAnalysisvariable {A B : Rates} {d e : ℕ}structure DualCoefficients (A B : Rates) whereleft : Quotaright : Quotagam : Grid→Fhed : Grid→Fnorth : (i:Grid)→ Cell (A i.1)south : (i:Grid)→ Cell (B i.2)def DualCoefficients.bet (p : DualCoefficients A B) (i : Grid) (x : LedgerS A B i) :=p.gam i * x.1 + p.hed i * x.2.1 + (dotProduct (p.north i) x.2.2.1+dotProduct (p.south i) x.2.2.2)def DualCoefficients.law (p : DualCoefficients A B) (V : StatusSp A B) :=∀ i:Grid,∀ v∈V i, p.bet i (want _ _ v) =p.left i.2 * couple _ v.2.1 + p.right i.1 * couple _ v.2.2private theorem coordinates (f : Question d e →ₗ[F] F) :∃ a b : F,∃ (u : Cell d) (v : Cell e),∀ (x:Question d e),f x=a*x.1+b*x.2.1 + (dotProduct u x.2.2.1+dotProduct v x.2.2.2) := bylet g := f ∘ₗ LinearMap.inr F F _ ∘ₗ LinearMap.inr F F _obtain ⟨u,hu⟩:=dotL_surj (g ∘ₗ LinearMap.inl F _ _)obtain ⟨v,hv⟩:=dotL_surj (g ∘ₗ LinearMap.inr F _ _)let a : Question d e := (1,0); let b : Question d e := (0,1,0)refine ⟨f a,f b,u,v,?_⟩rintro ⟨x,y,z,w⟩have he : ((x,y,z,w):Question d e)=x • a +y • b+((0,0,z,0)+(0,0,0,w)) := byunfold a b; ext <;> simphave h1 : f (0,0,z,0)=dotProduct u z := LinearMap.congr_fun hu zhave h2 : f (0,0,0,w)=dotProduct v w := LinearMap.congr_fun hv wchange f (x,y,z,w)=f a*x + f b*y + _conv_lhs => rw [he]rw [map_add,map_add,map_add,map_smul,map_smul,h1,h2]; simp [mul_comm]theorem jargon_score (V : StatusSp A B) (T : Cabinet A B)(h : ¬scorecard V T) (hh : ∀ i,coverBase (V i)) :∃ p : DualCoefficients A B, (p.left≠0 ∨ p.right≠0) ∧ p.law V ∧ ∑ i,p.bet i (T i)≠0 := byobtain ⟨p,hp,hf⟩:= counter_score V T hchoose a b u v he using fun i=>coordinates (p.alf i)let g : DualCoefficients A B:=⟨p.altL,p.altR,a,b,u,v⟩have hz i x : g.bet i x=p.alf i x := (he i x).symmrefine ⟨g,critic_nz V T hh p hp hf,fun i x hx=>?_,?_⟩· rw [hz]; exact hp i x hxsimp_rw [hz]; exact hfabbrev excessK (V : Space (Signal d e)) := V ⊓ LinearMap.ker (view d e)theorem signal_dim :dim (Signal d e) = dim (View d e)+2 := bysimp only [Signal,View,Whole,dim,finrank_prod,finrank_self]omegatheorem ker_two (V : Space (Signal d e)) :dim (excessK V) ≤ 2 := byhave he : Surjective (view d e) := byrintro ⟨i,j,k⟩; exact ⟨(i,(j,0),(k,0)),rfl⟩have ht := LinearMap.finrank_range_add_finrank_ker (view d e)change rk (view _ _) + dim _=dim (Signal d e) at htrw [rk_surj.mp he,signal_dim] at htexact (Submodule.finrank_mono (show excessK V≤_ from inf_le_right)).trans(by omega : dim (LinearMap.ker (view d e)) ≤ 2)def overage (V : Space (Signal d e)) := dim V - dim (View d e)theorem overage_two (V : Space (Signal d e)) : overage V≤2 := byhave hi : dim V ≤ dim (Signal d e) := finrank_le _rw [signal_dim] at hi; unfold overage; omegatheorem overage_mono {V W : Space (Signal d e)} (h : V≤W) :overage V≤overage W := Nat.sub_le_sub_right (finrank_mono h) _theorem overage_lt {V W : Space (Signal d e)} (h : V<W) (he : coverBase V) :overage V<overage W := byhave hh := finrank_lt_finrank_of_lt h; change dim V<dim W at hhhave hx : dim (View d e) ≤ dim V := LinearMap.finrank_le_finrank_of_surjective heunfold overage; omegaend StatusAnalysisend HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687import OAI.Combinatorics.HadwigerCounterexample.ScalarStatusAlgebranamespace OAI/-! # Coordinate Duality -/noncomputable sectionnamespace HadwigerCounterexampleopen Finset Matrix Module LinearMap Submodule Functionopen scoped BigOperatorsnamespace StatusAnalysisvariable {A B : Rates} {d e : ℕ}structure DualCoefficients (A B : Rates) whereleft : Quotaright : Quotagam : Grid→Fhed : Grid→Fnorth : (i:Grid)→ Cell (A i.1)south : (i:Grid)→ Cell (B i.2)def DualCoefficients.bet (p : DualCoefficients A B) (i : Grid) (x : LedgerS A B i) :=p.gam i * x.1 + p.hed i * x.2.1 + (dotProduct (p.north i) x.2.2.1+dotProduct (p.south i) x.2.2.2)def DualCoefficients.law (p : DualCoefficients A B) (V : StatusSp A B) :=∀ i:Grid,∀ v∈V i, p.bet i (want _ _ v) =p.left i.2 * couple _ v.2.1 + p.right i.1 * couple _ v.2.2private theorem coordinates (f : Question d e →ₗ[F] F) :∃ a b : F,∃ (u : Cell d) (v : Cell e),∀ (x:Question d e),f x=a*x.1+b*x.2.1 + (dotProduct u x.2.2.1+dotProduct v x.2.2.2) := bylet g := f ∘ₗ LinearMap.inr F F _ ∘ₗ LinearMap.inr F F _obtain ⟨u,hu⟩:=dotL_surj (g ∘ₗ LinearMap.inl F _ _)obtain ⟨v,hv⟩:=dotL_surj (g ∘ₗ LinearMap.inr F _ _)let a : Question d e := (1,0); let b : Question d e := (0,1,0)refine ⟨f a,f b,u,v,?_⟩rintro ⟨x,y,z,w⟩have he : ((x,y,z,w):Question d e)=x • a +y • b+((0,0,z,0)+(0,0,0,w)) := byunfold a b; ext <;> simphave h1 : f (0,0,z,0)=dotProduct u z := LinearMap.congr_fun hu zhave h2 : f (0,0,0,w)=dotProduct v w := LinearMap.congr_fun hv wchange f (x,y,z,w)=f a*x + f b*y + _conv_lhs => rw [he]rw [map_add,map_add,map_add,map_smul,map_smul,h1,h2]; simp [mul_comm]theorem jargon_score (V : StatusSp A B) (T : Cabinet A B)(h : ¬scorecard V T) (hh : ∀ i,coverBase (V i)) :∃ p : DualCoefficients A B, (p.left≠0 ∨ p.right≠0) ∧ p.law V ∧ ∑ i,p.bet i (T i)≠0 := byobtain ⟨p,hp,hf⟩:= counter_score V T hchoose a b u v he using fun i=>coordinates (p.alf i)let g : DualCoefficients A B:=⟨p.altL,p.altR,a,b,u,v⟩have hz i x : g.bet i x=p.alf i x := (he i x).symmrefine ⟨g,critic_nz V T hh p hp hf,fun i x hx=>?_,?_⟩· rw [hz]; exact hp i x hxsimp_rw [hz]; exact hfabbrev excessK (V : Space (Signal d e)) := V ⊓ LinearMap.ker (view d e)theorem signal_dim :dim (Signal d e) = dim (View d e)+2 := bysimp only [Signal,View,Whole,dim,finrank_prod,finrank_self]omegatheorem ker_two (V : Space (Signal d e)) :dim (excessK V) ≤ 2 := byhave he : Surjective (view d e) := byrintro ⟨i,j,k⟩; exact ⟨(i,(j,0),(k,0)),rfl⟩have ht := LinearMap.finrank_range_add_finrank_ker (view d e)change rk (view _ _) + dim _=dim (Signal d e) at htrw [rk_surj.mp he,signal_dim] at htexact (Submodule.finrank_mono (show excessK V≤_ from inf_le_right)).trans(by omega : dim (LinearMap.ker (view d e)) ≤ 2)def overage (V : Space (Signal d e)) := dim V - dim (View d e)theorem overage_two (V : Space (Signal d e)) : overage V≤2 := byhave hi : dim V ≤ dim (Signal d e) := finrank_le _rw [signal_dim] at hi; unfold overage; omegatheorem overage_mono {V W : Space (Signal d e)} (h : V≤W) :overage V≤overage W := Nat.sub_le_sub_right (finrank_mono h) _theorem overage_lt {V W : Space (Signal d e)} (h : V<W) (he : coverBase V) :overage V<overage W := byhave hh := finrank_lt_finrank_of_lt h; change dim V<dim W at hhhave hx : dim (View d e) ≤ dim V := LinearMap.finrank_le_finrank_of_surjective heunfold overage; omegaend StatusAnalysisend HadwigerCounterexampleendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163import OAI.Combinatorics.HadwigerCounterexample.MatrixRanksimport Mathlib.Data.Matrix.ColumnRowPartitionednamespace OAI/-! # Coordinate Embeddings -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module Functionopen scoped BigOperatorsvariable {U V I J K T : Type} [Fintype U] [Fintype V] [Fintype I] [Fintype J][Fintype K] [Fintype T]def embedMat [DecidableEq U] (f : I → U) : Mat U I := Matrix.of (fun i j => if i=f j then 1 else 0)omit [Fintype I] intheorem embedMatT [DecidableEq U] (f : I → U) (x : Vec U) :(embedMat f)ᵀ *ᵥ x = fun i => x (f i) := byclassical funext isimp [embedMat,Matrix.mulVec,dotProduct]omit [Fintype V] [Fintype I] intheorem mul_embedMat [DecidableEq U] (f : I → U) (M : Mat V U) :M*embedMat f = M.submatrix _root_.id f := byext i jsimp [Matrix.mul_apply,embedMat]omit [Fintype V] [Fintype I] intheorem embedMat_mul [DecidableEq U] (f : I → U) (M : Mat U V) :(embedMat f)ᵀ*M = M.submatrix f _root_.id := byext i jsimp [Matrix.mul_apply,embedMat]omit [Fintype I] intheorem embedMat_self [DecidableEq I] [DecidableEq U] {f : I → U} (h : Injective f) :(embedMat f)ᵀ * embedMat f = 1 := byext i jrw [embedMat_mul]simp only [embedMat,Matrix.submatrix_apply,Matrix.of_apply,id_eq,Matrix.one_apply,h.eq_iff]theorem embedMat_inj [DecidableEq U] {f : I → U} (h : Injective f) :Injective (embedMat f).mulVec := byclassicalintro x y gchange embedMat f *ᵥ x = embedMat f *ᵥ y at ghave he (x : Vec I) : (embedMat f)ᵀ *ᵥ (embedMat f *ᵥ x) = x := byrw [Matrix.mulVec_mulVec,embedMat_self h,Matrix.one_mulVec]rw [← he x,g,he]omit [Fintype U] intheorem inj_fromCols {A : Mat U I} {B : Mat U J} (hA : Injective A.mulVec)(hB : Injective B.mulVec) (h : Disjoint (colSp A) (colSp B)) :Injective (fromCols A B).mulVec := byrw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]intro x hxlet a := fun i => x (Sum.inl i)let b := fun j => x (Sum.inr j)rw [fromCols_mulVec] at hxhave he : A*ᵥa=B*ᵥb := add_right_cancel (hx.trans (char_two (B*ᵥb)).symm)have hi : A*ᵥa ∈ colSp A ⊓ colSp B :=⟨⟨a,rfl⟩, he.symm ▸ (show B*ᵥb∈colSp B from ⟨b,rfl⟩)⟩rw [h.eq_bot] at hihave hg : A*ᵥa=0 := by simpa using hihave ha : a=0 := hA (hg.trans (Matrix.mulVec_zero A).symm)rw [he] at hghave hb : b=0 := hB (hg.trans (Matrix.mulVec_zero B).symm)funext icases i· exact congr_fun ha _· exact congr_fun hb _/-- Specify an arbitrary cross Gram bilinear form between independent columns. -/theorem prescribe_between {A : Mat U I} {B : Mat V J}(hA : Injective A.mulVec) (hB : Injective B.mulVec) (M : Mat I J) :∃ L : Mat U V, Aᵀ*L*B=M := byclassicalobtain ⟨a,ha⟩ := mat_left_inv hAobtain ⟨b,hb⟩ := mat_left_inv hBrefine ⟨aᵀ*(M*b),?_⟩rw [← Matrix.mul_assoc Aᵀ,←transpose_mul,ha,transpose_one,Matrix.one_mul,Matrix.mul_assoc,hb,Matrix.mul_one]/-- Two opposite-direction restrictions are specifiable on disjoint bases. -/theorem prescribe_opposite {A : Mat U I} {B : Mat V J} {C : Mat U K} {D : Mat V T}(hc : Injective (fromCols A C).mulVec) (hd : Injective (fromCols B D).mulVec)(M : Mat I J) (N : Mat T K) :∃ L : Mat U V, Aᵀ*L*B=M ∧ Dᵀ*Lᵀ*C=N := byobtain ⟨L,hL⟩ := prescribe_between hc hd (fromBlocks M 0 0 Nᵀ)rw [transpose_fromCols, fromRows_mul, fromRows_mul_fromCols] at hLhave hi : Cᵀ*L*D=Nᵀ := congrArg Matrix.toBlocks₂₂ hLrefine ⟨L, congrArg Matrix.toBlocks₁₁ hL, ?_⟩have hg := congrArg Matrix.transpose hirwa [transpose_mul,transpose_mul,transpose_transpose,transpose_transpose,← Matrix.mul_assoc] at hgomit [Fintype I] intheorem rank_ge_mul (A : Mat I J) (B : Mat J K) :A.rank+B.rank ≤ (A*B).rank+Fintype.card J := bylet f := A.mulVecLinlet g := f ∘ₗ (colSp B).subtypehave he : LinearMap.range g = colSp (A*B) := bychange LinearMap.range g = LinearMap.range ((A*B).mulVecLin)rw [mulVecLin_mul]unfold grw [LinearMap.range_comp,LinearMap.range_comp]simp [f,colSp]have hi : dim (LinearMap.ker g) ≤ dim (LinearMap.ker f) := bylet q := ((colSp B).subtype ∘ₗ (LinearMap.ker g).subtype)have hq (x : LinearMap.ker g) : q x ∈ LinearMap.ker f := x.propertylet k := q.codRestrict (LinearMap.ker f) hqhave hk : Injective k := byintro x y hhave heq := congrArg (fun b : LinearMap.ker f => b.val) hexact Subtype.ext (Subtype.ext heq)exact LinearMap.finrank_le_finrank_of_injective hkhave h1 := g.finrank_range_add_finrank_kerrw [he] at h1have h2 := f.finrank_range_add_finrank_kerchange (A*B).rank + dim (LinearMap.ker g)=B.rank at h1change A.rank + dim (LinearMap.ker f)=dim (Vec J) at h2rw [dim_vec] at h2; omegatheorem rank_ge_congr (A : Mat I I) (B : Mat J I) :A.rank + 2*B.rank ≤ (liftM B B A).rank + 2*Fintype.card I := byhave h1 := rank_ge_mul B Ahave h2 := rank_ge_mul (B*A) Bᵀrw [Matrix.rank_transpose] at h2rw [liftM_def]; omega/-- Choose a large space in the domain which becomes disjoint from S in the target. -/theorem choose_free {A : Mat I J} (hA : Injective A.mulVec) (S : Space (Vec I)) :∃ T : Space (Vec J), Fintype.card J ≤ dim T+dim S ∧Disjoint S (colSp (A*pack T)) := bylet U := S.comap A.mulVecLinobtain ⟨T,hT⟩ := U.exists_isComplrefine ⟨T,?_,?_⟩· have hi : dim U ≤ dim S := bylet q := A.mulVecLin ∘ₗ U.subtypehave he (x : U) : q x∈S := x.propertylet B := q.codRestrict S hehave hb : Injective B := fun x y h => Subtype.ext (hA(show q x=q y from congrArg Subtype.val h))exact LinearMap.finrank_le_finrank_of_injective hbhave he := (U.prodEquivOfIsCompl T hT).finrank_eqrw [finrank_prod,show finrank F (Vec J)=Fintype.card J from dim_vec _] at hechange dim U + dim T = Fintype.card J at herw [← he]exact (Nat.add_le_add_right hi _).trans_eq (Nat.add_comm _ _)rw [colSp,mulVecLin_mul,LinearMap.range_comp,show LinearMap.range (pack T).mulVecLin = T fromcolSp_pack T]rw [disjoint_iff_inf_le]rintro x ⟨hx,y,hy,rfl⟩have hh : y∈U⊓T := ⟨hx,hy⟩rw [hT.inf_eq_bot] at hhhave he : y=0 := by simpa using hhrw [he,map_zero]; exact Submodule.zero_mem _end HadwigerCounterexampleendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163import OAI.Combinatorics.HadwigerCounterexample.MatrixRanksimport Mathlib.Data.Matrix.ColumnRowPartitionednamespace OAI/-! # Coordinate Embeddings -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Module Functionopen scoped BigOperatorsvariable {U V I J K T : Type} [Fintype U] [Fintype V] [Fintype I] [Fintype J][Fintype K] [Fintype T]def embedMat [DecidableEq U] (f : I → U) : Mat U I := Matrix.of (fun i j => if i=f j then 1 else 0)omit [Fintype I] intheorem embedMatT [DecidableEq U] (f : I → U) (x : Vec U) :(embedMat f)ᵀ *ᵥ x = fun i => x (f i) := byclassical funext isimp [embedMat,Matrix.mulVec,dotProduct]omit [Fintype V] [Fintype I] intheorem mul_embedMat [DecidableEq U] (f : I → U) (M : Mat V U) :M*embedMat f = M.submatrix _root_.id f := byext i jsimp [Matrix.mul_apply,embedMat]omit [Fintype V] [Fintype I] intheorem embedMat_mul [DecidableEq U] (f : I → U) (M : Mat U V) :(embedMat f)ᵀ*M = M.submatrix f _root_.id := byext i jsimp [Matrix.mul_apply,embedMat]omit [Fintype I] intheorem embedMat_self [DecidableEq I] [DecidableEq U] {f : I → U} (h : Injective f) :(embedMat f)ᵀ * embedMat f = 1 := byext i jrw [embedMat_mul]simp only [embedMat,Matrix.submatrix_apply,Matrix.of_apply,id_eq,Matrix.one_apply,h.eq_iff]theorem embedMat_inj [DecidableEq U] {f : I → U} (h : Injective f) :Injective (embedMat f).mulVec := byclassicalintro x y gchange embedMat f *ᵥ x = embedMat f *ᵥ y at ghave he (x : Vec I) : (embedMat f)ᵀ *ᵥ (embedMat f *ᵥ x) = x := byrw [Matrix.mulVec_mulVec,embedMat_self h,Matrix.one_mulVec]rw [← he x,g,he]omit [Fintype U] intheorem inj_fromCols {A : Mat U I} {B : Mat U J} (hA : Injective A.mulVec)(hB : Injective B.mulVec) (h : Disjoint (colSp A) (colSp B)) :Injective (fromCols A B).mulVec := byrw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]intro x hxlet a := fun i => x (Sum.inl i)let b := fun j => x (Sum.inr j)rw [fromCols_mulVec] at hxhave he : A*ᵥa=B*ᵥb := add_right_cancel (hx.trans (char_two (B*ᵥb)).symm)have hi : A*ᵥa ∈ colSp A ⊓ colSp B :=⟨⟨a,rfl⟩, he.symm ▸ (show B*ᵥb∈colSp B from ⟨b,rfl⟩)⟩rw [h.eq_bot] at hihave hg : A*ᵥa=0 := by simpa using hihave ha : a=0 := hA (hg.trans (Matrix.mulVec_zero A).symm)rw [he] at hghave hb : b=0 := hB (hg.trans (Matrix.mulVec_zero B).symm)funext icases i· exact congr_fun ha _· exact congr_fun hb _/-- Specify an arbitrary cross Gram bilinear form between independent columns. -/theorem prescribe_between {A : Mat U I} {B : Mat V J}(hA : Injective A.mulVec) (hB : Injective B.mulVec) (M : Mat I J) :∃ L : Mat U V, Aᵀ*L*B=M := byclassicalobtain ⟨a,ha⟩ := mat_left_inv hAobtain ⟨b,hb⟩ := mat_left_inv hBrefine ⟨aᵀ*(M*b),?_⟩rw [← Matrix.mul_assoc Aᵀ,←transpose_mul,ha,transpose_one,Matrix.one_mul,Matrix.mul_assoc,hb,Matrix.mul_one]/-- Two opposite-direction restrictions are specifiable on disjoint bases. -/theorem prescribe_opposite {A : Mat U I} {B : Mat V J} {C : Mat U K} {D : Mat V T}(hc : Injective (fromCols A C).mulVec) (hd : Injective (fromCols B D).mulVec)(M : Mat I J) (N : Mat T K) :∃ L : Mat U V, Aᵀ*L*B=M ∧ Dᵀ*Lᵀ*C=N := byobtain ⟨L,hL⟩ := prescribe_between hc hd (fromBlocks M 0 0 Nᵀ)rw [transpose_fromCols, fromRows_mul, fromRows_mul_fromCols] at hLhave hi : Cᵀ*L*D=Nᵀ := congrArg Matrix.toBlocks₂₂ hLrefine ⟨L, congrArg Matrix.toBlocks₁₁ hL, ?_⟩have hg := congrArg Matrix.transpose hirwa [transpose_mul,transpose_mul,transpose_transpose,transpose_transpose,← Matrix.mul_assoc] at hgomit [Fintype I] intheorem rank_ge_mul (A : Mat I J) (B : Mat J K) :A.rank+B.rank ≤ (A*B).rank+Fintype.card J := bylet f := A.mulVecLinlet g := f ∘ₗ (colSp B).subtypehave he : LinearMap.range g = colSp (A*B) := bychange LinearMap.range g = LinearMap.range ((A*B).mulVecLin)rw [mulVecLin_mul]unfold grw [LinearMap.range_comp,LinearMap.range_comp]simp [f,colSp]have hi : dim (LinearMap.ker g) ≤ dim (LinearMap.ker f) := bylet q := ((colSp B).subtype ∘ₗ (LinearMap.ker g).subtype)have hq (x : LinearMap.ker g) : q x ∈ LinearMap.ker f := x.propertylet k := q.codRestrict (LinearMap.ker f) hqhave hk : Injective k := byintro x y hhave heq := congrArg (fun b : LinearMap.ker f => b.val) hexact Subtype.ext (Subtype.ext heq)exact LinearMap.finrank_le_finrank_of_injective hkhave h1 := g.finrank_range_add_finrank_kerrw [he] at h1have h2 := f.finrank_range_add_finrank_kerchange (A*B).rank + dim (LinearMap.ker g)=B.rank at h1change A.rank + dim (LinearMap.ker f)=dim (Vec J) at h2rw [dim_vec] at h2; omegatheorem rank_ge_congr (A : Mat I I) (B : Mat J I) :A.rank + 2*B.rank ≤ (liftM B B A).rank + 2*Fintype.card I := byhave h1 := rank_ge_mul B Ahave h2 := rank_ge_mul (B*A) Bᵀrw [Matrix.rank_transpose] at h2rw [liftM_def]; omega/-- Choose a large space in the domain which becomes disjoint from S in the target. -/theorem choose_free {A : Mat I J} (hA : Injective A.mulVec) (S : Space (Vec I)) :∃ T : Space (Vec J), Fintype.card J ≤ dim T+dim S ∧Disjoint S (colSp (A*pack T)) := bylet U := S.comap A.mulVecLinobtain ⟨T,hT⟩ := U.exists_isComplrefine ⟨T,?_,?_⟩· have hi : dim U ≤ dim S := bylet q := A.mulVecLin ∘ₗ U.subtypehave he (x : U) : q x∈S := x.propertylet B := q.codRestrict S hehave hb : Injective B := fun x y h => Subtype.ext (hA(show q x=q y from congrArg Subtype.val h))exact LinearMap.finrank_le_finrank_of_injective hbhave he := (U.prodEquivOfIsCompl T hT).finrank_eqrw [finrank_prod,show finrank F (Vec J)=Fintype.card J from dim_vec _] at hechange dim U + dim T = Fintype.card J at herw [← he]exact (Nat.add_le_add_right hi _).trans_eq (Nat.add_comm _ _)rw [colSp,mulVecLin_mul,LinearMap.range_comp,show LinearMap.range (pack T).mulVecLin = T fromcolSp_pack T]rw [disjoint_iff_inf_le]rintro x ⟨hx,y,hy,rfl⟩have hh : y∈U⊓T := ⟨hx,hy⟩rw [hT.inf_eq_bot] at hhhave he : y=0 := by simpa using hhrw [he,map_zero]; exact Submodule.zero_mem _end HadwigerCounterexampleendend OAI
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import OAI.Combinatorics.HadwigerCounterexample.PhaseClassCompatibilityimport OAI.Combinatorics.HadwigerCounterexample.LowRankKernelAlternativenamespace OAI/-! # Cover Alternatives -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Finset Filteropen scoped BigOperators Topologyopen PredictionClassvariable {p : Shape} {n N M : ℕ}theorem longStory (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)(c : PredictionClass) (α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :∃ P : UnitType p n N×UnitType p n N→Prop,named P (bp (3*d*(N:ℝ))) ∧named (P ∘ Prod.swap) (bp (3*d*(N:ℝ))) ∧∀ x,pairW w w x≠0→ (P x↔ matchUp Δ α r c x) := byclassicallet Q (x : Daypair p T×Daypair p T) : Prop :=c.compatible α r (fun i=>x.2.2 i x.1.1, fun i => x.1.2 i x.2.1)let f := daypair p T Δ wrefine ⟨fun x=>Q (f x.1,f x.2),day_named p T Δ w d hd Q,day_named p T Δ w d hd (Q∘Prod.swap),fun x hx=>?_⟩have hs (x y : UnitType p n N) (hz : w x≠0) (i) :(f y).2 i (f x).1=tone p y (unary i) (Δ x) :=shadow_valid p T Δ hh x y (unary i) hzunfold Q matchUp quenchdsimp onlysimp_rw [hs _ _ (left_ne_zero_of_mul hx), hs _ _ (right_ne_zero_of_mul hx)]theorem matSeason (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)(α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :∃ F : Mat (UnitType p n N) (UnitType p n N), F.rank ≤ 2*d*N ∧(∀ x, F x x=0) ∧ ∀ x,pairW w w x≠0→ (F x.1 x.2=0 ↔ matchUp Δ α r twinned x) := bylet F := circus p T Δ whave he : F.rank ≤ N*d := (circus_rank ..).trans (Nat.mul_le_mul_left _ hd)refine ⟨F+Fᵀ, (mrk_add_le F Fᵀ).trans ?_,fun x=>char_two _,fun x hx=>?_⟩· rw [Matrix.rank_transpose]; nlinarith· unfold matchUp compatible quenchdsimp only; rw [←tone_vec,←tone_vec]have h x y (hx : w x ≠ 0) : F x y = tone p y allSide (Δ x) :=shadow_valid p T Δ hh x y allSide hxchange (F x.1 x.2+F x.2 x.1=0) ↔ _rw [h _ _ (left_ne_zero_of_mul hx),h _ _ (right_ne_zero_of_mul hx)]set_option maxHeartbeats 1000000 intheorem coFiber (l : Filter ℕ) (hz : l≤atTop) {M : ℕ} (hM : 1≤ M) (d : ℕ)(p : Shape) (w : ∀ n,Wgt (UnitType p n (M*n)))(α : Party) (r : F) (Δ : ∀ n, UnitType p n (M*n) → Ambient p (M*n))(h : ∀ᶠ n in l, IsLaw (w n) ∧∃ T : Cov p (M*n),cdim p T≤d∧∀ x,w n x≠0 → covered p T (Δ n x))(he : slight l (fun n=>pr (pairW (w n) (w n)) (matchUp (Δ n) α r twinned))) :∃ S : ∀ n, UnitType p n (M*n)→Prop,warm l (fun n=>((M*n:ℕ):ℝ)) (fun n=>pr (w n) (S n)) ∧∀ᶠ n in l, ∀ x,S n x.1 → S n x.2 → matchUp (Δ n) α r twinned x := byclassicallet X n:= UnitType p n (M*n)let q n:= matchUp (Δ n) α r twinnedlet c (k : ℕ) := ((k:ℝ)+1)⁻¹let P n (S : X n→Prop) (k : ℕ) :=bp (-(c k)*((M*n:ℕ):ℝ)) ≤ pr (w n) S ∧ ∀ x,S x.1 → S x.2 → q n xhave hf (k : ℕ) : ∀ᶠ n in l,∃ S : X n→Prop,P n S k := byobtain ⟨θ,hθ,hg⟩:= fiber_growth (2*d) (c k) (by unfold c; positivity) (by positivity)filter_upwards [h,he θ hθ, (trend_sizes l hz hM).1.eventually hg] with n hn hh hFobtain ⟨hv,T,hT,h⟩:=hnobtain ⟨F,hf,hz,hc⟩:= matSeason T d hT α r (Δ n) (w n) hhave ht : pr (pairW (w n) (w n)) (fun x => F x.1 x.2=0) ≤ θ :=(avg_congr (fun x hx => show ind _=ind _ from congrArg ind (propext (hc x hx)))).trans_le hhhave hr : (F.rank:ℝ)≤ 2*d*(M*n:ℕ) := by exact_mod_cast hfobtain ⟨S,hS,ht⟩:= hF (X n) F (w n) hv hr hz htlet Y (x:X n) := S x∧ w n x≠0have he : pr (w n) Y=pr (w n) S := avg_congr (fun x hx=>by simp [Y, hx])refine ⟨Y, hS.trans_eq he.symm, fun x hx hy =>(hc x (mul_ne_zero hx.2 hy.2)).mp (ht x.1 hx.1 x.2 hy.1)⟩obtain ⟨k,hk,hf⟩:= diagonal_gains l hz (fun n k => ∃ S : X n→Prop,P n S k) hfobtain ⟨S,h⟩:= taking hfrefine ⟨S,fun ε he=>?_, h.mono fun i hi=>hi.2⟩filter_upwards [h,slight_inv_stage hk ε he] with n hn hhexact (bp_le (mul_le_mul_of_nonneg_right (neg_le_neg hh) (Nat.cast_nonneg _))).trans hn.1end HadwigerCounterexampleendend OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import OAI.Combinatorics.HadwigerCounterexample.PhaseClassCompatibilityimport OAI.Combinatorics.HadwigerCounterexample.LowRankKernelAlternativenamespace OAI/-! # Cover Alternatives -/noncomputable sectionnamespace HadwigerCounterexampleopen Matrix Finset Filteropen scoped BigOperators Topologyopen PredictionClassvariable {p : Shape} {n N M : ℕ}theorem longStory (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)(c : PredictionClass) (α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :∃ P : UnitType p n N×UnitType p n N→Prop,named P (bp (3*d*(N:ℝ))) ∧named (P ∘ Prod.swap) (bp (3*d*(N:ℝ))) ∧∀ x,pairW w w x≠0→ (P x↔ matchUp Δ α r c x) := byclassicallet Q (x : Daypair p T×Daypair p T) : Prop :=c.compatible α r (fun i=>x.2.2 i x.1.1, fun i => x.1.2 i x.2.1)let f := daypair p T Δ wrefine ⟨fun x=>Q (f x.1,f x.2),day_named p T Δ w d hd Q,day_named p T Δ w d hd (Q∘Prod.swap),fun x hx=>?_⟩have hs (x y : UnitType p n N) (hz : w x≠0) (i) :(f y).2 i (f x).1=tone p y (unary i) (Δ x) :=shadow_valid p T Δ hh x y (unary i) hzunfold Q matchUp quenchdsimp onlysimp_rw [hs _ _ (left_ne_zero_of_mul hx), hs _ _ (right_ne_zero_of_mul hx)]theorem matSeason (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)(α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :∃ F : Mat (UnitType p n N) (UnitType p n N), F.rank ≤ 2*d*N ∧(∀ x, F x x=0) ∧ ∀ x,pairW w w x≠0→ (F x.1 x.2=0 ↔ matchUp Δ α r twinned x) := bylet F := circus p T Δ whave he : F.rank ≤ N*d := (circus_rank ..).trans (Nat.mul_le_mul_left _ hd)refine ⟨F+Fᵀ, (mrk_add_le F Fᵀ).trans ?_,fun x=>char_two _,fun x hx=>?_⟩· rw [Matrix.rank_transpose]; nlinarith· unfold matchUp compatible quenchdsimp only; rw [←tone_vec,←tone_vec]have h x y (hx : w x ≠ 0) : F x y = tone p y allSide (Δ x) :=shadow_valid p T Δ hh x y allSide hxchange (F x.1 x.2+F x.2 x.1=0) ↔ _rw [h _ _ (left_ne_zero_of_mul hx),h _ _ (right_ne_zero_of_mul hx)]set_option maxHeartbeats 1000000 intheorem coFiber (l : Filter ℕ) (hz : l≤atTop) {M : ℕ} (hM : 1≤ M) (d : ℕ)(p : Shape) (w : ∀ n,Wgt (UnitType p n (M*n)))(α : Party) (r : F) (Δ : ∀ n, UnitType p n (M*n) → Ambient p (M*n))(h : ∀ᶠ n in l, IsLaw (w n) ∧∃ T : Cov p (M*n),cdim p T≤d∧∀ x,w n x≠0 → covered p T (Δ n x))(he : slight l (fun n=>pr (pairW (w n) (w n)) (matchUp (Δ n) α r twinned))) :∃ S : ∀ n, UnitType p n (M*n)→Prop,warm l (fun n=>((M*n:ℕ):ℝ)) (fun n=>pr (w n) (S n)) ∧∀ᶠ n in l, ∀ x,S n x.1 → S n x.2 → matchUp (Δ n) α r twinned x := byclassicallet X n:= UnitType p n (M*n)let q n:= matchUp (Δ n) α r twinnedlet c (k : ℕ) := ((k:ℝ)+1)⁻¹let P n (S : X n→Prop) (k : ℕ) :=bp (-(c k)*((M*n:ℕ):ℝ)) ≤ pr (w n) S ∧ ∀ x,S x.1 → S x.2 → q n xhave hf (k : ℕ) : ∀ᶠ n in l,∃ S : X n→Prop,P n S k := byobtain ⟨θ,hθ,hg⟩:= fiber_growth (2*d) (c k) (by unfold c; positivity) (by positivity)filter_upwards [h,he θ hθ, (trend_sizes l hz hM).1.eventually hg] with n hn hh hFobtain ⟨hv,T,hT,h⟩:=hnobtain ⟨F,hf,hz,hc⟩:= matSeason T d hT α r (Δ n) (w n) hhave ht : pr (pairW (w n) (w n)) (fun x => F x.1 x.2=0) ≤ θ :=(avg_congr (fun x hx => show ind _=ind _ from congrArg ind (propext (hc x hx)))).trans_le hhhave hr : (F.rank:ℝ)≤ 2*d*(M*n:ℕ) := by exact_mod_cast hfobtain ⟨S,hS,ht⟩:= hF (X n) F (w n) hv hr hz htlet Y (x:X n) := S x∧ w n x≠0have he : pr (w n) Y=pr (w n) S := avg_congr (fun x hx=>by simp [Y, hx])refine ⟨Y, hS.trans_eq he.symm, fun x hx hy =>(hc x (mul_ne_zero hx.2 hy.2)).mp (ht x.1 hx.1 x.2 hy.1)⟩obtain ⟨k,hk,hf⟩:= diagonal_gains l hz (fun n k => ∃ S : X n→Prop,P n S k) hfobtain ⟨S,h⟩:= taking hfrefine ⟨S,fun ε he=>?_, h.mono fun i hi=>hi.2⟩filter_upwards [h,slight_inv_stage hk ε he] with n hn hhexact (bp_le (mul_le_mul_of_nonneg_right (neg_le_neg hh) (Nat.cast_nonneg _))).trans hn.1end HadwigerCounterexampleendend OAI
lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveProjectionBounds.lean+124-124
lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveRecordBounds.lean+102-102
lean/OAI/Combinatorics/HadwigerCounterexample/AdditionalProbeBounds.lean+171-171
lean/OAI/Combinatorics/HadwigerCounterexample/AffineFrames.lean+195-195
lean/OAI/Combinatorics/HadwigerCounterexample/AggregateCostBounds.lean+124-124
lean/OAI/Combinatorics/HadwigerCounterexample/AmbientBatchSlots.lean+211-211
lean/OAI/Combinatorics/HadwigerCounterexample/AnalyticParameters.lean+143-143
lean/OAI/Combinatorics/HadwigerCounterexample/AtomFlavors.lean+148-148
lean/OAI/Combinatorics/HadwigerCounterexample/AttackCutDecomposition.lean+277-277
lean/OAI/Combinatorics/HadwigerCounterexample/BaselineExtension.lean+124-124
lean/OAI/Combinatorics/HadwigerCounterexample/BaselineForms.lean+147-147
lean/OAI/Combinatorics/HadwigerCounterexample/BasisConditioning.lean+113-113
lean/OAI/Combinatorics/HadwigerCounterexample/BatchCharacters.lean+153-153
lean/OAI/Combinatorics/HadwigerCounterexample/BiasedRotationBounds.lean+142-142
lean/OAI/Combinatorics/HadwigerCounterexample/BilinearBlockCorrelation.lean+107-107
lean/OAI/Combinatorics/HadwigerCounterexample/BilinearCompression.lean+126-126
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryEvaluationForms.lean+174-174
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMatrices.lean+125-125
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMixingBounds.lean+106-106
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryPrescriptions.lean+265-265
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryStatusComparison.lean+143-143
lean/OAI/Combinatorics/HadwigerCounterexample/BooleanLabels.lean+151-151
lean/OAI/Combinatorics/HadwigerCounterexample/BoundedQueryTemplates.lean+134-134
lean/OAI/Combinatorics/HadwigerCounterexample/CellPositivityScales.lean+177-177
lean/OAI/Combinatorics/HadwigerCounterexample/CellPruning.lean+128-128
lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFactorization.lean+144-144
lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFrameLaws.lean+186-186
lean/OAI/Combinatorics/HadwigerCounterexample/CollisionInequality.lean+204-204
lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitionRefinement.lean+79-79
lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitions.lean+119-119
lean/OAI/Combinatorics/HadwigerCounterexample/CommonPredictions.lean+112-112
lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleOptionRealization.lean+130-130
lean/OAI/Combinatorics/HadwigerCounterexample/CompatiblePairTests.lean+105-105
lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleTableEvents.lean+149-149
lean/OAI/Combinatorics/HadwigerCounterexample/ComponentIndices.lean+115-115
lean/OAI/Combinatorics/HadwigerCounterexample/ConcentrationScales.lean+169-169
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalCellEntropy.lean+156-156
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFlags.lean+107-107
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFourCorners.lean+101-101
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalLargeSetHits.lean+106-106
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProductLaws.lean+125-125
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProjection.lean+96-96
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalSignaturePositivity.lean+110-110
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedBatchLaws.lean+198-198
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedCorrelations.lean+97-97
lean/OAI/Combinatorics/HadwigerCounterexample/ConstructionScales.lean+100-100
lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateBlocks.lean+147-147
lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateDuality.lean+87-87
lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateEmbeddings.lean+163-163
lean/OAI/Combinatorics/HadwigerCounterexample/CoverAlternatives.lean+86-86