Add lean source and binary files (part 59)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/ClosedWalkFamily.leanAdded+145
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/ClosedWalkPattern.leanAdded+120
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/ClosedWords.leanAdded+123
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/CountClosedWalk.leanAdded+99
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/DensityGlobalSpectral.leanAdded+111
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/EdgeStar.leanAdded+96
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/ExtendStarApply.leanAdded+51
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/ExtendStarMulVec.leanAdded+86
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/FallingFactorialNormalizedProduct.leanAdded+130
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/FreshLogCheckNone.leanAdded+49
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/FreshLogCheckNone2.leanAdded+54
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/FreshLogCheckNone3.leanAdded+47
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/GlobalLinkAdjacencyHermitian.leanAdded+85
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/GraphStarApproximation.leanAdded+92
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/LinkStarMatrix.leanAdded+116
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixEuclideanAlgHom.leanAdded+74
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixExpL2Bound.leanAdded+60
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixInfinityAlgHom.leanAdded+42
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixRowAbsSum.leanAdded+89
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/MovingStarDegree.leanAdded+327
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/NormalizedOnes.leanAdded+143
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/RealTraceAdjMatrix.leanAdded+132
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/StarInclusion.leanAdded+127
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/TracedGridQueryAddress.leanAdded+133
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/TracedGridQueryLog.leanAdded+55
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/TracedGridQuerySeparated.leanAdded+88
- lean/OAI/Combinatorics/TriangleRemoval/Spectral/WheelSpoke.leanAdded+246
- lean/OAI/Combinatorics/TriangleRemoval/Stability/ActiveCavityFactorProduct.leanAdded+129
- lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityGenerator.leanAdded+361
- lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityReference.leanAdded+183
- lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityWeight.leanAdded+138
- lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityWeightLipschitz.leanAdded+119
- lean/OAI/Combinatorics/TriangleRemoval/Stability/ContinuousCavityWeightClip.leanAdded+111
- lean/OAI/Combinatorics/TriangleRemoval/Stability/EdgeStabilityRate.leanAdded+117
- lean/OAI/Combinatorics/TriangleRemoval/Stability/GeometricVolterraIdentity.leanAdded+123
- lean/OAI/Combinatorics/TriangleRemoval/Stability/GridCavityError.leanAdded+304
- lean/OAI/Combinatorics/TriangleRemoval/Stability/GridCavityWeightLower.leanAdded+131
- lean/OAI/Combinatorics/TriangleRemoval/Stability/MovingPerturbationFiniteExpansion.leanAdded+96
- lean/OAI/Combinatorics/TriangleRemoval/Stability/MovingResidualForcing.leanAdded+171
- lean/OAI/Combinatorics/TriangleRemoval/Stability/RelativeTemplateResidual.leanAdded+77
- lean/OAI/Combinatorics/TriangleRemoval/Stability/Volterra.leanAdded+231
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/BalancedJump.leanAdded+205
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/CenteredCodegreeNeighborSum.leanAdded+72
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeNoiseRadius.leanAdded+79
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeRelativeNoiseTail.leanAdded+52
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeVarianceRate.leanAdded+89
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeVertexCount.leanAdded+103
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/GoodPrefixStarApproximation.leanAdded+67
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/GoodPrefixSurvivalMoments.leanAdded+85
- lean/OAI/Combinatorics/TriangleRemoval/Tracking/NormalizedTrackingAbsolute.leanAdded+125
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.ClosedWords
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpaceopen scoped BigOperators
namespace SharpTerminalLeavesection TraceBridgevariable {V : Type*} [Fintype V] [DecidableEq V]variable (G : SimpleGraph V) [DecidableRel G.Adj]
abbrev closedWalkFamily (r : ℕ) := Σ v : V, {p : G.Walk v v // p.length = r}
omit [Fintype V] [DecidableEq V] [DecidableRel G.Adj] in
lemma wordOfWalk_adj {r : ℕ} {a : V} (p : G.Walk a a) (hp : p.length = r) (i j : Fin r) (hij : (SimpleGraph.cycleGraph r).Adj i j) : G.Adj (p.getVert i.val) (p.getVert j.val) := by obtain ⟨x,hx⟩ := i obtain ⟨y,hy⟩ := j have hne : x ≠ y := by intro h subst y exact hij.ne rfl wlog hgt : x > y generalizing x y · exact (this y hy x hx hij.symm hne.symm (by omega)).symm rcases SimpleGraph.cycleGraph_adj'.mp hij with h | h · rw [Fin.sub_val_of_le (show (⟨y, hy⟩ : Fin r) ≤ ⟨x, hx⟩ from hgt.le)] at h dsimp only at h have heq : x = y+1 := by omega subst x exact (p.adj_getVert_succ (by omega : y < p.length)).symm · rw [Fin.coe_sub_iff_lt.mpr hgt] at h dsimp only at h have hx' : x = r-1 := by omega have hy' : y = 0 := by omega subst x; subst y have hlast := p.adj_getVert_succ (by omega : r-1 < p.length) simpa only [show r-1+1 = p.length by omega, SimpleGraph.Walk.getVert_length, SimpleGraph.Walk.getVert_zero] using hlast
noncomputable def wordOfWalk {r : ℕ} (p : closedWalkFamily G r) : closedWords G r := ⟨fun i => p.2.1.getVert i.val, by classical simp only [closedWords, Finset.mem_filter, Finset.mem_univ, true_and] exact wordOfWalk_adj G p.2.1 p.2.2⟩
omit [DecidableEq V] inlemma wordOfWalk_injective {r : ℕ} (hr : 0 < r) : Function.Injective (wordOfWalk (G := G) (r := r)) := by intro p q hpq obtain ⟨a,p,hp⟩ := p obtain ⟨b,q,hq⟩ := q have hword : (fun i : Fin r => p.getVert i.val) = (fun i : Fin r => q.getVert i.val) := Subtype.ext_iff.mp hpq have hab : a = b := by simpa using congrFun hword ⟨0,hr⟩ subst b apply congrArg (Sigma.mk a) apply Subtype.ext apply SimpleGraph.Walk.ext_getVert_le_length (hp.trans hq.symm) intro k hk by_cases hkr : k < r · exact congrFun hword ⟨k,hkr⟩ · have heq : k = r := by omega subst k simpa only [hp, hq] using p.getVert_length.trans q.getVert_length.symm
noncomputable def walkOfWord (n : ℕ) (f : closedWords G (n+3)) : closedWalkFamily G (n+3) := by let h : SimpleGraph.cycleGraph (n+3) →g G := ⟨f.val, by have hf := f.property simpa only [closedWords, Finset.mem_filter, Finset.mem_univ, true_and] using hf⟩ exact ⟨f.val 0, (SimpleGraph.cycleGraph.cycle n).map h, by change ((SimpleGraph.cycleGraph.cycle n).map h).length = n+3 rw [SimpleGraph.Walk.length_map, SimpleGraph.cycleGraph.length_cycle]⟩
omit [DecidableEq V] inlemma walkOfWord_injective (n : ℕ) : Function.Injective (walkOfWord G n) := by intro f g hfg apply Subtype.ext funext i let k := (SimpleGraph.cycleGraph.cycle n).support.idxOf i have hk := (SimpleGraph.cycleGraph.cycle n).getVert_support_idxOf (canonical_cycle_spanning n i) have hget := congrArg (fun w : closedWalkFamily G (n+3) => w.2.1.getVert k) hfg simpa [walkOfWord, SimpleGraph.Walk.getVert_map, k, hk] using hget
theorem trace_adjMatrix_eq_closedWords (n : ℕ) : Matrix.trace (G.adjMatrix ℕ ^ (n+3)) = (closedWords G (n+3)).card := by have hcard : Fintype.card (closedWalkFamily G (n+3)) = Fintype.card (closedWords G (n+3)) := le_antisymm (Fintype.card_le_of_injective _ (wordOfWalk_injective G (by omega))) (Fintype.card_le_of_injective _ (walkOfWord_injective G n)) rw [Fintype.card_coe] at hcard rw [← hcard, Fintype.card_sigma] simp only [Matrix.trace, Matrix.diag_apply, SimpleGraph.adjMatrix_pow_apply_eq_card_walk, Nat.cast_id] apply Finset.sum_congr rfl intro i hi exact Fintype.card_congr (Equiv.refl _)
lemma closedWords_card_eq (r : ℕ) : (closedWords G r).card = (graphEmbeddings (SimpleGraph.cycleGraph r) G).card + (nonsimpleWords G r).card := by classical have hfun : ((closedWords G r).filter Function.Injective) = (graphEmbeddings (SimpleGraph.cycleGraph r) G).image (fun (τ : Fin r ↪ V) => (τ : Fin r → V)) := by ext f simp only [Finset.mem_filter, closedWords, Finset.mem_univ, true_and, Finset.mem_image] constructor · rintro ⟨hf, hi⟩ exact ⟨⟨f,hi⟩, (mem_graphEmbeddings _).mpr hf, rfl⟩ · rintro ⟨τ,hτ,rfl⟩ exact ⟨(mem_graphEmbeddings τ).mp hτ, τ.injective⟩ have hc := Finset.card_filter_add_card_filter_not (s := closedWords G r) Function.Injective rw [hfun, Finset.card_image_of_injective _ (fun _ _ h => Function.Embedding.ext (congrFun h))] at hc exact hc.symm
theorem link_trace_count_bound (n : ℕ) (Δ C : ℕ) (hΔ0 : 1 ≤ Δ) (hΔ : ∀ x : V, (Finset.univ.filter (G.Adj x)).card ≤ Δ) (hcyc : ∀ b, 3 ≤ b → b < n+3 → (graphEmbeddings (SimpleGraph.cycleGraph b) G).card ≤ C * Δ ^ b) : Matrix.trace (G.adjMatrix ℕ ^ (n+3)) - (graphEmbeddings (SimpleGraph.cycleGraph (n+3)) G).card ≤ (n+3) ^ (n+4) * (Fintype.card V * Δ ^ ((n+3)/2) + C * Δ ^ (n+2)) := by rw [trace_adjMatrix_eq_closedWords, closedWords_card_eq, Nat.add_sub_cancel_left] exact nonsimpleWords_card_le G n Δ C hΔ0 hΔ hcyc
end TraceBridgeend SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120import Mathlibimport OAI.Combinatorics.TriangleRemoval.Embeddings.GraphEmbeddingsRestrictionimport OAI.Combinatorics.TriangleRemoval.Spectral.CountClosedWalk
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpaceopen scoped BigOperators
namespace SharpTerminalLeave
theorem canonical_cycle_spanning (n : ℕ) (v : Fin (n+3)) : v ∈ (SimpleGraph.cycleGraph.cycle n).support := by let f : Fin (n+3) → Fin (n+3) := fun i => (SimpleGraph.cycleGraph.cycle n).getVert i have hf : Function.Injective f := by intro i j hij apply Fin.ext exact SimpleGraph.cycleGraph.isCycle_cycle.getVert_injOn' (by simp only [Set.mem_ofPred_eq, SimpleGraph.cycleGraph.length_cycle]; omega) (by simp only [Set.mem_ofPred_eq, SimpleGraph.cycleGraph.length_cycle]; omega) hij obtain ⟨i, hi⟩ := Finite.surjective_of_injective hf v exact hi ▸ (SimpleGraph.cycleGraph.cycle n).getVert_mem_support i
section WalkPatternsvariable {r k : ℕ}
def closedWalkPattern (σ : Fin r → Fin k) : SimpleGraph (Fin k) := (SimpleGraph.cycleGraph r).map σ
def PatternProper (σ : Fin r → Fin k) : Prop := ∀ i j, (SimpleGraph.cycleGraph r).Adj i j → σ i ≠ σ j
noncomputable def patternHom (σ : Fin r → Fin k) (hσ : PatternProper σ) : SimpleGraph.cycleGraph r →g closedWalkPattern σ := SimpleGraph.Hom.map σ _ (fun hij => hσ _ _ hij)
@[simp] lemma patternHom_apply (σ : Fin r → Fin k) (hσ : PatternProper σ) (i : Fin r) : patternHom σ hσ i = σ i := rfl
lemma pattern_preconnected (σ : Fin r → Fin k) (hσ : PatternProper σ) (hs : Function.Surjective σ) : (closedWalkPattern σ).Preconnected := SimpleGraph.Preconnected.map (patternHom σ hσ) hs SimpleGraph.cycleGraph_preconnected
theorem pattern_spanning_walk {n k : ℕ} (σ : Fin (n+3) → Fin k) (hσ : PatternProper σ) (hs : Function.Surjective σ) : ∃ a : Fin k, ∃ p : (closedWalkPattern σ).Walk a a, p.length = n+3 ∧ ∀ v, v ∈ p.support := by let p := (SimpleGraph.cycleGraph.cycle n).map (patternHom σ hσ) refine ⟨σ 0, p, ?_, ?_⟩ · change ((SimpleGraph.cycleGraph.cycle n).map (patternHom σ hσ)).length = n+3 rw [SimpleGraph.Walk.length_map, SimpleGraph.cycleGraph.length_cycle] · intro v obtain ⟨i, rfl⟩ := hs v change σ i ∈ ((SimpleGraph.cycleGraph.cycle n).map (patternHom σ hσ)).support rw [SimpleGraph.Walk.support_map] exact List.mem_map.mpr ⟨i, canonical_cycle_spanning n i, rfl⟩
end WalkPatterns
section PatternCountingvariable {A V : Type*} [Fintype A] [DecidableEq A] [Fintype V] [DecidableEq V]variable (H : SimpleGraph A) (G : SimpleGraph V) [DecidableRel G.Adj]
theorem noninjective_pattern_count (r : ℕ) (hH : H.Preconnected) (hsize : Fintype.card A < r) (a : A) (p : H.Walk a a) (hlength : p.length = r) (hspan : ∀ v, v ∈ p.support) (Δ C : ℕ) (hΔ0 : 1 ≤ Δ) (hΔ : ∀ x : V, (Finset.univ.filter (G.Adj x)).card ≤ Δ) (hcyc : ∀ b, 3 ≤ b → b < r → (graphEmbeddings (SimpleGraph.cycleGraph b) G).card ≤ C * Δ ^ b) : (graphEmbeddings H G).card ≤ Fintype.card V * Δ ^ (r / 2) + C * Δ ^ (r-1) := by classical by_cases htree : H.IsAcyclic · have hv := acyclic_spanning_walk_vertices p htree hspan rw [hlength] at hv calc _ ≤ Fintype.card V * Δ ^ (Fintype.card A - 1) := connected_embedding_count H G hH a Δ hΔ _ ≤ Fintype.card V * Δ ^ (r/2) := Nat.mul_le_mul_left _ (Nat.pow_le_pow_right hΔ0 hv) _ ≤ _ := Nat.le_add_right _ _ · obtain ⟨v, c, hc⟩ : ∃ v : A, ∃ c : H.Walk v v, c.IsCycle := by simpa only [SimpleGraph.IsAcyclic, not_forall, not_not] using htree have hb : 3 ≤ c.length := hc.three_le_length obtain ⟨f⟩ := (SimpleGraph.cycleGraph_isContained_iff (by omega : 2 < c.length)).mpr ⟨v, c, hc, rfl⟩ have hcard : c.length ≤ Fintype.card A := by simpa using Fintype.card_le_of_injective f.toEmbedding f.injective have hh := cyclic_seed_embedding_count H G hH (SimpleGraph.cycleGraph c.length) f.toEmbedding (by exact Fin.pos_iff_nonempty.mp (by omega)) (fun i j hij => f.toHom.map_adj hij) Δ hΔ have hp : Δ ^ c.length * Δ ^ (Fintype.card A - c.length) = Δ ^ Fintype.card A := by rw [← pow_add, Nat.add_sub_of_le hcard] calc _ ≤ (graphEmbeddings (SimpleGraph.cycleGraph c.length) G).card * Δ ^ (Fintype.card A-c.length) := by simpa using hh _ ≤ (C * Δ ^ c.length) * Δ ^ (Fintype.card A-c.length) := Nat.mul_le_mul_right _ (hcyc _ hb (hcard.trans_lt hsize)) _ = C * Δ ^ Fintype.card A := by rw [mul_assoc, hp] _ ≤ C * Δ ^ (r-1) := Nat.mul_le_mul_left _ (Nat.pow_le_pow_right hΔ0 (by omega)) _ ≤ _ := Nat.le_add_left _ _
end PatternCountingend SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.ClosedWalkPattern
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpaceopen scoped BigOperators
namespace SharpTerminalLeavesection ClosedWordsvariable {V : Type*} [Fintype V] [DecidableEq V]variable (G : SimpleGraph V) [DecidableRel G.Adj]
noncomputable def closedWords (r : ℕ) : Finset (Fin r → V) := by classical exact Finset.univ.filter (fun f => ∀ i j, (SimpleGraph.cycleGraph r).Adj i j → G.Adj (f i) (f j))
noncomputable def nonsimpleWords (r : ℕ) : Finset (Fin r → V) := by classical exact (closedWords G r).filter (fun f => ¬Function.Injective f)
theorem nonsimple_word_factor {r : ℕ} {f : Fin r → V} (hf : f ∈ nonsimpleWords G r) : ∃ k : Fin r, ∃ σ : Fin r → Fin k.val, PatternProper σ ∧ Function.Surjective σ ∧ ∃ τ ∈ graphEmbeddings (closedWalkPattern σ) G, (fun i => τ (σ i)) = f := by classical have hfadj : ∀ i j, (SimpleGraph.cycleGraph r).Adj i j → G.Adj (f i) (f j) := by simpa only [nonsimpleWords, closedWords, Finset.mem_filter, Finset.mem_univ, true_and] using (Finset.mem_filter.mp hf).1 have hnot := (Finset.mem_filter.mp hf).2 let S := Finset.univ.image f have hcard : S.card < r := by have hle : S.card ≤ r := by simpa [S] using (Finset.card_image_le (s := Finset.univ) (f := f)) refine lt_of_le_of_ne hle ?_ intro heq apply hnot have hi : Set.InjOn f (↑(Finset.univ : Finset (Fin r))) := Finset.card_image_iff.mp (by simpa [S] using heq) exact fun i j hij => hi (by simp) (by simp) hij let e : S ≃ Fin S.card := (Fintype.equivFin S).trans (finCongr (Fintype.card_coe S)) let σ : Fin r → Fin S.card := fun i => e ⟨f i, Finset.mem_image.mpr ⟨i, by simp, rfl⟩⟩ let τ : Fin S.card ↪ V := e.symm.toEmbedding.trans (Function.Embedding.subtype _) have hτσ : ∀ i, τ (σ i) = f i := by intro i; simp [τ, σ] have hs : Function.Surjective σ := by intro a obtain ⟨i, _, hi⟩ := Finset.mem_image.mp (e.symm a).property refine ⟨i, ?_⟩ apply e.symm.injective apply Subtype.ext simpa [σ] using hi have hp : PatternProper σ := by intro i j hij heq exact (hfadj i j hij).ne (by rw [← hτσ i, ← hτσ j, heq]) refine ⟨⟨S.card, hcard⟩, σ, hp, hs, τ, ?_, funext hτσ⟩ apply (mem_graphEmbeddings τ).mpr intro a b hab obtain ⟨_, i, j, hij, hi, hj⟩ := hab subst a; subst b simpa only [hτσ] using hfadj i j hij
theorem nonsimpleWords_card_le (n : ℕ) (Δ C : ℕ) (hΔ0 : 1 ≤ Δ) (hΔ : ∀ x : V, (Finset.univ.filter (G.Adj x)).card ≤ Δ) (hcyc : ∀ b, 3 ≤ b → b < n+3 → (graphEmbeddings (SimpleGraph.cycleGraph b) G).card ≤ C * Δ ^ b) : (nonsimpleWords G (n+3)).card ≤ (n+3) ^ (n+4) * (Fintype.card V * Δ ^ ((n+3)/2) + C * Δ ^ (n+2)) := by classical let t : (k : Fin (n+3)) → Finset (Fin (n+3) → Fin k.val) := fun _ => Finset.univ.filter (fun σ => PatternProper σ ∧ Function.Surjective σ) let R := fun (k : Fin (n+3)) (σ : Fin (n+3) → Fin k.val) => (graphEmbeddings (closedWalkPattern σ) G).image (fun τ i => τ (σ i)) have hsub : nonsimpleWords G (n+3) ⊆ Finset.univ.biUnion (fun k => (t k).biUnion (R k)) := by intro f hf obtain ⟨k, σ, hp, hs, τ, hτ, rfl⟩ := nonsimple_word_factor G hf exact Finset.mem_biUnion.mpr ⟨k, by simp, Finset.mem_biUnion.mpr ⟨σ, by simp [t, hp, hs], Finset.mem_image.mpr ⟨τ, hτ, rfl⟩⟩⟩ let B := Fintype.card V * Δ ^ ((n+3)/2) + C * Δ ^ (n+2) have hR : ∀ k, ∀ σ ∈ t k, (R k σ).card ≤ B := by intro k σ hσ have hh : PatternProper σ ∧ Function.Surjective σ := by simpa only [t, Finset.mem_filter, Finset.mem_univ, true_and] using hσ obtain ⟨a, p, hp, hs⟩ := pattern_spanning_walk σ hh.1 hh.2 exact (Finset.card_image_le).trans (by simpa [B] using noninjective_pattern_count (closedWalkPattern σ) G (n+3) (pattern_preconnected σ hh.1 hh.2) (by simpa only [Fintype.card_fin] using k.isLt) a p hp hs Δ C hΔ0 hΔ hcyc) calc _ ≤ (Finset.univ.biUnion (fun k => (t k).biUnion (R k))).card := Finset.card_le_card hsub _ ≤ ∑ k : Fin (n+3), ∑ σ ∈ t k, (R k σ).card := by exact (Finset.card_biUnion_le).trans (Finset.sum_le_sum (fun k _ => Finset.card_biUnion_le)) _ ≤ ∑ k : Fin (n+3), (t k).card * B := by apply Finset.sum_le_sum intro k hk simpa using Finset.sum_le_sum (hR k) _ ≤ ∑ _k : Fin (n+3), (n+3)^(n+3) * B := by apply Finset.sum_le_sum intro k hk apply Nat.mul_le_mul_right B calc (t k).card ≤ Fintype.card (Fin (n+3) → Fin k.val) := Finset.card_le_univ _ _ = k.val^(n+3) := by simp _ ≤ (n+3)^(n+3) := Nat.pow_le_pow_left k.isLt.le _ _ = (n+3)^(n+4) * B := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, smul_eq_mul]; rw [show n+4 = (n+3)+1 by omega, pow_succ]; ring
end ClosedWordsend SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899import Mathlib
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpaceopen scoped BigOperators
namespace SharpTerminalLeave
variable {V : Type*} [DecidableEq V] {G : SimpleGraph V}
theorem bridge_count_closedWalk {a : V} (p : G.Walk a a) {e : Sym2 V} (he : e ∈ p.edges) (hb : G.IsBridge e) : 2 ≤ p.edges.count e := by classical induction e using Sym2.inductionOn with | _ x y => obtain ⟨i, hi, heq⟩ := (p.mk_mem_edges_iff_exists).mp he let q := p.drop i have hq : ¬ q.Nil := by rw [← SimpleGraph.Walk.length_eq_zero_iff] dsimp [q] rw [SimpleGraph.Walk.drop_length] omega have he' : s(p.getVert i, q.snd) = s(x,y) := by simpa only [q, SimpleGraph.Walk.snd, SimpleGraph.Walk.drop_getVert] using heq have hmem : s(p.getVert i, q.snd) ∈ (q.tail.append (p.take i)).edges := by have hh : G.IsBridge s(p.getVert i, q.snd) := he'.symm ▸ hb have hwalk := (SimpleGraph.isBridge_iff_forall_walk_mem_edges.mp hh) (q.tail.append (p.take i)).reverse simpa only [SimpleGraph.Walk.edges_reverse, List.mem_reverse] using hwalk have hcount : 1 ≤ (q.tail.append (p.take i)).edges.count s(x,y) := by exact List.one_le_count_iff.mpr (he' ▸ hmem) have hp : p.edges = (p.take i).edges ++ s(x,y) :: q.tail.edges := by conv_lhs => rw [← p.append_take_drop_eq i] rw [SimpleGraph.Walk.edges_append] change (p.take i).edges ++ q.edges = _ rw [← q.cons_tail_eq hq, SimpleGraph.Walk.edges_cons, he'] simp rw [SimpleGraph.Walk.edges_append, List.count_append] at hcount rw [hp, List.count_append, List.count_cons_self] omega
theorem acyclic_closedWalk_distinct_edges {a : V} (p : G.Walk a a) (hG : G.IsAcyclic) : 2 * p.edges.toFinset.card ≤ p.length := by classical have hh : ∀ e ∈ p.edges.toFinset, 2 ≤ p.edges.count e := by intro e he have he' := List.mem_toFinset.mp he exact bridge_count_closedWalk p he' ((SimpleGraph.isAcyclic_iff_forall_isBridge.mp hG) (p.edges_subset_edgeSet he')) calc _ = ∑ _e ∈ p.edges.toFinset, 2 := by simp [Nat.mul_comm] _ ≤ ∑ e ∈ p.edges.toFinset, p.edges.count e := Finset.sum_le_sum hh _ = p.edges.length := by exact List.sum_toFinset_count_eq_length _ _ = p.length := p.length_edges
theorem walk_support_card_le_edges {a b : V} (p : G.Walk a b) : p.support.toFinset.card ≤ p.edges.toFinset.card + 1 := by classical induction p with | nil => simp | @cons a b c hab p ih => simp only [SimpleGraph.Walk.support_cons, SimpleGraph.Walk.edges_cons, List.toFinset_cons] by_cases ha : a ∈ p.support.toFinset · rw [Finset.insert_eq_of_mem ha] exact ih.trans (Nat.add_le_add_right (Finset.card_le_card (Finset.subset_insert _ _)) 1) · have he : s(a,b) ∉ p.edges.toFinset := by intro he exact ha (List.mem_toFinset.mpr (p.fst_mem_support_of_mem_edges (List.mem_toFinset.mp he))) rw [Finset.card_insert_of_notMem ha, Finset.card_insert_of_notMem he] omega
theorem acyclic_spanning_walk_vertices [Fintype V] {a : V} (p : G.Walk a a) (hG : G.IsAcyclic) (hspan : ∀ v, v ∈ p.support) : Fintype.card V - 1 ≤ p.length / 2 := by have hc := acyclic_closedWalk_distinct_edges p hG have hv := walk_support_card_le_edges p have hs : p.support.toFinset = Finset.univ := by exact Finset.eq_univ_iff_forall.mpr (fun v => List.mem_toFinset.mpr (hspan v)) rw [hs, Finset.card_univ] at hv omega
end SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111import Mathlibimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixCodegreeDriftTermimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixBalancedNoiseimport OAI.Combinatorics.TriangleRemoval.Spectral.WheelSpokeimport OAI.Combinatorics.TriangleRemoval.Embeddings.DegreeTemplate
namespace OAI
sectionnoncomputable sectionopen scoped BigOperators Matrix.Norms.L2Operatoropen Filter Classical
namespace SharpTerminalLeave
theorem density_global_spectral {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (D c : ℝ) (hD : prefixD n ≤ D) (hDmin : 1 ≤ prefixD n) (hδ : (n : ℝ)^(-c) ≤ 1) (hne : ∀ u, (neighbors G u).Nonempty) (hrow : ∀ u v : Fin n, {u,v} ∈ G → |(currentCodegree G u v : ℝ)-D| ≤ (n : ℝ)^(-c)*D) (hcyc : ∀ j, 3 ≤ j → j ≤ 8000 → ∀ u : Fin n, |linkCycleCount j G u-D^j| ≤ (n : ℝ)^(-c)*D^j) : ‖D⁻¹ • globalLinkAdjacency G hG-globalStarAverage G‖ ≤ 2*prefixSpectralError n c := by have hD1 : 1 ≤ D := hDmin.trans hD have hD0 : 0 < D := lt_of_lt_of_le zero_lt_one hD1 have hd0 : 0 ≤ (n : ℝ)^(-c) := Real.rpow_nonneg (Nat.cast_nonneg _) _ let M (u : Fin n) : Matrix (neighbors G u) (neighbors G u) ℝ := D⁻¹ • (linkSimpleGraph G hG u).adjMatrix ℝ-averagingProjector let N (u : Fin n) : Matrix (edgeStar G u) (edgeStar G u) ℝ := Matrix.reindex (neighborEdgeEquiv G hG u) (neighborEdgeEquiv G hG u) (M u) have hM : ∀ u, (M u).IsHermitian := by intro u exact ((linkSimpleGraph G hG u).isHermitian_adjMatrix ℝ).smul (isSelfAdjoint_iff.mpr rfl) |>.sub averagingProjector_hermitian have hlocal : ∀ u, ‖N u‖ ≤ prefixSpectralError n c := by intro u have : Nonempty (neighbors G u) := (hne u).to_subtype apply (hermitian_reindex_norm_le _ _ (hM u)).trans have hr : ∀ v : neighbors G u, |((Finset.univ.filter ((linkSimpleGraph G hG u).Adj v)).card : ℝ)-D| ≤ (n : ℝ)^(-c)*D := by intro v rw [link_degree_eq G hG u v] exact hrow u v.val (Finset.mem_filter.mp v.property).2 have hm := hcyc 8000 (by decide) le_rfl u rw [linkCycleCount_eq_graphEmbeddings (j := 7998) G hG u] at hm have hc : ∀ b, 3 ≤ b → b < 8000 → ((graphEmbeddings (SimpleGraph.cycleGraph b) (linkSimpleGraph G hG u)).card : ℝ) ≤ 2*D^b := by intro b hb hb' have hh := (abs_le.mp (hcyc b hb hb'.le u)).2 have he : b = b-2+2 := by omega have hcount : linkCycleCount b G u = ((graphEmbeddings (SimpleGraph.cycleGraph b) (linkSimpleGraph G hG u)).card : ℝ) := by rw [he] exact linkCycleCount_eq_graphEmbeddings G hG u rw [hcount] at hh have hx := mul_le_mul_of_nonneg_right hδ (pow_nonneg hD0.le b) nlinarith have hh := graph_star_approximation (linkSimpleGraph G hG u) 7997 (by decide) D ((n : ℝ)^(-c)) hD1 hd0 hδ hr hm hc apply hh.trans have hn : (Fintype.card (neighbors G u) : ℝ) ≤ n := by exact_mod_cast (show Fintype.card (neighbors G u) ≤ n by simpa using (neighbors G u).card_le_univ) change 4*((8001 : ℝ)*(n : ℝ)^(-c)+(8000 : ℝ)^8001*2^8000* ((Fintype.card (neighbors G u) : ℝ)/D^4000+1/D))^(1/(8000 : ℝ))+7*(n : ℝ)^(-c) ≤ _ unfold prefixSpectralError gcongr have hsplit : D⁻¹ • globalLinkAdjacency G hG-globalStarAverage G = ∑ u, extendStar (edgeStar G u) (N u) := by simp only [globalLinkAdjacency,globalStarAverage,Finset.smul_sum,← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro u _ have he : N u = D⁻¹ • linkStarMatrix G hG u-averagingProjector := by ext i j simp only [N,M,linkStarMatrix,Matrix.reindex_apply,Matrix.submatrix_apply, Matrix.sub_apply,Matrix.smul_apply,averagingProjector] rw [Fintype.card_congr (neighborEdgeEquiv G hG u)] rw [he] simp [extendStar,Matrix.mul_sub,Matrix.sub_mul,Matrix.smul_mul,Matrix.mul_smul] rw [hsplit] exact graph_star_error_norm G hG N (fun u => (Matrix.isHermitian_reindex_iff _).mpr (hM u)) (prefixSpectralError n c) (prefixSpectralError_nonneg n c (zero_le_one.trans hDmin)) hlocal
theorem prefix_degree_wheel_tracking : ∀ᶠ n : ℕ in atTop, ∀ ω : History (Graph n) (prefixTime n), ω ∈ (historyLaw (PMF.pure (completeGraph n)) (fun _ => step) (prefixTime n) (prefixTime n)).support → PrefixRootedUpper 8001 n ω → PrefixBalancedNoise 8001 n ω → ∀ i ≤ prefixTime n, historyAlive (fun j => densityEdgeSafe n (earlyDensity n j) (prefixEdgeRadius n)) (prefixTime n) i ω → (∀ u : Fin n, |(currentDegree (ω (historyIndex (prefixTime n) i)) u : ℝ)/ ((n : ℝ)*earlyDensity n i)-1| ≤ prefixWheelRadius n/2) ∧ (∀ j, 3 ≤ j → j ≤ 8000 → ∀ u : Fin n, |linkCycleCount j (ω (historyIndex (prefixTime n) i)) u/ ((n : ℝ)*earlyDensity n i^2)^j-1| ≤ prefixWheelRadius n/2) := by filter_upwards [prefix_balanced_tracking 8001] with n hn intro ω hω hu hnse i hi hs have hG : ω (historyIndex (prefixTime n) i) ⊆ completeGraph n := complete_history_valid ω hω i hi constructor · intro u have h := hn ω hω hu hnse i hi hs 2 (by decide) degreeTemplate degreeTemplate_balanced (degreeRoot u) rwa [degree_rootedCount _ hG,degree_rootedScaling] at h · intro j hj hj' u have h := hn ω hω hu hnse i hi hs (j+1) (by omega) (wheelTemplate j hj) (wheelTemplate_balanced j hj) (wheelRoot hj u) rwa [wheel_rootedCount hj _ hG,wheel_rootedScaling] at h
end SharpTerminalLeaveendend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import Mathlibimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixEpsilonimport OAI.Combinatorics.TriangleRemoval.Spectral.StarInclusion
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrix InnerProductSpaceopen scoped BigOperatorsopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix
namespace SharpTerminalLeave
def edgeStar {n : ℕ} (G : Graph n) (u : Fin n) : Finset G := Finset.univ.filter (fun e => u ∈ e.val)
@[simp] theorem mem_edgeStar {n : ℕ} (G : Graph n) (u : Fin n) (e : G) : e ∈ edgeStar G u ↔ u ∈ e.val := by simp [edgeStar]
def neighborEdge {n : ℕ} (G : Graph n) (u : Fin n) (v : neighbors G u) : edgeStar G u := ⟨⟨{u,v.val},(Finset.mem_filter.mp v.property).2⟩,by simp⟩
theorem neighborEdge_injective {n : ℕ} (G : Graph n) (u : Fin n) : Function.Injective (neighborEdge G u) := by intro v w h have he : ({u,v.val} : Finset (Fin n)) = {u,w.val} := congrArg (fun e => e.val.val) h have hv : v.val ∈ ({u,w.val} : Finset (Fin n)) := he ▸ (by simp) have hw : w.val ∈ ({u,v.val} : Finset (Fin n)) := he.symm ▸ (by simp) simp only [Finset.mem_insert,Finset.mem_singleton] at hv hw apply Subtype.ext rcases hv with hv | hv · rcases hw with hw | hw · exact hv.trans hw.symm · exact hw.symm · exact hv
theorem neighborEdge_surjective {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (u : Fin n) : Function.Surjective (neighborEdge G u) := by intro e obtain ⟨a,b,hab,he⟩ := Finset.card_eq_two.mp (mem_completeGraph.mp (hG e.val.property)) have hu : u ∈ e.val.val := (mem_edgeStar G u e.val).mp e.property rw [he] at hu simp only [Finset.mem_insert,Finset.mem_singleton] at hu have hm : ({a,b} : Finset (Fin n)) ∈ G := he ▸ e.val.property rcases hu with rfl | rfl · refine ⟨⟨b,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hm⟩⟩,?_⟩ apply Subtype.ext apply Subtype.ext exact he.symm · refine ⟨⟨a,Finset.mem_filter.mpr ⟨Finset.mem_univ _,?_⟩⟩,?_⟩ · simpa only [Finset.pair_comm] using hm · apply Subtype.ext apply Subtype.ext exact (Finset.pair_comm _ _).trans he.symm
noncomputable def neighborEdgeEquiv {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (u : Fin n) : neighbors G u ≃ edgeStar G u := Equiv.ofBijective (neighborEdge G u) ⟨neighborEdge_injective G u,neighborEdge_surjective G hG u⟩
theorem edgeStar_card {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (u : Fin n) : (edgeStar G u).card = currentDegree G u := by have h := Fintype.card_congr (neighborEdgeEquiv G hG u) simpa only [Fintype.card_coe,currentDegree] using h.symm
theorem edgeStar_exact_overlap {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (e : G) : (Finset.univ.filter fun u => e ∈ edgeStar G u).card = 2 := by have he : (Finset.univ.filter fun u => e ∈ edgeStar G u) = e.val := by ext u simp rw [he] exact mem_completeGraph.mp (hG e.property)
open scoped Matrix.Norms.L2Operator in
theorem graph_star_error_norm {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (M : (u : Fin n) → Matrix (edgeStar G u) (edgeStar G u) ℝ) (hM : ∀ u, (M u).IsHermitian) (ε : ℝ) (hε : 0 ≤ ε) (hlocal : ∀ u, ‖M u‖ ≤ ε) : ‖∑ u, extendStar (edgeStar G u) (M u)‖ ≤ 2*ε := by apply sum_star_norm_bound _ _ hM ε 2 hε (by norm_num) hlocal intro e rw [edgeStar_exact_overlap G hG e] norm_num
end SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.StarInclusion
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrix InnerProductSpaceopen scoped BigOperatorsopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix
namespace SharpTerminalLeave
variable {E : Type*} [Fintype E] [DecidableEq E]
omit [Fintype E] in
theorem extendStar_apply (S : Finset E) (M : Matrix S S ℝ) (i j : E) : extendStar S M i j = if hi : i ∈ S then if hj : j ∈ S then M ⟨i,hi⟩ ⟨j,hj⟩ else 0 else 0 := by simp only [extendStar,Matrix.mul_apply,Matrix.conjTranspose_apply,starInclusion, star_trivial] by_cases hi : i ∈ S · by_cases hj : j ∈ S · have hei : ∀ x : S, i = x.val ↔ x = ⟨i,hi⟩ := fun x => by rw [Subtype.ext_iff] exact eq_comm have hej : ∀ x : S, j = x.val ↔ x = ⟨j,hj⟩ := fun x => by rw [Subtype.ext_iff] exact eq_comm simp [hi,hj,hei,hej] · have hej : ∀ x : S, j ≠ x.val := fun x hx => hj (hx.symm ▸ x.property) simp [hi,hj,hej] · have hei : ∀ x : S, i ≠ x.val := fun x hx => hi (hx.symm ▸ x.property) simp [hi,hei]
end SharpTerminalLeave
open scoped BigOperators Topology NNReal Matrix.Norms.Operatoropen MeasureTheory
endend
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.LinkStarMatriximport OAI.Combinatorics.TriangleRemoval.Process.CompleteEdge
namespace OAI
sectionnoncomputable sectionopen scoped BigOperatorsopen Classical Matrix
namespace SharpTerminalLeave
lemma extendStar_mulVec_apply {E : Type*} [Fintype E] [DecidableEq E] (S : Finset E) (M : Matrix S S ℝ) (z : E → ℝ) (e : E) : (extendStar S M *ᵥ z) e = if he : e ∈ S then (M *ᵥ fun f : S => z f.val) ⟨e,he⟩ else 0 := by rw [extendStar,← Matrix.mulVec_mulVec,← Matrix.mulVec_mulVec,starInclusion_mulVec] simp only [Matrix.mulVec,dotProduct,starInclusion] by_cases he : e ∈ S · have hh : ∀ f : S, e = f.val ↔ f = ⟨e,he⟩ := fun f => by rw [Subtype.ext_iff]; exact eq_comm simp [he,hh] · have hh : ∀ f : S, e ≠ f.val := fun f hf => he (hf.symm ▸ f.property) simp [he,hh]
lemma extendStar_average_apply {E : Type*} [Fintype E] [DecidableEq E] (S : Finset E) (z : E → ℝ) (e : E) : (extendStar S averagingProjector *ᵥ z) e = if e ∈ S then (∑ f ∈ S, z f)/(S.card : ℝ) else 0 := by rw [extendStar_mulVec_apply] split_ifs with he · simp only [Matrix.mulVec,dotProduct,averagingProjector,Fintype.card_coe] rw [← Finset.mul_sum,Finset.sum_coe_sort] ring · rfl
lemma graphActive_star_sum {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (x : CompleteEdge n → ℝ) (u : Fin n) : (∑ e ∈ (graphActive G).filter (fun e => u ∈ e.val), x e) = ∑ e ∈ edgeStar G u, graphRestrict G hG x e := by rw [Finset.sum_filter] rw [graphActive_sum G hG] simp only [edgeStar,Finset.sum_filter] rfl
lemma graphActive_star_card {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (u : Fin n) : ((graphActive G).filter (fun e => u ∈ e.val)).card = (edgeStar G u).card := by have hh := graphActive_star_sum G hG (fun _ => 1) u simpa only [graphRestrict,LinearMap.coe_mk,AddHom.coe_mk,Finset.sum_const,nsmul_eq_mul,mul_one, Nat.cast_inj] using hh
lemma graph_movingStarMean {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (x : CompleteEdge n → ℝ) (u : Fin n) : movingStarMean (fun e : CompleteEdge n => e.val) (graphActive G) x u = (∑ e ∈ edgeStar G u, graphRestrict G hG x e)/(edgeStar G u).card := by unfold movingStarMean movingStarDegree congr 1 · convert graphActive_star_sum G hG x u using 1 congr 1 ext e simp · convert congrArg (Nat.cast : ℕ → ℝ) (graphActive_star_card G hG u) using 1 congr 2 ext e simp
lemma graph_movingStarLift {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (x : CompleteEdge n → ℝ) (e : CompleteEdge n) (he : e ∈ graphActive G) : movingStarLift (fun e : CompleteEdge n => e.val) (movingStarMean (fun e : CompleteEdge n => e.val) (graphActive G) x) e = graphMatrixLift G hG (globalStarAverage G) x e := by have heG : e.val ∈ G := (mem_graphActive G e).mp he change (∑ u ∈ e.val, _) = (graphExtend G (globalStarAverage G *ᵥ graphRestrict G hG x)) e simp only [graphExtend,LinearMap.coe_mk,AddHom.coe_mk,dite_eq_left heG] rw [globalStarAverage,Matrix.sum_mulVec] simp only [Finset.sum_apply,extendStar_average_apply,mem_edgeStar] rw [← Finset.sum_filter] have heq : Finset.univ.filter (fun u => u ∈ e.val) = e.val := by ext; simp rw [heq] exact Finset.sum_congr rfl (fun u _ => graph_movingStarMean G hG x u)
end SharpTerminalLeaveendend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130import Mathlibimport OAI.Combinatorics.TriangleRemoval.Coupling.UnitTime
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
lemma fallingFactorial_normalized_product (r a n : ℕ) (hn : r+a ≤ n) (hn0 : 0 < n) : ((n-r).descFactorial a : ℝ)/(n : ℝ)^a = ∏ i ∈ Finset.range a, (1-((r+i : ℕ) : ℝ)/(n : ℝ)) := by have hnR : (0 : ℝ) < n := by exact_mod_cast hn0 rw [Nat.descFactorial_eq_prod_range,Nat.cast_prod] have hh : (n : ℝ)^a = ∏ _i ∈ Finset.range a, (n : ℝ) := by simp rw [hh,← Finset.prod_div_distrib] apply Finset.prod_congr rfl intro i hi have hri : r+i ≤ n := by have := Finset.mem_range.mp hi; omega rw [Nat.sub_sub,Nat.cast_sub hri] field_simp
theorem fallingFactorial_normalized_error (r a n : ℕ) (hn : r+a ≤ n) (hn0 : 0 < n) : |((n-r).descFactorial a : ℝ)/(n : ℝ)^a-1| ≤ (a : ℝ)*(r+a : ℕ)/(n : ℝ) := by have hnR : (0 : ℝ) < n := by exact_mod_cast hn0 rw [fallingFactorial_normalized_product r a n hn hn0] let f := fun i : ℕ => 1-((r+i : ℕ) : ℝ)/(n : ℝ) have hf : ∀ i ∈ Finset.range a, f i ∈ Set.Icc (0 : ℝ) 1 := by intro i hi have hri : r+i ≤ n := by have := Finset.mem_range.mp hi; omega have h0 : 0 ≤ ((r+i : ℕ) : ℝ)/(n : ℝ) := by positivity have h1 : ((r+i : ℕ) : ℝ)/(n : ℝ) ≤ 1 := by apply (div_le_one hnR).mpr exact_mod_cast hri exact ⟨by dsimp [f]; linarith,by dsimp [f]; linarith⟩ have hh := abs_prod_sub_prod_le_sum (Finset.range a) f (fun _ => 1) hf (fun _ _ => ⟨zero_le_one,le_rfl⟩) simp only [Finset.prod_const_one] at hh apply hh.trans calc (∑ i ∈ Finset.range a, |f i-1|) = ∑ i ∈ Finset.range a, ((r+i : ℕ) : ℝ)/(n : ℝ) := by apply Finset.sum_congr rfl intro i _ dsimp [f] have h0 : 0 ≤ ((r+i : ℕ) : ℝ)/(n : ℝ) := by positivity rw [show 1-((r+i : ℕ) : ℝ)/(n : ℝ)-1 = -(((r+i : ℕ) : ℝ)/(n : ℝ)) by ring, abs_neg,abs_of_nonneg h0] _ ≤ ∑ _i ∈ Finset.range a, ((r+a : ℕ) : ℝ)/(n : ℝ) := by apply Finset.sum_le_sum intro i hi apply div_le_div_of_nonneg_right _ hnR.le exact_mod_cast (by have := Finset.mem_range.mp hi; omega : r+i ≤ r+a) _ = _ := by simp; ring
theorem initialDensity_power_error (b n : ℕ) (hn : 1 ≤ n) : |(1-1/(n : ℝ))^b-1| ≤ (b : ℝ)/(n : ℝ) := by have hnR : (1 : ℝ) ≤ n := by exact_mod_cast hn have hp0 : 0 ≤ 1-1/(n : ℝ) := by have : 1/(n : ℝ) ≤ 1 := by apply (div_le_one (by linarith)).mpr; exact hnR linarith have hp1 : 1-1/(n : ℝ) ≤ 1 := by have : 0 ≤ 1/(n : ℝ) := by positivity linarith have hh := abs_prod_sub_prod_le_sum (Finset.range b) (fun _ => 1-1/(n : ℝ)) (fun _ => 1) (fun _ _ => ⟨hp0,hp1⟩) (fun _ _ => ⟨zero_le_one,le_rfl⟩) simpa only [Finset.prod_const,Finset.card_range,one_pow, show 1-1/(n : ℝ)-1 = -(1/(n : ℝ)) by ring,abs_neg, abs_of_nonneg (by positivity : 0 ≤ 1/(n : ℝ)),Finset.sum_const, nsmul_eq_mul,mul_one_div] using hh
theorem initialRootedScaling_error (r a b n : ℕ) (hn : r+a ≤ n) (hn2 : 2 ≤ n) : |((n-r).descFactorial a : ℝ) / ((n : ℝ)^a * (1-1/(n : ℝ))^b)-1| ≤ (2 : ℝ)^b * ((a : ℝ)*(r+a : ℕ)+(b : ℝ))/(n : ℝ) := by have hnR : (2 : ℝ) ≤ n := by exact_mod_cast hn2 have hn0 : 0 < n := by omega have hnR0 : (0 : ℝ) < n := by linarith have hp : (1/2 : ℝ) ≤ 1-1/(n : ℝ) := by have hh : 1/(n : ℝ) ≤ 1/2 := (div_le_div_iff₀ hnR0 (by norm_num)).mpr (by linarith) linarith have hp0 : 0 < (1-1/(n : ℝ))^b := pow_pos (by linarith) _ have hi : 1/(1-1/(n : ℝ))^b ≤ (2 : ℝ)^b := by have hh := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 1/2) hp b have hh2 : (1/2 : ℝ)^b = 1/(2 : ℝ)^b := by rw [div_pow,one_pow] rw [hh2] at hh exact (div_le_iff₀ hp0).mpr (by have ht : (0 : ℝ) < (2 : ℝ)^b := by positivity have hmul := (div_le_iff₀ ht).mp hh simpa only [mul_comm] using hmul) have hf := fallingFactorial_normalized_error r a n hn hn0 have ht := initialDensity_power_error b n (by omega) have he : |((n-r).descFactorial a : ℝ) / ((n : ℝ)^a*(1-1/(n : ℝ))^b)-1| = |((n-r).descFactorial a : ℝ)/(n : ℝ)^a-(1-1/(n : ℝ))^b| / (1-1/(n : ℝ))^b := by calc _ = |(((n-r).descFactorial a : ℝ)/(n : ℝ)^a-(1-1/(n : ℝ))^b) / (1-1/(n : ℝ))^b| := by rw [sub_div,div_self (ne_of_gt hp0),div_div] _ = _ := by rw [abs_div,abs_of_pos hp0] rw [he,div_eq_mul_inv] have he2 : |((n-r).descFactorial a : ℝ)/(n : ℝ)^a-(1-1/(n : ℝ))^b| ≤ ((a : ℝ)*(r+a : ℕ)+(b : ℝ))/(n : ℝ) := by calc _ ≤ |((n-r).descFactorial a : ℝ)/(n : ℝ)^a-1| + |(1-1/(n : ℝ))^b-1| := by simpa only [abs_sub_comm (1 : ℝ)] using (abs_sub_le (((n-r).descFactorial a : ℝ)/(n : ℝ)^a) 1 ((1-1/(n : ℝ))^b)) _ ≤ (a : ℝ)*(r+a : ℕ)/(n : ℝ)+(b : ℝ)/(n : ℝ) := add_le_add hf ht _ = _ := by ring calc _ ≤ (((a : ℝ)*(r+a : ℕ)+(b : ℝ))/(n : ℝ)) * (2 : ℝ)^b := mul_le_mul he2 (by simpa only [one_div] using hi) (inv_nonneg.mpr hp0.le) (by positivity) _ = _ := by ring
end SharpTerminalLeave
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.MapOutput
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeave.ExposureTreevariable {K V R : Type*}
theorem freshLog_checkNoneTrace_forall (ν : K → PMF V) (P : R → Prop) (as : List (ExposureTree K V (Bool × List R))) (ha : ∀ A ∈ as, ∀ z ∈ (freshLog ν A).support, ∀ c ∈ z.1.2, P c) {z : (Bool × List R) × List K} (hz : z ∈ (freshLog ν (checkNoneTrace as)).support) : ∀ c ∈ z.1.2, P c := by induction as generalizing z with | nil => have heq : z = ((true,[]),[]) := by simpa [checkNoneTrace,freshLog] using hz simp [heq] | cons A as ih => rw [checkNoneTrace, freshLog_bind] at hz obtain ⟨x,hx,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz have hxP := ha A (by simp) x hx have has (B) (hB : B ∈ as) := ha B (by simp [hB]) cases hb : x.1.1 · simp only [hb, Bool.false_eq_true, ↓reduceIte, freshLog_mapOutput] at hy obtain ⟨w,hw,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hy intro c hc rcases List.mem_append.mp hc with hc | hc · exact hxP c hc · exact ih has hw c hc · simp only [hb, ↓reduceIte, freshLog, PMF.mem_support_pure_iff] at hy subst y exact hxP
end SharpTerminalLeave.ExposureTree
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.FreshLogCheckNone
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeave.ExposureTreevariable {K V R : Type*}
theorem freshLog_checkNoneTrace_pairwise (ν : K → PMF V) (rel : R → R → Prop) (as : List (ExposureTree K V (Bool × List R))) (ha : ∀ A ∈ as, ∀ z ∈ (freshLog ν A).support, z.1.2.Pairwise rel) (hab : as.Pairwise (fun A B => ∀ x ∈ (freshLog ν A).support, ∀ y ∈ (freshLog ν B).support, ∀ c ∈ x.1.2, ∀ d ∈ y.1.2, rel c d)) {z : (Bool × List R) × List K} (hz : z ∈ (freshLog ν (checkNoneTrace as)).support) : z.1.2.Pairwise rel := by induction as generalizing z with | nil => have heq : z = ((true,[]),[]) := by simpa [checkNoneTrace,freshLog] using hz simp [heq] | cons A as ih => obtain ⟨hhead,htail⟩ := List.pairwise_cons.mp hab rw [checkNoneTrace, freshLog_bind] at hz obtain ⟨x,hx,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz have hxR := ha A (by simp) x hx have has (B) (hB : B ∈ as) := ha B (by simp [hB]) cases hb : x.1.1 · simp only [hb, Bool.false_eq_true, ↓reduceIte, freshLog_mapOutput] at hy obtain ⟨w,hw,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hy apply List.pairwise_append.mpr refine ⟨hxR, ih has htail hw, ?_⟩ intro c hc exact freshLog_checkNoneTrace_forall ν (rel c) as (fun B hB y hy' d hd => hhead B hB x hx y hy' c hc d hd) hw · simp only [hb, ↓reduceIte, freshLog, PMF.mem_support_pure_iff] at hy subst y exact hxR
end SharpTerminalLeave.ExposureTree
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.MapOutput
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen Filter MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave.ExposureTreevariable {K V R : Type*}
theorem freshLog_checkNoneTrace_append (ν : K → PMF V) (P : List R → Prop) (h0 : P []) (happend : ∀ a b, P a → P b → P (a ++ b)) (as : List (ExposureTree K V (Bool × List R))) (ha : ∀ A ∈ as, ∀ z ∈ (freshLog ν A).support, P z.1.2) {z : (Bool × List R) × List K} (hz : z ∈ (freshLog ν (checkNoneTrace as)).support) : P z.1.2 := by induction as generalizing z with | nil => have he : z = ((true,[]),[]) := by simpa [checkNoneTrace,freshLog] using hz simpa only [he] using h0 | cons A as ih => rw [checkNoneTrace, freshLog_bind] at hz obtain ⟨x,hx,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz have hxa := ha A (by simp) x hx have has (B) (hB : B ∈ as) := ha B (by simp [hB]) cases hb : x.1.1 · simp only [hb,Bool.false_eq_true,↓reduceIte,freshLog_mapOutput] at hy obtain ⟨w,hw,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hy exact happend _ _ hxa (ih has hw) · simp only [hb,↓reduceIte,freshLog,PMF.mem_support_pure_iff] at hy subst y exact hxa
end SharpTerminalLeave.ExposureTree
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.EdgeIncidenceimport OAI.Combinatorics.TriangleRemoval.Process.AveragingProjectorInftyOneimport OAI.Combinatorics.TriangleRemoval.Spectral.MatrixEuclideanAlgHom
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheory
namespace SharpTerminalLeaveopen scoped Matrix.Norms.Operator
theorem globalLinkAdjacency_hermitian {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) : (globalLinkAdjacency G hG).IsHermitian := by apply Matrix.IsHermitian.ext intro i j simp only [globalLinkAdjacency,Matrix.sum_apply] apply Finset.sum_congr rfl intro u _ exact (Matrix.isHermitian_mul_mul_conjTranspose (starInclusion (edgeStar G u)) ((Matrix.isHermitian_reindex_iff _).mpr ((linkSimpleGraph G hG u).isHermitian_adjMatrix ℝ))).apply i j
theorem goodPrefix_semigroup_quantitative {n : ℕ} [NeZero n] {G : Graph n} [Nonempty G] {c C : ℝ} (h : GoodPrefixGraph n c C G) (hne : ∀ u, (neighbors G u).Nonempty) (hD : 1 ≤ prefixD n) (hδ : (n : ℝ)^(-c) ≤ 1) (T : ℝ) (hT : 0 ≤ T) (K : ℕ) (s : ℝ) (hs : s ∈ Set.Icc (0 : ℝ) T) : ‖NormedSpace.exp ((-s) • ((prefixD n)⁻¹ • globalLinkAdjacency G h.1))‖ ≤ (∑ j ∈ Finset.range K, ((1+2*T)*6*T)^j*(1+2*T)) + Real.sqrt G.card * ((2*prefixSpectralError n c*T)^K * Real.exp (T*(2*prefixSpectralError n c))) := by let P := globalStarAverage G let R := (prefixD n)⁻¹ • globalLinkAdjacency G h.1 - P let ε := 2*prefixSpectralError n c have hε : 0 ≤ ε := mul_nonneg (by norm_num) (prefixSpectralError_nonneg n c (le_trans zero_le_one hD)) have hPR : P+R = (prefixD n)⁻¹ • globalLinkAdjacency G h.1 := by dsimp [R]; abel have hP : P.PosSemidef := globalStarAverage_posSemidef G have hR : IsSelfAdjoint R := by exact ((globalLinkAdjacency_hermitian G h.1).smul (isSelfAdjoint_iff.mpr rfl) |>.sub hP.isHermitian).isSelfAdjoint have hR₂ : ‖matrixEuclideanAlgHom R‖ ≤ ε := goodPrefix_global_spectral h hne hD hδ have hRinf : ‖R‖ ≤ 6 := goodPrefix_residual_infty h hD hδ have hF : Continuous (matrixEuclideanAlgHom (I := G)) := (matrixEuclideanAlgHom (I := G)).toLinearMap.continuous_of_finiteDimensional have hb : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖NormedSpace.exp ((-t) • P)‖ ≤ 1+2*T := by intro t ht have hdeg : ∀ u, 0 < currentDegree G u := fun u => Finset.card_pos.mpr (hne u) exact (graph_star_semigroup_bound G h.1 hdeg t ht.1).trans (by linarith [ht.2]) have hb₂ : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖NormedSpace.exp ((-t) • matrixEuclideanAlgHom P)‖ ≤ 1 := fun t ht => euclidean_posSemidef_exp_bound P hP t ht.1 have hf₂ : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖NormedSpace.exp ((-t) • (matrixEuclideanAlgHom P + matrixEuclideanAlgHom R))‖ ≤ Real.exp (T*ε) := by intro t ht apply (euclidean_perturbed_exp_bound P R hP hR t ht.1).trans apply Real.exp_le_exp.mpr exact (mul_le_mul_of_nonneg_left hR₂ ht.1).trans (mul_le_mul_of_nonneg_right ht.2 hε) let : CompleteSpace (EuclideanSpace ℝ G) := PiLp.completeSpace 2 (fun _ : G => ℝ) let : CompleteSpace (EuclideanSpace ℝ G →L[ℝ] EuclideanSpace ℝ G) := ContinuousLinearMap.instCompleteSpace have hh := perturbation_mixed_norm_bound (matrixEuclideanAlgHom (I := G)) hF P R T (1+2*T) (Real.exp (T*ε)) (Real.sqrt G.card) hT (by positivity) (by positivity) (by positivity) (by simpa only [Fintype.card_coe] using (matrix_infty_le_sqrt_card_euclidean (I := G))) hb hb₂ hf₂ K s hs rw [hPR] at hh apply hh.trans apply add_le_add · apply Finset.sum_le_sum intro j _ gcongr · gcongr
end SharpTerminalLeave
open Filteropen scoped BigOperators Topology
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.NormalizedOnesimport OAI.Combinatorics.TriangleRemoval.Spectral.RealTraceAdjMatrix
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpaceopen scoped BigOperators
namespace SharpTerminalLeaveopen scoped BigOperators Matrix.Norms.L2Operator
section GraphStarvariable {V : Type*} [Fintype V] [DecidableEq V] [Nonempty V]variable (G : SimpleGraph V) [DecidableRel G.Adj]
theorem graph_star_approximation (n : ℕ) (hr : Even (n+3)) (D δ : ℝ) (hD : 1 ≤ D) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) (hrow : ∀ x : V, |((Finset.univ.filter (G.Adj x)).card : ℝ) - D| ≤ δ*D) (hmain : |((graphEmbeddings (SimpleGraph.cycleGraph (n+3)) G).card : ℝ) - D^(n+3)| ≤ δ * D^(n+3)) (hcyc : ∀ b, 3 ≤ b → b < n+3 → ((graphEmbeddings (SimpleGraph.cycleGraph b) G).card : ℝ) ≤ 2 * D^b) : ‖D⁻¹ • G.adjMatrix ℝ - averagingProjector‖ ≤ 4 * (((n+4 : ℕ) : ℝ) * δ + ((n+3 : ℕ) : ℝ)^(n+4) * 2^(n+3) * ((Fintype.card V : ℝ) / D^((n+3)/2) + 1/D)) ^ (1 / ((n+3 : ℕ) : ℝ)) + 7*δ := by have hD0 : 0 < D := lt_of_lt_of_le zero_lt_one hD have hDne : D ≠ 0 := ne_of_gt hD0 let W : ℝ := ((n+3 : ℕ) : ℝ)^(n+4) * 2^(n+3) * ((Fintype.card V : ℝ) / D^((n+3)/2) + 1/D) let E : ℝ := ((n+4 : ℕ) : ℝ)*δ + W let θ : ℝ := E ^ (1 / ((n+3 : ℕ) : ℝ)) have hW : 0 ≤ W := by dsimp [W]; positivity have hE : 0 ≤ E := by dsimp [E]; positivity have hθ : 0 ≤ θ := Real.rpow_nonneg hE _ have hθpow : θ ^ (n+3) = E := by dsimp [θ] rw [← Real.rpow_mul_natCast hE] have hn : ((n+3 : ℕ) : ℝ) ≠ 0 := by positivity rw [div_mul_cancel₀ _ hn,Real.rpow_one] have hdeg : ∀ x : V, ((Finset.univ.filter (G.Adj x)).card : ℝ) ≤ 2*D := by intro x have hh := (abs_le.mp (hrow x)).2 nlinarith have htrace := normalized_link_trace_bound G n hr D δ hD hdeg hmain hcyc have hber : 1 - ((n+3 : ℕ) : ℝ)*δ ≤ (1-δ)^(n+3) := by simpa only [sub_eq_add_neg, mul_neg] using (one_add_mul_le_pow (a := -δ) (by linarith) (n+3)) have htrace' : Matrix.trace ((D⁻¹ • G.adjMatrix ℝ)^(n+3)) ≤ (1-δ)^(n+3) + θ^(n+3) := by rw [hθpow] have hh := (abs_le.mp htrace).2 dsimp [E] change Matrix.trace ((D⁻¹ • G.adjMatrix ℝ)^(n+3)) - 1 ≤ δ + W at hh push_cast at hber ⊢ nlinarith have hrows : ∀ x : V, |(∑ y, (D⁻¹ • G.adjMatrix ℝ) x y) - 1| ≤ δ := by intro x have hsum : (∑ y, G.adjMatrix ℝ x y) = ((Finset.univ.filter (G.Adj x)).card : ℝ) := by simp only [SimpleGraph.adjMatrix_apply] exact Finset.sum_boole _ _ simp only [Matrix.smul_apply,smul_eq_mul,← Finset.mul_sum,hsum] have heq : D⁻¹ * ((Finset.univ.filter (G.Adj x)).card : ℝ) - 1 = D⁻¹ * (((Finset.univ.filter (G.Adj x)).card : ℝ) - D) := by field_simp rw [heq,abs_mul,abs_of_pos (inv_pos.mpr hD0)] calc _ ≤ D⁻¹ * (δ*D) := mul_le_mul_of_nonneg_left (hrow x) (inv_nonneg.mpr hD0.le) _ = δ := by field_simp have hpos : ∀ x y, 0 ≤ (D⁻¹ • G.adjMatrix ℝ) x y := by intro x y change 0 ≤ D⁻¹ * G.adjMatrix ℝ x y exact mul_nonneg (inv_nonneg.mpr hD0.le) (by simp [SimpleGraph.adjMatrix_apply]; split_ifs <;> norm_num) exact star_approximation_from_trace _ ((G.isHermitian_adjMatrix ℝ).smul (isSelfAdjoint_iff.mpr rfl)) δ θ hδ0 hδ1 hθ hpos hrows (n+3) hr (by omega) htrace'
end GraphStarend SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116import Mathlibimport OAI.Combinatorics.TriangleRemoval.Tracking.GoodPrefixStarApproximationimport OAI.Combinatorics.TriangleRemoval.Process.ReindexQuadraticimport OAI.Combinatorics.TriangleRemoval.Spectral.EdgeStar
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrix InnerProductSpaceopen scoped BigOperatorsopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix
namespace SharpTerminalLeaveopen scoped Matrix.Norms.L2Operator
theorem averagingProjector_reindex {I J : Type*} [Fintype I] [Fintype J] (e : I ≃ J) : Matrix.reindex e e (averagingProjector : Matrix I I ℝ) = (averagingProjector : Matrix J J ℝ) := by ext i j simp only [Matrix.reindex_apply,Matrix.submatrix_apply,averagingProjector] rw [Fintype.card_congr e]
theorem averagingProjector_hermitian {I : Type*} [Fintype I] : (averagingProjector : Matrix I I ℝ).IsHermitian := by apply Matrix.IsHermitian.ext intro i j simp [averagingProjector]
theorem averagingProjector_posSemidef {I : Type*} [Fintype I] : (averagingProjector : Matrix I I ℝ).PosSemidef := by apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg averagingProjector_hermitian intro x have heq : star x ⬝ᵥ ((averagingProjector : Matrix I I ℝ) *ᵥ x) = (Fintype.card I : ℝ)⁻¹ * (∑ i, x i)^2 := by simp [averagingProjector,dotProduct,Matrix.mulVec,← Finset.sum_mul,pow_two, mul_comm,mul_assoc] rw [heq] positivity
noncomputable def linkStarMatrix {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (u : Fin n) : Matrix (edgeStar G u) (edgeStar G u) ℝ := Matrix.reindex (neighborEdgeEquiv G hG u) (neighborEdgeEquiv G hG u) ((linkSimpleGraph G hG u).adjMatrix ℝ)
noncomputable def globalLinkAdjacency {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) : Matrix G G ℝ := ∑ u, extendStar (edgeStar G u) (linkStarMatrix G hG u)
noncomputable def globalStarAverage {n : ℕ} (G : Graph n) : Matrix G G ℝ := ∑ u, extendStar (edgeStar G u) averagingProjector
theorem globalStarAverage_posSemidef {n : ℕ} (G : Graph n) : (globalStarAverage G).PosSemidef := by apply Matrix.posSemidef_sum intro u _ exact averagingProjector_posSemidef.mul_mul_conjTranspose_same _
noncomputable def prefixSpectralError (n : ℕ) (c : ℝ) : ℝ := 4 * ((8001 : ℝ) * (n : ℝ)^(-c) + (8000 : ℝ)^8001 * 2^8000 * ((n : ℝ) / prefixD n^4000 + 1/prefixD n)) ^ (1 / (8000 : ℝ)) + 7*(n : ℝ)^(-c)
theorem prefixSpectralError_nonneg (n : ℕ) (c : ℝ) (hD : 0 ≤ prefixD n) : 0 ≤ prefixSpectralError n c := by unfold prefixSpectralError positivity
theorem goodPrefix_global_spectral {n : ℕ} {G : Graph n} {c C : ℝ} (h : GoodPrefixGraph n c C G) (hne : ∀ u, (neighbors G u).Nonempty) (hD : 1 ≤ prefixD n) (hδ : (n : ℝ)^(-c) ≤ 1) : ‖(prefixD n)⁻¹ • globalLinkAdjacency G h.1 - globalStarAverage G‖ ≤ 2 * prefixSpectralError n c := by let M (u : Fin n) : Matrix (neighbors G u) (neighbors G u) ℝ := (prefixD n)⁻¹ • (linkSimpleGraph G h.1 u).adjMatrix ℝ - averagingProjector let N (u : Fin n) : Matrix (edgeStar G u) (edgeStar G u) ℝ := Matrix.reindex (neighborEdgeEquiv G h.1 u) (neighborEdgeEquiv G h.1 u) (M u) have hM : ∀ u, (M u).IsHermitian := by intro u exact ((linkSimpleGraph G h.1 u).isHermitian_adjMatrix ℝ).smul (isSelfAdjoint_iff.mpr rfl) |>.sub averagingProjector_hermitian have hlocal : ∀ u, ‖N u‖ ≤ prefixSpectralError n c := by intro u have : Nonempty (neighbors G u) := (hne u).to_subtype apply (hermitian_reindex_norm_le _ _ (hM u)).trans apply (goodPrefix_star_fixed h u hD hδ).trans have hn : ((neighbors G u).card : ℝ) ≤ n := by exact_mod_cast (show (neighbors G u).card ≤ n by simpa using (neighbors G u).card_le_univ) unfold prefixSpectralError gcongr have hsplit : (prefixD n)⁻¹ • globalLinkAdjacency G h.1 - globalStarAverage G = ∑ u, extendStar (edgeStar G u) (N u) := by simp only [globalLinkAdjacency,globalStarAverage,Finset.smul_sum,← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro u _ have heq : N u = (prefixD n)⁻¹ • linkStarMatrix G h.1 u - averagingProjector := by ext i j simp only [N,M,linkStarMatrix,Matrix.reindex_apply,Matrix.submatrix_apply, Matrix.sub_apply,Matrix.smul_apply,averagingProjector] rw [Fintype.card_congr (neighborEdgeEquiv G h.1 u)] rw [heq] simp [extendStar,Matrix.mul_sub,Matrix.sub_mul,Matrix.smul_mul,Matrix.mul_smul] rw [hsplit] apply graph_star_error_norm G h.1 N (fun u => (Matrix.isHermitian_reindex_iff _).mpr (hM u)) (prefixSpectralError n c) (prefixSpectralError_nonneg n c (le_trans zero_le_one hD)) hlocal
end SharpTerminalLeave
endend
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.IncidenceDegreeimport OAI.Combinatorics.TriangleRemoval.Stability.Volterraimport OAI.Combinatorics.TriangleRemoval.Spectral.MatrixExpL2Bound
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheory
namespace SharpTerminalLeave
noncomputable def matrixEuclideanAlgHom {I : Type*} [Fintype I] [DecidableEq I] : Matrix I I ℝ →ₐ[ℝ] (EuclideanSpace ℝ I →L[ℝ] EuclideanSpace ℝ I) := (Matrix.toEuclideanCLM (n := I) (𝕜 := ℝ)).toAlgEquiv.toAlgHom
open scoped Matrix.Norms.L2Operator in
theorem euclidean_posSemidef_exp_bound {I : Type*} [Fintype I] [DecidableEq I] (P : Matrix I I ℝ) (hP : P.PosSemidef) (s : ℝ) (hs : 0 ≤ s) : ‖NormedSpace.exp ((-s) • matrixEuclideanAlgHom P)‖ ≤ 1 := by have hF : Continuous (matrixEuclideanAlgHom (I := I)) := (matrixEuclideanAlgHom (I := I)).toLinearMap.continuous_of_finiteDimensional rw [← map_smul,← continuous_algHom_map_exp (matrixEuclideanAlgHom (I := I)) hF] exact matrix_posSemidef_exp_l2_le_one P hP s hs
open scoped Matrix.Norms.L2Operator in
theorem euclidean_perturbed_exp_bound {I : Type*} [Fintype I] [DecidableEq I] [Nonempty I] (P R : Matrix I I ℝ) (hP : P.PosSemidef) (hR : IsSelfAdjoint R) (s : ℝ) (hs : 0 ≤ s) : ‖NormedSpace.exp ((-s) • (matrixEuclideanAlgHom P + matrixEuclideanAlgHom R))‖ ≤ Real.exp (s * ‖matrixEuclideanAlgHom R‖) := by have hF : Continuous (matrixEuclideanAlgHom (I := I)) := (matrixEuclideanAlgHom (I := I)).toLinearMap.continuous_of_finiteDimensional rw [← map_add,← map_smul,← continuous_algHom_map_exp (matrixEuclideanAlgHom (I := I)) hF] exact matrix_perturbed_exp_l2_bound P R hP hR s hs
open scoped Matrix.Norms.Operator in
theorem matrix_infty_le_sqrt_card_euclidean {I : Type*} [Fintype I] [DecidableEq I] (A : Matrix I I ℝ) : ‖A‖ ≤ Real.sqrt (Fintype.card I) * ‖matrixEuclideanAlgHom A‖ := by apply matrix_norm_le_of_row_abs_sum_le _ _ (by positivity) intro i let v : EuclideanSpace ℝ I := WithLp.toLp 2 (fun j => if 0 ≤ A i j then 1 else -1) have hv : ‖v‖ = Real.sqrt (Fintype.card I) := by rw [EuclideanSpace.norm_eq] congr 1 calc _ = ∑ _j : I, (1 : ℝ) := by apply Finset.sum_congr rfl intro j _ simp only [v] split_ifs <;> norm_num _ = _ := by simp have heq : (matrixEuclideanAlgHom A v).ofLp i = ∑ j, |A i j| := by change (Matrix.toEuclideanCLM (n := I) (𝕜 := ℝ) A v).ofLp i = _ simp only [Matrix.ofLp_toEuclideanCLM,v,Matrix.mulVec,dotProduct] apply Finset.sum_congr rfl intro j _ by_cases h : 0 ≤ A i j · simp [h,abs_of_nonneg h] · simp [h,abs_of_neg (lt_of_not_ge h)] have hp := (PiLp.norm_apply_le (matrixEuclideanAlgHom A v) i).trans ((matrixEuclideanAlgHom A).le_opNorm v) rw [heq,Real.norm_eq_abs,abs_of_nonneg (Finset.sum_nonneg fun j _ => abs_nonneg _),hv] at hp simpa only [mul_comm] using hp
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960import Mathlib
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheory
sectionopen scoped BigOperators Topology Matrix.Norms.L2Operator MatrixOrder
namespace SharpTerminalLeave
theorem matrix_exp_l2_bound {ι : Type*} [Fintype ι] [DecidableEq ι] (A : Matrix ι ι ℝ) (hA : IsSelfAdjoint A) (r s : ℝ) (hs : 0 ≤ s) (hlower : ∀ x ∈ spectrum ℝ A, -r ≤ x) : ‖NormedSpace.exp ((-s) • A)‖ ≤ Real.exp (s * r) := by have heq : NormedSpace.exp ((-s) • A) = cfc (fun x : ℝ => Real.exp ((-s) * x)) A := by rw [← CFC.real_exp_eq_normedSpace_exp ((isSelfAdjoint_iff.mpr rfl).smul hA)] rw [← cfc_smul_id (R := ℝ) (-s) A hA, ← cfc_comp Real.exp (fun x : ℝ => (-s) • x) A hA] rfl rw [heq] apply norm_cfc_le (Real.exp_pos _).le intro x hx rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] exact Real.exp_le_exp.mpr (by nlinarith [hlower x hx])
theorem matrix_posSemidef_exp_l2_le_one {ι : Type*} [Fintype ι] [DecidableEq ι] (P : Matrix ι ι ℝ) (hP : P.PosSemidef) (s : ℝ) (hs : 0 ≤ s) : ‖NormedSpace.exp ((-s) • P)‖ ≤ 1 := by have h : ∀ x ∈ spectrum ℝ P, -(0 : ℝ) ≤ x := by simpa only [neg_zero] using (algebraMap_le_iff_le_spectrum (IsSelfAdjoint.of_nonneg hP.nonneg)).mp (show algebraMap ℝ _ 0 ≤ P by simp [hP.nonneg]) simpa only [mul_zero, Real.exp_zero] using matrix_exp_l2_bound P (IsSelfAdjoint.of_nonneg hP.nonneg) 0 s hs h
theorem matrix_perturbed_exp_l2_bound {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] (P R : Matrix ι ι ℝ) (hP : P.PosSemidef) (hR : IsSelfAdjoint R) (s : ℝ) (hs : 0 ≤ s) : ‖NormedSpace.exp ((-s) • (P + R))‖ ≤ Real.exp (s * ‖R‖) := by have hPR : IsSelfAdjoint (P + R) := (IsSelfAdjoint.of_nonneg hP.nonneg).add hR have hRlower : algebraMap ℝ (Matrix ι ι ℝ) (-‖R‖) ≤ R := by apply algebraMap_le_of_le_spectrum (ha := hR) intro x hx have hxnorm := spectrum.norm_le_norm_of_mem hx rw [Real.norm_eq_abs] at hxnorm exact (abs_le.mp hxnorm).1 apply matrix_exp_l2_bound (P + R) hPR ‖R‖ s hs apply (algebraMap_le_iff_le_spectrum hPR).mp exact hRlower.trans (le_add_of_nonneg_left hP.nonneg)
end SharpTerminalLeave
end
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142import Mathlibimport OAI.Combinatorics.TriangleRemoval.Stability.Volterra
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeavenoncomputable def matrixInfinityAlgHom {I : Type*} [Fintype I] [DecidableEq I] : Matrix I I ℝ →ₐ[ℝ] ((I → ℝ) →L[ℝ] (I → ℝ)) := (Matrix.toLinAlgEquiv'.trans (Module.End.toContinuousLinearMap (I → ℝ))).toAlgHom
@[simp] theorem matrixInfinityAlgHom_apply {I : Type*} [Fintype I] [DecidableEq I] (A : Matrix I I ℝ) (z : I → ℝ) (i : I) : matrixInfinityAlgHom A z i = ∑ j, A i j * z j := rfl
open scoped Matrix.Norms.Operator in
@[simp] theorem matrixInfinityAlgHom_norm {I : Type*} [Fintype I] [DecidableEq I] (A : Matrix I I ℝ) : ‖matrixInfinityAlgHom A‖ = ‖A‖ := (Matrix.linfty_opNorm_eq_opNorm A).symm
open scoped Matrix.Norms.Operator in
theorem matrixInfinityAlgHom_exp_norm {I : Type*} [Fintype I] [DecidableEq I] (A : Matrix I I ℝ) (s : ℝ) : ‖NormedSpace.exp ((-s) • matrixInfinityAlgHom A)‖ = ‖NormedSpace.exp ((-s) • A)‖ := by have hc : Continuous (matrixInfinityAlgHom (I := I)) := (matrixInfinityAlgHom (I := I)).toLinearMap.continuous_of_finiteDimensional rw [← map_smul,← continuous_algHom_map_exp (matrixInfinityAlgHom (I := I)) hc, matrixInfinityAlgHom_norm] rflend SharpTerminalLeave
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.ExtendStarApplyimport OAI.Combinatorics.TriangleRemoval.Process.IncidenceDegree
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrix InnerProductSpaceopen scoped BigOperatorsopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrixopen scoped BigOperators Topology NNReal Matrix.Norms.Operatoropen MeasureTheory
namespace SharpTerminalLeaveopen scoped Matrix.Norms.Operator
theorem matrix_row_abs_sum_le {I J : Type*} [Fintype I] [Fintype J] (M : Matrix I J ℝ) (i : I) : ∑ j, |M i j| ≤ ‖M‖ := by rw [Matrix.linfty_opNorm_def] have hh : ∑ j, ‖M i j‖₊ ≤ Finset.univ.sup (fun k => ∑ j, ‖M k j‖₊) := Finset.le_sup (f := fun k => ∑ j, ‖M k j‖₊) (Finset.mem_univ i) have hc := NNReal.coe_le_coe.mpr hh simpa only [NNReal.coe_sum,coe_nnnorm,Real.norm_eq_abs] using hc
theorem extendStar_row_abs_sum {E : Type*} [Fintype E] [DecidableEq E] (S : Finset E) (M : Matrix S S ℝ) (i : E) : ∑ j, |extendStar S M i j| = if hi : i ∈ S then ∑ j : S, |M ⟨i,hi⟩ j| else 0 := by by_cases hi : i ∈ S · rw [dite_eq_left hi] have he : ∑ j : E, |extendStar S M i j| = ∑ j ∈ S, |extendStar S M i j| := by symm apply Finset.sum_subset (Finset.subset_univ S) intro j _ hj simp [extendStar_apply,hj] rw [he,← Finset.sum_coe_sort S] apply Finset.sum_congr rfl intro j _ simp [extendStar_apply,hi,j.property] · simp [extendStar_apply,hi]
theorem sum_star_infty_norm_bound {E U : Type*} [Fintype E] [DecidableEq E] [Fintype U] (S : U → Finset E) (M : (u : U) → Matrix (S u) (S u) ℝ) (ε K : ℝ) (hε : 0 ≤ ε) (hK : 0 ≤ K) (hM : ∀ u, ‖M u‖ ≤ ε) (hoverlap : ∀ e, ((Finset.univ.filter fun u => e ∈ S u).card : ℝ) ≤ K) : ‖∑ u, extendStar (S u) (M u)‖ ≤ K*ε := by apply matrix_norm_le_of_row_abs_sum_le _ _ (mul_nonneg hK hε) intro e calc _ ≤ ∑ f, ∑ u, |extendStar (S u) (M u) e f| := by apply Finset.sum_le_sum intro f _ simp only [Matrix.sum_apply] exact Finset.abs_sum_le_sum_abs _ _ _ = ∑ u, ∑ f, |extendStar (S u) (M u) e f| := Finset.sum_comm _ ≤ ∑ u, if e ∈ S u then ε else 0 := by apply Finset.sum_le_sum intro u _ rw [extendStar_row_abs_sum] by_cases he : e ∈ S u · simp only [he,↓reduceDIte,↓reduceIte] exact (matrix_row_abs_sum_le (M u) ⟨e,he⟩).trans (hM u) · simp [he] _ = ((Finset.univ.filter fun u => e ∈ S u).card : ℝ) * ε := by rw [← Finset.sum_filter] simp _ ≤ K*ε := mul_le_mul_of_nonneg_right (hoverlap e) hε
theorem infty_reindex_norm_le {I J : Type*} [Fintype I] [Fintype J] (e : I ≃ J) (M : Matrix I I ℝ) : ‖Matrix.reindex e e M‖ ≤ ‖M‖ := by apply matrix_norm_le_of_row_abs_sum_le _ _ (norm_nonneg _) intro i simp only [Matrix.reindex_apply,Matrix.submatrix_apply] rw [e.symm.sum_comp (fun j => |M (e.symm i) j|)] exact matrix_row_abs_sum_le M (e.symm i)
end SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327import Mathlib
namespace OAI
sectionopen scoped BigOperators
namespace SharpTerminalLeave
open Classical
private lemma moving_abs_sub_bound (x y : ℝ) : |x-y| ≤ |x|+|y| := by simpa using (abs_sub_le x 0 y)
noncomputable def movingStarDegree {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (u : V) : ℝ := by classical exact ((active.filter (fun e => u ∈ ends e)).card : ℝ)
noncomputable def movingStarMean {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (x : E → ℝ) (u : V) : ℝ := by classical exact (∑ e ∈ active.filter (fun e => u ∈ ends e), x e) / movingStarDegree ends active u
noncomputable def movingStarLift {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (b : V → ℝ) (e : E) : ℝ := ∑ u ∈ ends e, b u
noncomputable def movingStarOtherMean {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (b : V → ℝ) (u : V) : ℝ := by classical exact (∑ e ∈ active.filter (fun e => u ∈ ends e), ∑ v ∈ (ends e).erase u, b v) / movingStarDegree ends active u
lemma movingStarDegree_nonneg {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (u : V) : 0 ≤ movingStarDegree ends active u := Nat.cast_nonneg _
lemma movingStarMean_congr {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) {x y : E → ℝ} (h : ∀ e ∈ active, x e = y e) : movingStarMean ends active x = movingStarMean ends active y := by classical funext u unfold movingStarMean congr 1 apply Finset.sum_congr rfl intro e he exact h e (Finset.mem_filter.mp he).1
lemma movingStarMean_sub {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (x y : E → ℝ) (u : V) : movingStarMean ends active (fun e => x e-y e) u = movingStarMean ends active x u-movingStarMean ends active y u := by classical simp only [movingStarMean,Finset.sum_sub_distrib,sub_div]
lemma movingStarMean_zero_degree {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (x : E → ℝ) (u : V) (hd : movingStarDegree ends active u = 0) : movingStarMean ends active x u = 0 := by simp [movingStarMean,hd]
lemma movingStarMean_bound {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (x : E → ℝ) (u : V) {M : ℝ} (hM : 0 ≤ M) (hx : ∀ e ∈ active, |x e| ≤ M) : |movingStarMean ends active x u| ≤ M := by classical by_cases hd : movingStarDegree ends active u = 0 · simpa [movingStarMean_zero_degree ends active x u hd] using hM · have hp : 0 < movingStarDegree ends active u := lt_of_le_of_ne (movingStarDegree_nonneg ends active u) (Ne.symm hd) unfold movingStarMean rw [abs_div,abs_of_pos hp] apply (div_le_iff₀ hp).mpr calc _ ≤ ∑ e ∈ active.filter (fun e => u ∈ ends e), |x e| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _e ∈ active.filter (fun e => u ∈ ends e), M := by apply Finset.sum_le_sum intro e he exact hx e (Finset.mem_filter.mp he).1 _ = _ := by simp [movingStarDegree,mul_comm]
lemma movingStarLift_bound {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (b : V → ℝ) {B : ℝ} (hb : ∀ v, |b v| ≤ B) (e : E) : |movingStarLift ends b e| ≤ 2*B := by classical unfold movingStarLift calc _ ≤ ∑ v ∈ ends e, |b v| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _v ∈ ends e, B := Finset.sum_le_sum (fun v _ => hb v) _ = _ := by simp [hends]
lemma movingStarOtherMean_bound {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active : Finset E) (b : V → ℝ) (u : V) {B : ℝ} (hB : 0 ≤ B) (hb : ∀ v, |b v| ≤ B) : |movingStarOtherMean ends active b u| ≤ B := by classical by_cases hd : movingStarDegree ends active u = 0 · simpa [movingStarOtherMean,hd] using hB · have hp : 0 < movingStarDegree ends active u := lt_of_le_of_ne (movingStarDegree_nonneg ends active u) (Ne.symm hd) unfold movingStarOtherMean rw [abs_div,abs_of_pos hp] apply (div_le_iff₀ hp).mpr calc _ ≤ ∑ e ∈ active.filter (fun e => u ∈ ends e), |∑ v ∈ (ends e).erase u, b v| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _e ∈ active.filter (fun e => u ∈ ends e), B := by apply Finset.sum_le_sum intro e he have hu := (Finset.mem_filter.mp he).2 have hc : ((ends e).erase u).card = 1 := by rw [Finset.card_erase_of_mem hu,hends] calc _ ≤ ∑ v ∈ (ends e).erase u, |b v| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _v ∈ (ends e).erase u, B := Finset.sum_le_sum (fun v _ => hb v) _ = B := by simp [hc] _ = _ := by simp [movingStarDegree,mul_comm]
lemma movingStarMean_lift {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (b : V → ℝ) (u : V) (hd : movingStarDegree ends active u ≠ 0) : movingStarMean ends active (movingStarLift ends b) u = b u + movingStarOtherMean ends active b u := by classical have he : (∑ e ∈ active.filter (fun e => u ∈ ends e), movingStarLift ends b e) = movingStarDegree ends active u*b u + ∑ e ∈ active.filter (fun e => u ∈ ends e), ∑ v ∈ (ends e).erase u, b v := by calc _ = ∑ e ∈ active.filter (fun e => u ∈ ends e), (b u+∑ v ∈ (ends e).erase u, b v) := by apply Finset.sum_congr rfl intro e he exact (Finset.add_sum_erase _ b (Finset.mem_filter.mp he).2).symm _ = _ := by simp [Finset.sum_add_distrib,movingStarDegree] unfold movingStarMean movingStarOtherMean rw [he,add_div,mul_div_cancel_left₀ _ hd]
theorem movingStar_vertex_step_bound {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active : Finset E) (b : V → ℝ) (M : E → ℝ) {B R a : ℝ} (hB : 0 ≤ B) (hR : 0 ≤ R) (ha : 0 ≤ a) (ha1 : a ≤ 1) (hb : ∀ u, |b u| ≤ B) (hM : ∀ e ∈ active, |M e| ≤ R) (u : V) : |b u + a*movingStarMean ends active (fun e => M e-movingStarLift ends b e) u| ≤ B+a*R := by classical rw [movingStarMean_sub] by_cases hd : movingStarDegree ends active u = 0 · rw [movingStarMean_zero_degree ends active M u hd, movingStarMean_zero_degree ends active (movingStarLift ends b) u hd] simp only [sub_self,mul_zero,add_zero] exact (hb u).trans (le_add_of_nonneg_right (mul_nonneg ha hR)) · rw [movingStarMean_lift ends active b u hd] have hid : b u+a*(movingStarMean ends active M u-(b u+movingStarOtherMean ends active b u)) = (1-a)*b u-a*movingStarOtherMean ends active b u+a*movingStarMean ends active M u := by ring rw [hid] calc _ ≤ |(1-a)*b u-a*movingStarOtherMean ends active b u|+ |a*movingStarMean ends active M u| := abs_add_le _ _ _ ≤ (|(1-a)*b u|+|a*movingStarOtherMean ends active b u|)+ |a*movingStarMean ends active M u| := by exact add_le_add (moving_abs_sub_bound _ _) le_rfl _ = ((1-a)*|b u|+a*|movingStarOtherMean ends active b u|)+ a*|movingStarMean ends active M u| := by rw [abs_mul,abs_mul,abs_mul,abs_of_nonneg (sub_nonneg.mpr ha1),abs_of_nonneg ha] _ ≤ ((1-a)*B+a*B)+a*R := by gcongr · exact hb u · exact movingStarOtherMean_bound ends hends active b u hB hb · exact movingStarMean_bound ends active M u hR hM _ = _ := by ring
noncomputable def movingStarVertices {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : ℕ → Finset E) (a : ℕ → ℝ) (M : ℕ → E → ℝ) : ℕ → V → ℝ | 0 => fun _ => 0 | k+1 => fun u => movingStarVertices ends active a M k u + a k * movingStarMean ends (active k) (fun e => M k e-movingStarLift ends (movingStarVertices ends active a M k) e) u
theorem movingStarVertices_bound {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active : ℕ → Finset E) (a : ℕ → ℝ) (M : ℕ → E → ℝ) (T : ℕ) {R : ℝ} (hR : 0 ≤ R) (ha : ∀ k < T, 0 ≤ a k ∧ a k ≤ 1) (hM : ∀ k < T, ∀ e ∈ active k, |M k e| ≤ R) : ∀ u, |movingStarVertices ends active a M T u| ≤ R*∑ k ∈ Finset.range T, a k := by induction T with | zero => intro u; simp [movingStarVertices] | succ T ih => have haT := ha T (by omega) have hb := ih (fun k hk => ha k (by omega)) (fun k hk => hM k (by omega)) have hB : 0 ≤ R*∑ k ∈ Finset.range T, a k := by exact mul_nonneg hR (Finset.sum_nonneg (fun k hk => (ha k (by have := Finset.mem_range.mp hk; omega)).1)) intro u have hh := movingStar_vertex_step_bound ends hends (active T) (movingStarVertices ends active a M T) (M T) hB hR haT.1 haT.2 hb (hM T (by omega)) u simpa only [movingStarVertices,Finset.sum_range_succ,mul_add,mul_comm] using hh
theorem movingStar_trajectory_representation {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : ℕ → Finset E) (a : ℕ → ℝ) (M x : ℕ → E → ℝ) (T : ℕ) (hnest : ∀ k < T, active (k+1) ⊆ active k) (hinit : ∀ e ∈ active 0, x 0 e = M 0 e) (hstep : ∀ k < T, ∀ e ∈ active (k+1), x (k+1) e = x k e - a k*movingStarLift ends (movingStarMean ends (active k) (x k)) e + (M (k+1) e-M k e)) : ∀ e ∈ active T, x T e = M T e-movingStarLift ends (movingStarVertices ends active a M T) e := by induction T with | zero => intro e he; simpa [movingStarVertices,movingStarLift] using hinit e he | succ T ih => have hx := ih (fun k hk => hnest k (by omega)) (fun k hk => hstep k (by omega)) have hm := movingStarMean_congr ends (active T) hx intro e he rw [hstep T (by omega) e he,hx e (hnest T (by omega) he),hm] simp only [movingStarVertices,movingStarLift,Finset.sum_add_distrib,Finset.mul_sum] ring
theorem movingStar_trajectory_bound {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active : ℕ → Finset E) (a : ℕ → ℝ) (M x : ℕ → E → ℝ) (T : ℕ) (hnest : ∀ k < T, active (k+1) ⊆ active k) (hinit : ∀ e ∈ active 0, x 0 e = M 0 e) (hstep : ∀ k < T, ∀ e ∈ active (k+1), x (k+1) e = x k e - a k*movingStarLift ends (movingStarMean ends (active k) (x k)) e + (M (k+1) e-M k e)) {R : ℝ} (hR : 0 ≤ R) (ha : ∀ k < T, 0 ≤ a k ∧ a k ≤ 1) (hM : ∀ k ≤ T, ∀ e ∈ active k, |M k e| ≤ R) : ∀ e ∈ active T, |x T e| ≤ R*(1+2*∑ k ∈ Finset.range T, a k) := by have hb := movingStarVertices_bound ends hends active a M T hR ha (fun k hk => hM k (by omega)) intro e he rw [movingStar_trajectory_representation ends active a M x T hnest hinit hstep e he] calc _ ≤ |M T e|+|movingStarLift ends (movingStarVertices ends active a M T) e| := moving_abs_sub_bound _ _ _ ≤ R+2*(R*∑ k ∈ Finset.range T, a k) := add_le_add (hM T le_rfl e he) (movingStarLift_bound ends hends _ hb e) _ = _ := by ring
lemma movingStar_incidence_swap {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (f : E → V → ℝ) : (∑ e ∈ active, ∑ u ∈ ends e, f e u) = ∑ u, ∑ e ∈ active.filter (fun e => u ∈ ends e), f e u := by classical have he (e : E) : (∑ u ∈ ends e, f e u) = ∑ u, if u ∈ ends e then f e u else 0 := by simp simp_rw [he] rw [Finset.sum_comm] simp only [Finset.sum_filter]
lemma movingStarMean_mass {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (x : E → ℝ) (u : V) : movingStarDegree ends active u*movingStarMean ends active x u = ∑ e ∈ active.filter (fun e => u ∈ ends e), x e := by classical by_cases hd : movingStarDegree ends active u = 0 · have hc : (active.filter (fun e => u ∈ ends e)).card = 0 := by exact_mod_cast (show ((active.filter (fun e => u ∈ ends e)).card : ℝ) = 0 from hd) have he := Finset.card_eq_zero.mp hc simp [movingStarMean,hd,he] · unfold movingStarMean exact mul_div_cancel₀ _ hd
theorem movingStar_energy_identity {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : Finset E) (x : E → ℝ) : (∑ e ∈ active, x e*movingStarLift ends (movingStarMean ends active x) e) = ∑ u, movingStarDegree ends active u*(movingStarMean ends active x u)^2 := by classical simp only [movingStarLift,Finset.mul_sum] rw [movingStar_incidence_swap] apply Finset.sum_congr rfl intro u _ rw [← Finset.sum_mul,← movingStarMean_mass ends active x u] ring
lemma movingStar_lift_sq_bound {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active : Finset E) (b : V → ℝ) : (∑ e ∈ active, (movingStarLift ends b e)^2) ≤ 2*∑ u, movingStarDegree ends active u*(b u)^2 := by classical calc _ ≤ ∑ e ∈ active, 2*∑ u ∈ ends e, (b u)^2 := by apply Finset.sum_le_sum intro e _ simpa only [movingStarLift,hends,Nat.cast_ofNat] using (sq_sum_le_card_mul_sum_sq (s := ends e) (f := b)) _ = _ := by rw [← Finset.mul_sum,movingStar_incidence_swap] congr 1 apply Finset.sum_congr rfl intro u _ simp [movingStarDegree]
theorem movingStar_euler_energy_le {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active : Finset E) (x : E → ℝ) {a : ℝ} (ha : 0 ≤ a) (ha1 : a ≤ 1) : (∑ e ∈ active, (x e-a*movingStarLift ends (movingStarMean ends active x) e)^2) ≤ ∑ e ∈ active, (x e)^2 := by classical let P := movingStarLift ends (movingStarMean ends active x) let V := ∑ u, movingStarDegree ends active u*(movingStarMean ends active x u)^2 have hV : 0 ≤ V := Finset.sum_nonneg (fun u _ => mul_nonneg (movingStarDegree_nonneg ends active u) (sq_nonneg _)) have hlin : (∑ e ∈ active, x e*P e) = V := movingStar_energy_identity ends active x have hsq : (∑ e ∈ active, (P e)^2) ≤ 2*V := movingStar_lift_sq_bound ends hends active (movingStarMean ends active x) have hexpand : (∑ e ∈ active, (x e-a*P e)^2) = (∑ e ∈ active, (x e)^2)-2*a*(∑ e ∈ active, x e*P e)+ a^2*(∑ e ∈ active, (P e)^2) := by calc _ = ∑ e ∈ active, ((x e)^2-2*a*(x e*P e)+a^2*(P e)^2) := by apply Finset.sum_congr rfl intro e _ ring _ = _ := by simp only [Finset.sum_add_distrib,Finset.sum_sub_distrib,Finset.mul_sum] change (∑ e ∈ active, (x e-a*P e)^2) ≤ _ rw [hexpand,hlin] have hsq' := mul_le_mul_of_nonneg_left hsq (sq_nonneg a) have hab : a^2 ≤ a := by nlinarith have hb := mul_le_mul_of_nonneg_right hab hV nlinarith only [hsq',hb]
theorem movingStar_euler_energy_subset_le {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active remaining : Finset E) (hsub : remaining ⊆ active) (x : E → ℝ) {a : ℝ} (ha : 0 ≤ a) (ha1 : a ≤ 1) : (∑ e ∈ remaining, (x e-a*movingStarLift ends (movingStarMean ends active x) e)^2) ≤ ∑ e ∈ active, (x e)^2 := by apply le_trans _ (movingStar_euler_energy_le ends hends active x ha ha1) exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => sq_nonneg _)
end SharpTerminalLeaveend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.UnitLineRemainderimport OAI.Combinatorics.TriangleRemoval.Process.EigenProjectorimport OAI.Combinatorics.TriangleRemoval.Process.EigenvalueAbsRowsum
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpace
namespace SharpTerminalLeave
variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι]
noncomputable def normalizedOnes : EuclideanSpace ℝ ι := WithLp.toLp 2 (fun _ => (Real.sqrt (Fintype.card ι : ℝ))⁻¹)
noncomputable def averagingProjector : Matrix ι ι ℝ := fun _ _ => (Fintype.card ι : ℝ)⁻¹
omit [DecidableEq ι] intheorem normalizedOnes_norm : ‖(normalizedOnes : EuclideanSpace ℝ ι)‖ = 1 := by have hn : 0 < (Fintype.card ι : ℝ) := Nat.cast_pos.mpr Fintype.card_pos have hs : (Real.sqrt (Fintype.card ι : ℝ)) ^ 2 = Fintype.card ι := Real.sq_sqrt (le_of_lt hn) have hnorm : ‖(normalizedOnes : EuclideanSpace ℝ ι)‖ ^ 2 = 1 := by rw [EuclideanSpace.norm_sq_eq] simp only [normalizedOnes, WithLp.ofLp_toLp, Real.norm_eq_abs, sq_abs, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, inv_pow, hs] exact mul_inv_cancel₀ (ne_of_gt hn) nlinarith [norm_nonneg (normalizedOnes : EuclideanSpace ℝ ι)]
theorem normalizedOnes_residual (A : Matrix ι ι ℝ) (δ : ℝ) (hδ : 0 ≤ δ) (hrow : ∀ i, |(∑ j, A i j) - 1| ≤ δ) : ‖(Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) A normalizedOnes - normalizedOnes‖ ≤ δ := by have hn : 0 < (Fintype.card ι : ℝ) := Nat.cast_pos.mpr Fintype.card_pos have hs : (Real.sqrt (Fintype.card ι : ℝ)) ^ 2 = Fintype.card ι := Real.sq_sqrt (le_of_lt hn) have hcoords : ∀ i, ((Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) A normalizedOnes - normalizedOnes).ofLp i = ((∑ j, A i j) - 1) * (Real.sqrt (Fintype.card ι : ℝ))⁻¹ := by intro i simp [normalizedOnes, Matrix.toEuclideanCLM_toLp, Matrix.mulVec, dotProduct, Finset.sum_mul, sub_mul] have hsq : ‖(Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) A normalizedOnes - normalizedOnes‖ ^ 2 ≤ δ ^ 2 := by rw [EuclideanSpace.norm_sq_eq] calc _ = ∑ i, |((∑ j, A i j) - 1)| ^ 2 * (Real.sqrt (Fintype.card ι : ℝ))⁻¹ ^ 2 := by simp only [hcoords, Real.norm_eq_abs, sq_abs, mul_pow] _ ≤ ∑ _ : ι, δ ^ 2 * (Real.sqrt (Fintype.card ι : ℝ))⁻¹ ^ 2 := by apply Finset.sum_le_sum intro i _ exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (abs_nonneg _) (hrow i) 2) (sq_nonneg _) _ = δ ^ 2 := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, inv_pow, hs] field_simp nlinarith [norm_nonneg ((Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) A normalizedOnes - normalizedOnes)]
omit [Nonempty ι] intheorem eigenProjector_entry (A : Matrix ι ι ℝ) (hA : A.IsHermitian) (k i j : ι) : eigenProjector A hA k i j = hA.eigenvectorBasis k i * hA.eigenvectorBasis k j := by simp [eigenProjector, Unitary.conjStarAlgAut_apply, Matrix.mul_apply, Matrix.diagonal_apply, Pi.single_apply]
omit [Nonempty ι] intheorem eigenProjector_toCLM (A : Matrix ι ι ℝ) (hA : A.IsHermitian) (k : ι) : (Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) (eigenProjector A hA k) = rankOne ℝ (hA.eigenvectorBasis k) (hA.eigenvectorBasis k) := by ext x i change ((eigenProjector A hA k) *ᵥ x.ofLp) i = _ simp only [rankOne_apply, PiLp.smul_apply, smul_eq_mul, Matrix.mulVec, dotProduct, eigenProjector_entry, PiLp.inner_apply, RCLike.inner_apply, conj_trivial] simp_rw [Finset.sum_mul] apply Finset.sum_congr rfl intro j _ ring
omit [Nonempty ι] intheorem averagingProjector_toCLM : (Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) (averagingProjector : Matrix ι ι ℝ) = rankOne ℝ (normalizedOnes : EuclideanSpace ℝ ι) normalizedOnes := by have hn : 0 ≤ (Fintype.card ι : ℝ) := Nat.cast_nonneg _ have hs : (Real.sqrt (Fintype.card ι : ℝ))⁻¹ ^ 2 = (Fintype.card ι : ℝ)⁻¹ := by rw [inv_pow, Real.sq_sqrt hn] ext x i change (averagingProjector *ᵥ x.ofLp) i = _ simp only [rankOne_apply, PiLp.smul_apply, smul_eq_mul, Matrix.mulVec, dotProduct, averagingProjector, PiLp.inner_apply, RCLike.inner_apply, conj_trivial, normalizedOnes] rw [Finset.sum_mul] apply Finset.sum_congr rfl intro j _ nlinarith [congrArg (fun t : ℝ => t * x.ofLp j) hs]
theorem star_approximation_from_trace (A : Matrix ι ι ℝ) (hA : A.IsHermitian) (δ θ : ℝ) (hδ0 : 0 ≤ δ) (hδ1 : δ ≤ 1) (hθ : 0 ≤ θ) (hpos : ∀ i j, 0 ≤ A i j) (hrow : ∀ i, |(∑ j, A i j) - 1| ≤ δ) (r : ℕ) (hr : Even r) (hr0 : r ≠ 0) (htrace : (A ^ r).trace ≤ (1 - δ) ^ r + θ ^ r) : ‖A - averagingProjector‖ ≤ 4 * θ + 7 * δ := by have hrlo : ∀ i, 1 - δ ≤ ∑ j, A i j := fun i => by have hh := (abs_le.mp (hrow i)).1 linarith have hrhi : ∀ i, ∑ j, |A i j| ≤ 1 + δ := fun i => by simp_rw [abs_of_nonneg (hpos i _)] have hh := (abs_le.mp (hrow i)).2 linarith obtain ⟨k, hklo, hkhi, _⟩ := exists_leading_of_rowsums A hA (1-δ) (1+δ) (by linarith) hrlo hrhi have hlam : |hA.eigenvalues k - 1| ≤ δ := by have hhi := (abs_le.mp hkhi).2 exact abs_le.mpr ⟨by linarith, by linarith⟩ have htail := eigenvalue_tail_of_trace A hA k r hr hr0 (1-δ) θ (by linarith) hθ hklo htrace have happrox := eigenProjector_approximation A hA k θ hθ htail have heig : ‖(Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) A - hA.eigenvalues k • rankOne ℝ (hA.eigenvectorBasis k) (hA.eigenvectorBasis k)‖ ≤ θ := by rw [← eigenProjector_toCLM A hA k, ← map_smul, ← map_sub, Matrix.l2_opNorm_toEuclideanCLM] exact happrox have hfinal := projector_transfer ((Matrix.toEuclideanCLM (n := ι) (𝕜 := ℝ)) A) (hA.eigenvectorBasis k) normalizedOnes (hA.eigenvectorBasis.norm_eq_one k) normalizedOnes_norm (hA.eigenvalues k) θ δ δ heig hlam (normalizedOnes_residual A δ hδ0 hrow) rw [← averagingProjector_toCLM, ← map_sub, Matrix.l2_opNorm_toEuclideanCLM] at hfinal linarith
end SharpTerminalLeave
open scoped BigOperators
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.ClosedWalkFamily
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpaceopen scoped BigOperators
namespace SharpTerminalLeavesection RealTracevariable {V : Type*} [Fintype V] [DecidableEq V]variable (G : SimpleGraph V) [DecidableRel G.Adj]
lemma real_trace_adjMatrix_eq (n : ℕ) : Matrix.trace (G.adjMatrix ℝ ^ (n+3)) = ((graphEmbeddings (SimpleGraph.cycleGraph (n+3)) G).card : ℝ) + (nonsimpleWords G (n+3)).card := by have hNat := trace_adjMatrix_eq_closedWords G n rw [closedWords_card_eq] at hNat have ht : Matrix.trace (G.adjMatrix ℝ ^ (n+3)) = ((Matrix.trace (G.adjMatrix ℕ ^ (n+3)) : ℕ) : ℝ) := by simp only [Matrix.trace, Matrix.diag_apply, Nat.cast_sum, SimpleGraph.adjMatrix_pow_apply_eq_card_walk, Nat.cast_id] rw [ht, hNat, Nat.cast_add]
theorem normalized_link_trace_bound (n : ℕ) (hr : Even (n+3)) (D δ : ℝ) (hD : 1 ≤ D) (hdeg : ∀ x : V, ((Finset.univ.filter (G.Adj x)).card : ℝ) ≤ 2*D) (hmain : |((graphEmbeddings (SimpleGraph.cycleGraph (n+3)) G).card : ℝ) - D^(n+3)| ≤ δ * D^(n+3)) (hcyc : ∀ b, 3 ≤ b → b < n+3 → ((graphEmbeddings (SimpleGraph.cycleGraph b) G).card : ℝ) ≤ 2 * D^b) : |Matrix.trace (((D⁻¹) • G.adjMatrix ℝ) ^ (n+3)) - 1| ≤ δ + ((n+3 : ℕ) : ℝ)^(n+4) * 2^(n+3) * ((Fintype.card V : ℝ) / D^((n+3)/2) + 1/D) := by classical have hD0 : 0 < D := lt_of_lt_of_le zero_lt_one hD have hDne : D ≠ 0 := ne_of_gt hD0 let Δ : ℕ := ⌊2*D⌋₊ have hΔlo : D ≤ (Δ : ℝ) := by have hh := Nat.lt_floor_add_one (2*D) change 2*D < (Δ : ℝ)+1 at hh linarith have hΔhi : (Δ : ℝ) ≤ 2*D := Nat.floor_le (by positivity) have hΔ0 : 1 ≤ Δ := by exact_mod_cast hD.trans hΔlo have hdeg' : ∀ x : V, (Finset.univ.filter (G.Adj x)).card ≤ Δ := by intro x exact (Nat.le_floor_iff (by positivity : 0 ≤ 2*D)).mpr (hdeg x) have hcyc' : ∀ b, 3 ≤ b → b < n+3 → (graphEmbeddings (SimpleGraph.cycleGraph b) G).card ≤ 2 * Δ^b := by intro b hb hbr have hh := (hcyc b hb hbr).trans (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hD0.le hΔlo b) (by norm_num : (0:ℝ) ≤ 2)) exact_mod_cast hh have hcount := nonsimpleWords_card_le G n Δ 2 hΔ0 hdeg' hcyc' have hcountR : ((nonsimpleWords G (n+3)).card : ℝ) ≤ ((n+3 : ℕ) : ℝ)^(n+4) * ((Fintype.card V : ℝ) * (2*D)^((n+3)/2) + 2*(2*D)^(n+2)) := by have hh : ((nonsimpleWords G (n+3)).card : ℝ) ≤ ((n+3 : ℕ) : ℝ)^(n+4) * ((Fintype.card V : ℝ) * (Δ:ℝ)^((n+3)/2) + 2*(Δ:ℝ)^(n+2)) := by exact_mod_cast hcount refine hh.trans (mul_le_mul_of_nonneg_left ?_ (by positivity)) exact add_le_add (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (Nat.cast_nonneg Δ) hΔhi _) (Nat.cast_nonneg _)) (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (Nat.cast_nonneg Δ) hΔhi _) (by norm_num)) have hhalf : (n+3)/2 + (n+3)/2 = n+3 := by obtain ⟨k, hk⟩ := hr omega have hhalfle : (n+3)/2 ≤ n+3 := Nat.div_le_self _ _ have hp2 : (2:ℝ)^((n+3)/2) ≤ 2^(n+3) := pow_le_pow_right₀ (by norm_num) hhalfle have hpow : D^(n+3) = D^((n+3)/2) * D^((n+3)/2) := by rw [← pow_add, hhalf] have hpow' : D^(n+3) = D^(n+2) * D := by rw [← pow_succ] have hratio : ((nonsimpleWords G (n+3)).card : ℝ) / D^(n+3) ≤ ((n+3 : ℕ) : ℝ)^(n+4) * 2^(n+3) * ((Fintype.card V : ℝ) / D^((n+3)/2) + 1/D) := by apply (div_le_iff₀ (pow_pos hD0 _)).mpr have htree : (Fintype.card V : ℝ) * (2*D)^((n+3)/2) ≤ 2^(n+3) * ((Fintype.card V : ℝ)/D^((n+3)/2)) * D^(n+3) := by rw [mul_pow, hpow] field_simp nlinarith [mul_le_mul_of_nonneg_right hp2 (mul_nonneg (Nat.cast_nonneg (Fintype.card V)) (pow_nonneg hD0.le ((n+3)/2)))] have hcycle : 2*(2*D)^(n+2) = 2^(n+3) * (1/D) * D^(n+3) := by rw [mul_pow, hpow', show n+3 = (n+2)+1 by omega, pow_succ] field_simp ring calc _ ≤ ((n+3 : ℕ) : ℝ)^(n+4) * ((Fintype.card V : ℝ) * (2*D)^((n+3)/2) + 2*(2*D)^(n+2)) := hcountR _ ≤ ((n+3 : ℕ) : ℝ)^(n+4) * (2^(n+3) * ((Fintype.card V : ℝ)/D^((n+3)/2)) * D^(n+3) + 2^(n+3) * (1/D) * D^(n+3)) := mul_le_mul_of_nonneg_left (add_le_add htree hcycle.le) (by positivity) _ = _ := by ring have htrace : Matrix.trace (((D⁻¹) • G.adjMatrix ℝ) ^ (n+3)) = (((graphEmbeddings (SimpleGraph.cycleGraph (n+3)) G).card : ℝ) + (nonsimpleWords G (n+3)).card) / D^(n+3) := by rw [smul_pow, Matrix.trace_smul, real_trace_adjMatrix_eq] simp only [smul_eq_mul, inv_pow, div_eq_mul_inv, mul_comm] rw [htrace] calc _ = |(((graphEmbeddings (SimpleGraph.cycleGraph (n+3)) G).card : ℝ) - D^(n+3)) / D^(n+3) + (nonsimpleWords G (n+3)).card / D^(n+3)| := by congr 1 field_simp ring _ ≤ |(((graphEmbeddings (SimpleGraph.cycleGraph (n+3)) G).card : ℝ) - D^(n+3)) / D^(n+3)| + |((nonsimpleWords G (n+3)).card : ℝ) / D^(n+3)| := abs_add_le _ _ _ ≤ δ + ((n+3 : ℕ) : ℝ)^(n+4) * 2^(n+3) * ((Fintype.card V : ℝ) / D^((n+3)/2) + 1/D) := by apply add_le_add · rw [abs_div, abs_of_pos (pow_pos hD0 _)] exact (div_le_iff₀ (pow_pos hD0 _)).mpr hmain · rw [abs_of_nonneg (div_nonneg (Nat.cast_nonneg _) (pow_nonneg hD0.le _))] exact hratio
end RealTraceend SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127import Mathlib
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrix InnerProductSpaceopen scoped BigOperatorsopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix
namespace SharpTerminalLeave
variable {E U : Type*} [Fintype E] [DecidableEq E] [Fintype U]
def starInclusion (S : Finset E) : Matrix E S ℝ := fun e f => if e = f.val then 1 else 0
noncomputable def extendStar (S : Finset E) (M : Matrix S S ℝ) : Matrix E E ℝ := starInclusion S * M * (starInclusion S)ᴴ
theorem starInclusion_mulVec (S : Finset E) (x : E → ℝ) : (starInclusion S)ᴴ *ᵥ x = fun e : S => x e.val := by ext e simp [starInclusion,Matrix.mulVec,dotProduct]
theorem extendStar_quadratic (S : Finset E) (M : Matrix S S ℝ) (x : E → ℝ) : x ⬝ᵥ (extendStar S M *ᵥ x) = (fun e : S => x e.val) ⬝ᵥ (M *ᵥ fun e : S => x e.val) := by rw [extendStar,← Matrix.mulVec_mulVec,← Matrix.mulVec_mulVec,starInclusion_mulVec, Matrix.dotProduct_mulVec] congr 1 ext e simp [starInclusion,Matrix.vecMul,dotProduct]
theorem matrix_quadratic_abs (M : Matrix E E ℝ) (x : E → ℝ) : |x ⬝ᵥ (M *ᵥ x)| ≤ ‖M‖ * ∑ e, (x e)^2 := by let y : EuclideanSpace ℝ E := WithLp.toLp 2 x let T := (Matrix.toEuclideanCLM (n := E) (𝕜 := ℝ)) M have heq : x ⬝ᵥ (M *ᵥ x) = inner ℝ y (T y) := by simp [T,y,Matrix.toEuclideanCLM_toLp,EuclideanSpace.inner_eq_star_dotProduct,dotProduct, mul_comm] have hn : ‖y‖^2 = ∑ e, (x e)^2 := by simp [EuclideanSpace.norm_sq_eq,y,Real.norm_eq_abs] rw [heq] calc _ ≤ ‖y‖ * ‖T y‖ := abs_real_inner_le_norm _ _ _ ≤ ‖y‖ * (‖T‖ * ‖y‖) := mul_le_mul_of_nonneg_left (T.le_opNorm y) (norm_nonneg _) _ = ‖M‖ * ∑ e, (x e)^2 := by rw [mul_left_comm,← pow_two,hn] exact congrArg (fun a : ℝ => a * ∑ e, (x e)^2) (Matrix.l2_opNorm_toEuclideanCLM M)
theorem hermitian_norm_le_of_quadratic (M : Matrix E E ℝ) (hM : M.IsHermitian) (a : ℝ) (ha : 0 ≤ a) (hquad : ∀ x : E → ℝ, |x ⬝ᵥ (M *ᵥ x)| ≤ a * ∑ e, (x e)^2) : ‖M‖ ≤ a := by have hev : ∀ e, |hM.eigenvalues e| ≤ a := by intro e have h := hquad (hM.eigenvectorBasis e).ofLp have hn : ∑ i, ((hM.eigenvectorBasis e).ofLp i)^2 = 1 := by have hh := hM.eigenvectorBasis.norm_eq_one e have hs := EuclideanSpace.norm_sq_eq (hM.eigenvectorBasis e) simpa [hh,Real.norm_eq_abs] using hs.symm rw [hn,mul_one] at h simpa [hM.eigenvalues_eq e] using h conv_lhs => rw [hM.spectral_theorem] rw [Unitary.conjStarAlgAut_apply,← Unitary.coe_star,CStarRing.norm_mul_coe_unitary, CStarRing.norm_coe_unitary_mul,Matrix.l2_opNorm_diagonal] exact (pi_norm_le_iff_of_nonneg ha).mpr (fun e => hev e)
theorem sum_star_norm_bound (S : U → Finset E) (M : (u : U) → Matrix (S u) (S u) ℝ) (hM : ∀ u, (M u).IsHermitian) (ε K : ℝ) (hε : 0 ≤ ε) (hK : 0 ≤ K) (hlocal : ∀ u, ‖M u‖ ≤ ε) (hoverlap : ∀ e : E, ((Finset.univ.filter fun u => e ∈ S u).card : ℝ) ≤ K) : ‖∑ u, extendStar (S u) (M u)‖ ≤ K*ε := by have hsym : (∑ u, extendStar (S u) (M u)).IsHermitian := by apply Matrix.IsHermitian.ext intro i j simp only [Matrix.sum_apply,star_sum] apply Finset.sum_congr rfl intro u _ exact (Matrix.isHermitian_mul_mul_conjTranspose (starInclusion (S u)) (hM u)).apply i j apply hermitian_norm_le_of_quadratic _ hsym (K*ε) (mul_nonneg hK hε) intro x have hsum : x ⬝ᵥ ((∑ u, extendStar (S u) (M u)) *ᵥ x) = ∑ u, (fun e : S u => x e.val) ⬝ᵥ (M u *ᵥ fun e : S u => x e.val) := by simp only [Matrix.sum_mulVec,dotProduct_sum,extendStar_quadratic] have hcount : (∑ u, ∑ e : S u, (x e.val)^2) ≤ K * ∑ e, (x e)^2 := by have hrewrite : ∀ u, (∑ e : S u, (x e.val)^2) = ∑ e : E, if e ∈ S u then (x e)^2 else 0 := by intro u rw [← Finset.sum_filter] exact (Finset.sum_subtype (Finset.univ.filter fun e => e ∈ S u) (fun e => by simp only [Finset.mem_filter,Finset.mem_univ,true_and]) (fun e => (x e)^2)).symm simp_rw [hrewrite] rw [Finset.sum_comm,Finset.mul_sum] apply Finset.sum_le_sum intro e _ have heq : (∑ u : U, if e ∈ S u then (x e)^2 else 0) = ((Finset.univ.filter fun u => e ∈ S u).card : ℝ) * (x e)^2 := by rw [← Finset.sum_filter,Finset.sum_const,nsmul_eq_mul] rw [heq] exact mul_le_mul_of_nonneg_right (hoverlap e) (sq_nonneg _) rw [hsum] calc _ ≤ ∑ u, |(fun e : S u => x e.val) ⬝ᵥ (M u *ᵥ fun e : S u => x e.val)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ u, ε * ∑ e : S u, (x e.val)^2 := by apply Finset.sum_le_sum intro u _ exact (matrix_quadratic_abs _ _).trans (mul_le_mul_of_nonneg_right (hlocal u) (Finset.sum_nonneg fun _ _ => sq_nonneg _)) _ = ε * (∑ u, ∑ e : S u, (x e.val)^2) := by rw [Finset.mul_sum] _ ≤ ε * (K * ∑ e, (x e)^2) := mul_le_mul_of_nonneg_left hcount hε _ = K * ε * ∑ e, (x e)^2 := by ring
end SharpTerminalLeave
endend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133import Mathlibimport OAI.Combinatorics.TriangleRemoval.Asymptotics.FreshLogExposeLabeledimport OAI.Combinatorics.TriangleRemoval.Spectral.FreshLogCheckNone2
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeavesection TraceAddressvariable {ι τ : Type*} [Fintype τ] [DecidableEq ι] [DecidableEq τ]
theorem tracedGridQuery_address (H : τ → Finset ι) (N d k : ℕ) (c : QueryCall ι τ) (ν : τ → PMF (Fin N)) {z : (Bool × List (QueryCall ι τ)) × List τ} (hz : z ∈ (ExposureTree.freshLog ν (tracedGridQuery H N d k c)).support) : ∀ a ∈ z.1.2, c.address <:+ a.address := by induction d generalizing k c z with | zero => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,_,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz have heq : y = ((true,[c]),[]) := by simpa [ExposureTree.freshLog] using hy simp [heq] | succ d ih => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,_,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz rw [ExposureTree.freshLog_mapOutput] at hy obtain ⟨w,hw,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hy have hwP := ExposureTree.freshLog_checkNoneTrace_forall ν (fun a : QueryCall ι τ => c.address <:+ a.address) _ (by intro A hA a ha obtain ⟨p,_,rfl⟩ := List.mem_map.mp hA split_ifs at ha with hp · intro b hb exact (List.suffix_cons p.1 c.address).trans (ih _ _ ha b hb) · have heq : a = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using ha simp [heq]) hw intro a ha rcases List.mem_cons.mp ha with rfl | ha · exact ⟨[],rfl⟩ · exact hwP a ha
lemma fork_addresses_ne {α : Type*} {p q : α} {base a b : List α} (hpq : p ≠ q) (ha : p :: base <:+ a) (hb : q :: base <:+ b) : a ≠ b := by intro hab subst b have hh := List.suffix_of_suffix_length_le ha hb (by simp) have heq := hh.eq_of_length (by simp) exact hpq (List.cons.inj heq).1
lemma child_address_ne {α : Type*} {p : α} {base a : List α} (ha : p :: base <:+ a) : base ≠ a := by intro h have hh := ha.length_le simp only [List.length_cons, ← h] at hh omega
theorem tracedGridQuery_address_nodup (H : τ → Finset ι) (N d k : ℕ) (c : QueryCall ι τ) (ν : τ → PMF (Fin N)) {z : (Bool × List (QueryCall ι τ)) × List τ} (hz : z ∈ (ExposureTree.freshLog ν (tracedGridQuery H N d k c)).support) : (z.1.2.map QueryCall.address).Nodup := by induction d generalizing k c z with | zero => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,_,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz have heq : y = ((true,[c]),[]) := by simpa [ExposureTree.freshLog] using hy simp [heq] | succ d ih => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,hx,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz rw [ExposureTree.freshLog_mapOutput] at hy obtain ⟨w,hw,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hy have hxvals := (ExposureTree.freshLog_exposeLabeled_support ν Prod.snd _ hx).1 have hnd : (x.1.map Prod.fst).Nodup := by rw [hxvals]; exact Finset.nodup_toList _ have hsnd := ((List.mergeSort_perm x.1 (fun a b => a.2.val ≤ b.2.val)).map Prod.fst).nodup_iff.mpr hnd have hpair : (x.1.mergeSort (fun a b => a.2.val ≤ b.2.val)).Pairwise (fun a b => a.1 ≠ b.1) := by simpa only [List.Nodup, List.pairwise_map] using hsnd have hwR := ExposureTree.freshLog_checkNoneTrace_pairwise ν (fun a b : QueryCall ι τ => a.address ≠ b.address) _ (by intro A hA a ha obtain ⟨p,_,rfl⟩ := List.mem_map.mp hA split_ifs at ha with hp · have hh := ih _ _ ha simpa only [List.Nodup, List.pairwise_map] using hh · have heq : a = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using ha simp [heq]) (by apply List.pairwise_map.mpr apply hpair.imp intro p q hpq x hx y hy a ha b hb split_ifs at hx hy with hp hq · exact fork_addresses_ne hpq (tracedGridQuery_address H N d _ _ ν hx a ha) (tracedGridQuery_address H N d _ _ ν hy b hb) · have heq : y = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using hy simp [heq] at hb · have heq : x = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using hx simp [heq] at ha · have heq : x = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using hx simp [heq] at ha) hw have hwP := ExposureTree.freshLog_checkNoneTrace_forall ν (fun a : QueryCall ι τ => c.address ≠ a.address) _ (by intro A hA a ha obtain ⟨p,_,rfl⟩ := List.mem_map.mp hA split_ifs at ha with hp · intro b hb exact child_address_ne (tracedGridQuery_address H N d _ _ ν ha b hb) · have heq : a = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using ha simp [heq]) hw simpa only [List.Nodup, List.map_cons, List.pairwise_cons, List.pairwise_map, List.mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] using (And.intro hwP hwR)
end TraceAddressend SharpTerminalLeave
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import Mathlibimport OAI.Combinatorics.TriangleRemoval.Asymptotics.FreshLogExposeLabeled
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeavesection TraceAccountingvariable {ι τ : Type*} [Fintype τ] [DecidableEq ι] [DecidableEq τ]
theorem tracedGridQuery_log (H : τ → Finset ι) (N d k : ℕ) (c : QueryCall ι τ) (ν : τ → PMF (Fin N)) {z : (Bool × List (QueryCall ι τ)) × List τ} (hz : z ∈ (ExposureTree.freshLog ν (tracedGridQuery H N d k c)).support) : z.2 = z.1.2.flatMap (QueryCall.keys H) := by induction d generalizing k c z with | zero => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,hx,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz have heq : y = ((true,[c]),[]) := by simpa [ExposureTree.freshLog] using hy have hkeys := (ExposureTree.freshLog_exposeLabeled_support ν Prod.snd _ hx).2 simp [heq, hkeys, QueryCall.keys] | succ d ih => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,hx,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz rw [ExposureTree.freshLog_mapOutput] at hy obtain ⟨w,hw,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hy have hxkeys := (ExposureTree.freshLog_exposeLabeled_support ν Prod.snd _ hx).2 have hwkeys := ExposureTree.freshLog_checkNoneTrace_support ν (QueryCall.keys H) _ (by intro A hA a ha obtain ⟨p,_,rfl⟩ := List.mem_map.mp hA split_ifs at ha with hp · exact ih _ _ ha · have heq : a = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using ha simp [heq]) hw simp only [List.flatMap_cons, hxkeys, hwkeys, QueryCall.keys]
end TraceAccountingend SharpTerminalLeave
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.TracedGridQueryLogimport OAI.Combinatorics.TriangleRemoval.Queries.Separatedimport OAI.Combinatorics.TriangleRemoval.Spectral.FreshLogCheckNone
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeavesection TrueRepeatedCallvariable {ι τ : Type*} [Fintype τ] [DecidableEq ι] [DecidableEq τ]
theorem tracedGridQuery_separated (H : τ → Finset ι) (hlin : ∀ T S, T ≠ S → (H T ∩ H S).card ≤ 1) (N d k : ℕ) (c : QueryCall ι τ) (hc : c.Separated H) (ν : τ → PMF (Fin N)) {z : (Bool × List (QueryCall ι τ)) × List τ} (hz : z ∈ (ExposureTree.freshLog ν (tracedGridQuery H N d k c)).support) : ∀ a ∈ z.1.2, a.Separated H := by induction d generalizing k c z with | zero => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,_,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz have heq : y = ((true,[c]),[]) := by simpa [ExposureTree.freshLog] using hy simpa [heq] using hc | succ d ih => rw [tracedGridQuery, ExposureTree.freshLog_bind] at hz obtain ⟨x,_,hz⟩ := (PMF.mem_support_bind_iff _ _ _).mp hz obtain ⟨y,hy,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hz rw [ExposureTree.freshLog_mapOutput] at hy obtain ⟨w,hw,rfl⟩ := (PMF.mem_support_map_iff _ _ _).mp hy have hwP := ExposureTree.freshLog_checkNoneTrace_forall ν (fun a => a.Separated H) _ (by intro A hA a ha obtain ⟨p,_,rfl⟩ := List.mem_map.mp hA split_ifs at ha with hp · exact ih _ _ (separated_child H hlin _ _ _) ha · have heq : a = ((false,[]),[]) := by simpa [ExposureTree.freshLog] using ha simp [heq]) hw intro a ha rcases List.mem_cons.mp ha with rfl | ha · exact hc · exact hwP a ha
theorem repeated_flatMap_calls {R K : Type*} [DecidableEq K] (calls : List R) (keys : R → List K) (hc : ∀ c ∈ calls, (keys c).Nodup) (hr : ExposureTree.repeats ∅ (calls.flatMap keys) = true) : ∃ i j : Fin calls.length, i < j ∧ ∃ T, T ∈ keys (calls.get i) ∧ T ∈ keys (calls.get j) := by by_contra hn have hnd : (calls.flatMap keys).Nodup := by apply List.nodup_flatMap.mpr refine ⟨hc, List.pairwise_iff_get.mpr ?_⟩ intro i j hij apply List.disjoint_left.mpr intro T hTi hTj exact hn ⟨i,j,hij,T,hTi,hTj⟩ have hf := (ExposureTree.repeats_empty_false_iff _).mpr hnd rw [hr] at hf contradiction
theorem tracedGridQuery_repeat_calls (H : τ → Finset ι) (hlin : ∀ T S, T ≠ S → (H T ∩ H S).card ≤ 1) (N d k : ℕ) (c : QueryCall ι τ) (hc : c.Separated H) (ν : τ → PMF (Fin N)) {z : (Bool × List (QueryCall ι τ)) × List τ} (hz : z ∈ (ExposureTree.freshLog ν (tracedGridQuery H N d k c)).support) (hr : ExposureTree.repeats ∅ z.2 = true) : ∃ i j : Fin z.1.2.length, i < j ∧ ∃ T, T ∈ (z.1.2.get i).keys H ∧ T ∈ (z.1.2.get j).keys H := by have hp := tracedGridQuery_separated H hlin N d k c hc ν hz rw [tracedGridQuery_log H N d k c ν hz] at hr exact repeated_flatMap_calls _ _ (fun a ha => a.keys_nodup H (hp a ha)) hr
end TrueRepeatedCallend SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246import Mathlibimport OAI.Combinatorics.TriangleRemoval.Embeddings.RerootTemplate
namespace OAI
sectionnoncomputable sectionopen scoped BigOperatorsopen Filter Classical
namespace SharpTerminalLeave
lemma cycleNext_val {j : ℕ} (i : Fin j) : (cycleNext i).val = if i.val+1 < j then i.val+1 else 0 := by unfold cycleNext dsimp split_ifs with h · exact Nat.mod_eq_of_lt h · have he : i.val+1 = j := by omega simp [he]
lemma cycleNext_injective (j : ℕ) : Function.Injective (@cycleNext j) := by intro i k h have hh := congrArg Fin.val h rw [cycleNext_val,cycleNext_val] at hh apply Fin.ext split_ifs at hh <;> omega
lemma cycleNext_ne {j : ℕ} (hj : 2 ≤ j) (i : Fin j) : cycleNext i ≠ i := by intro h have hh := congrArg Fin.val h rw [cycleNext_val] at hh split_ifs at hh <;> omega
lemma cycleNext_twice_ne {j : ℕ} (hj : 3 ≤ j) (i : Fin j) : cycleNext (cycleNext i) ≠ i := by intro h have hh := congrArg Fin.val h have h1 := cycleNext_val i have h2 := cycleNext_val (cycleNext i) split_ifs at h1 h2 <;> omega
def wheelSpoke {j : ℕ} (i : Fin j) : Finset (Fin (j+1)) := {0,i.succ}def wheelRim {j : ℕ} (i : Fin j) : Finset (Fin (j+1)) := {i.succ,(cycleNext i).succ}
lemma wheelSpoke_injective (j : ℕ) : Function.Injective (@wheelSpoke j) := by intro i k h have hh : i.succ ∈ wheelSpoke k := h ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self _) simp only [wheelSpoke,Finset.mem_insert,Finset.mem_singleton] at hh rcases hh with hh | hh · exact (Fin.succ_ne_zero i hh).elim · exact Fin.succ_injective _ hh
lemma wheelRim_injective {j : ℕ} (hj : 3 ≤ j) : Function.Injective (@wheelRim j) := by intro i k h have ha : i.succ ∈ wheelRim k := h ▸ Finset.mem_insert_self _ _ have hb : (cycleNext i).succ ∈ wheelRim k := h ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self _) simp only [wheelRim,Finset.mem_insert,Finset.mem_singleton,Fin.succ_inj] at ha hb rcases ha with rfl | ha · rfl rcases hb with hb | hb · have hh : cycleNext (cycleNext k) = k := by rw [← ha,hb] exact (cycleNext_twice_ne hj k hh).elim · exact ((cycleNext_ne (by omega) i) (hb.trans ha.symm)).elim
lemma wheelSpoke_ne_rim {j : ℕ} (i k : Fin j) : wheelSpoke i ≠ wheelRim k := by intro h have hh : (0 : Fin (j+1)) ∈ wheelRim k := h ▸ Finset.mem_insert_self _ _ simp only [wheelRim,Finset.mem_insert,Finset.mem_singleton,(Ne.symm (Fin.succ_ne_zero _)),or_self] at hh
def wheelTemplate (j : ℕ) (hj : 3 ≤ j) : RootedTemplate (j+1) where edges := Finset.univ.image wheelSpoke ∪ Finset.univ.image wheelRim roots := {0} simple := by intro e he rcases Finset.mem_union.mp he with he | he · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he simp [wheelSpoke,(Ne.symm (Fin.succ_ne_zero _))] · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he have hne : i.succ ≠ (cycleNext i).succ := by intro h; exact cycleNext_ne (by omega) i (Fin.succ_injective _ h).symm simp [wheelRim,hne] independent := by intro e he hsub rcases Finset.mem_union.mp he with he | he · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he have hh := hsub (show i.succ ∈ wheelSpoke i by simp [wheelSpoke]) simp at hh · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he have hh := hsub (show i.succ ∈ wheelRim i by simp [wheelRim]) simp at hh
@[simp] lemma wheelTemplate_roots_card (j : ℕ) (hj : 3 ≤ j) : (wheelTemplate j hj).roots.card = 1 := Finset.card_singleton _
@[simp] lemma wheelTemplate_edges_card (j : ℕ) (hj : 3 ≤ j) : (wheelTemplate j hj).edges.card = 2*j := by have hd : Disjoint (Finset.univ.image (@wheelSpoke j)) (Finset.univ.image (@wheelRim j)) := by apply Finset.disjoint_left.mpr intro e he hf obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he obtain ⟨k,_,hk⟩ := Finset.mem_image.mp hf exact wheelSpoke_ne_rim i k hk.symm rw [wheelTemplate,Finset.card_union_of_disjoint hd, Finset.card_image_of_injective _ (wheelSpoke_injective j), Finset.card_image_of_injective _ (wheelRim_injective hj)] simp omega
lemma wheelTemplate_balanced (j : ℕ) (hj : 3 ≤ j) : RootedTwoBalanced (wheelTemplate j hj) := by intro J hJ have h0 : (0 : Fin (j+1)) ∈ J := hJ (Finset.mem_singleton_self _) let A := Finset.univ.filter (fun i : Fin j => i.succ ∈ J) have hsub : ((wheelTemplate j hj).edges.filter (· ⊆ J)) ⊆ A.image wheelSpoke ∪ A.image wheelRim := by intro e he obtain ⟨he,hsub⟩ := Finset.mem_filter.mp he rcases Finset.mem_union.mp he with he | he · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he exact Finset.mem_union_left _ (Finset.mem_image.mpr ⟨i,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hsub (Finset.mem_insert_of_mem (Finset.mem_singleton_self _))⟩,rfl⟩) · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp he exact Finset.mem_union_right _ (Finset.mem_image.mpr ⟨i,Finset.mem_filter.mpr ⟨Finset.mem_univ _,hsub (Finset.mem_insert_self _ _)⟩,rfl⟩) have hA : A.card ≤ (J.erase 0).card := by apply Finset.card_le_card_of_injOn Fin.succ · intro i hi exact Finset.mem_erase.mpr ⟨Fin.succ_ne_zero i,(Finset.mem_filter.mp hi).2⟩ · intro a _ b _ hab exact Fin.succ_injective _ hab have hc := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) have h1 := Finset.card_image_le (s := A) (f := wheelSpoke) have h2 := Finset.card_image_le (s := A) (f := wheelRim) rw [Finset.card_erase_of_mem h0] at hA rw [wheelTemplate_roots_card] omega
def wheelRoot {j n : ℕ} (hj : 3 ≤ j) (u : Fin n) : {v // v ∈ (wheelTemplate j hj).roots} ↪ Fin n where toFun := fun _ => u inj' := by intro a b _ apply Subtype.ext have ha : a.val = 0 := Finset.mem_singleton.mp a.property have hb : b.val = 0 := Finset.mem_singleton.mp b.property exact ha.trans hb.symm
lemma wheelRooted_zero {j n : ℕ} (hj : 3 ≤ j) (u : Fin n) (φ : RootedInjection (wheelTemplate j hj) (wheelRoot hj u)) : φ.val 0 = u := φ.property ⟨0,Finset.mem_singleton_self _⟩
def wheelRestrict {j n : ℕ} (hj : 3 ≤ j) (u : Fin n) (φ : RootedInjection (wheelTemplate j hj) (wheelRoot hj u)) : Fin j ↪ Fin n := (Fin.succEmb j).trans φ.val
lemma wheel_image_subset {j n : ℕ} (hj : 3 ≤ j) (u : Fin n) (φ : RootedInjection (wheelTemplate j hj) (wheelRoot hj u)) (G : Graph n) : imageEdges (wheelTemplate j hj) φ.val ⊆ G ↔ ∀ i, {u,wheelRestrict hj u φ i} ∈ G ∧ {wheelRestrict hj u φ i,wheelRestrict hj u φ (cycleNext i)} ∈ G := by have hs (i : Fin j) : (wheelSpoke i).map φ.val = {u,wheelRestrict hj u φ i} := by simp [wheelSpoke,wheelRestrict,wheelRooted_zero hj u φ] have hr (i : Fin j) : (wheelRim i).map φ.val = {wheelRestrict hj u φ i,wheelRestrict hj u φ (cycleNext i)} := by simp [wheelRim,wheelRestrict] constructor · intro h i constructor · rw [← hs] exact h (Finset.mem_image.mpr ⟨wheelSpoke i,Finset.mem_union_left _ (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩),rfl⟩) · rw [← hr] exact h (Finset.mem_image.mpr ⟨wheelRim i,Finset.mem_union_right _ (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩),rfl⟩) · intro h e he obtain ⟨f,hf,rfl⟩ := Finset.mem_image.mp he rcases Finset.mem_union.mp hf with hf | hf · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hf rw [hs]; exact (h i).1 · obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hf rw [hr]; exact (h i).2
lemma wheelRestrict_injective {j n : ℕ} (hj : 3 ≤ j) (u : Fin n) : Function.Injective (wheelRestrict hj u) := by intro φ χ h apply Subtype.ext apply Function.Embedding.ext intro i refine Fin.cases ?_ (fun i => ?_) i · exact (wheelRooted_zero hj u φ).trans (wheelRooted_zero hj u χ).symm · exact congrArg (fun f : Fin j ↪ Fin n => f i) h
lemma wheelRestrict_surj {j n : ℕ} (hj : 3 ≤ j) (u : Fin n) (φ : Fin j ↪ Fin n) (havoid : ∀ i, φ i ≠ u) : ∃ χ : RootedInjection (wheelTemplate j hj) (wheelRoot hj u), wheelRestrict hj u χ = φ := by let f : Fin (j+1) → Fin n := Fin.cases u φ have hf : Function.Injective f := by intro a b h revert h refine Fin.cases ?_ (fun a => ?_) a · refine Fin.cases ?_ (fun b => ?_) b · intro _; rfl · intro h; exact (havoid b h.symm).elim · refine Fin.cases ?_ (fun b => ?_) b · intro h; exact (havoid a h).elim · intro h; exact congrArg Fin.succ (φ.injective h) let χ : RootedInjection (wheelTemplate j hj) (wheelRoot hj u) := ⟨⟨f,hf⟩,by intro v; have hv : v.val = 0 := Finset.mem_singleton.mp v.property; change f v.val = u; rw [hv]; rfl⟩ exact ⟨χ,by ext i; rfl⟩
theorem wheel_rootedCount {j n : ℕ} (hj : 3 ≤ j) (G : Graph n) (hG : G ⊆ completeGraph n) (u : Fin n) : rootedCount (wheelTemplate j hj) (wheelRoot hj u) G = linkCycleCount j G u := by let A := Finset.univ.filter (fun φ : RootedInjection (wheelTemplate j hj) (wheelRoot hj u) => imageEdges (wheelTemplate j hj) φ.val ⊆ G) let B := Finset.univ.filter (fun φ : Fin j ↪ Fin n => ∀ i, {u,φ i} ∈ G ∧ {φ i,φ (cycleNext i)} ∈ G) have hA : rootedCount (wheelTemplate j hj) (wheelRoot hj u) G = (A.card : ℝ) := by simp [rootedCount,copyCount,intact,A] have hB : linkCycleCount j G u = (B.card : ℝ) := by simp [linkCycleCount,B,Finset.sum_boole] rw [hA,hB] congr 1 apply Finset.card_bij (fun φ _ => wheelRestrict hj u φ) · intro φ hφ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,(wheel_image_subset hj u φ G).mp (Finset.mem_filter.mp hφ).2⟩ · intro φ _ χ _ h exact wheelRestrict_injective hj u h · intro φ hφ have hp := (Finset.mem_filter.mp hφ).2 have hav : ∀ i, φ i ≠ u := by intro i he have hh := mem_completeGraph.mp (hG (hp i).1) simp [he] at hh obtain ⟨χ,hχ⟩ := wheelRestrict_surj hj u φ hav refine ⟨χ,Finset.mem_filter.mpr ⟨Finset.mem_univ _,?_⟩,hχ⟩ exact (wheel_image_subset hj u χ G).mpr (hχ.symm ▸ hp)
@[simp] theorem wheel_rootedScaling {j n : ℕ} (hj : 3 ≤ j) (p : ℝ) : rootedScaling (wheelTemplate j hj) n p = ((n : ℝ)*p^2)^j := by simp only [rootedScaling,wheelTemplate_roots_card,wheelTemplate_edges_card,Nat.add_sub_cancel, mul_pow,← pow_mul]
end SharpTerminalLeaveendend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.TriangleHypergraphReindeximport OAI.Combinatorics.TriangleRemoval.Stability.CavityWeightimport OAI.Combinatorics.TriangleRemoval.Process.PathRequired
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeave
lemma active_cavity_factor_product {n : ℕ} (G : Graph n) (e : G) (T : triangles G) (t : ℝ) : (∏ f ∈ (triangleHypergraph G T.val).erase e.val, cavityLimit (triangleHypergraph G) f (some T.val) t) = ∏ f ∈ (activeHypergraph G T).erase e, cavityLimit (activeHypergraph G) f (some T) t := by change (∏ f ∈ (triangleHypergraph G (triangleEmbedding G T)).erase (edgeEmbedding G e), _) = _ rw [triangleHypergraph_reindex,← Finset.map_erase,Finset.prod_map] apply Finset.prod_congr rfl intro f _ exact active_cavity_eq G f (some T) t
lemma active_messageIntegral {n : ℕ} (G : Graph n) (e : G) (T : triangles G) (t : ℝ) : messageIntegral (triangleHypergraph G) (cavityLimit (triangleHypergraph G)) e.val T.val t = messageIntegral (activeHypergraph G) (cavityLimit (activeHypergraph G)) e T t := by unfold messageIntegral apply intervalIntegral.integral_congr intro s _ exact active_cavity_factor_product G e T s
lemma goodPrefix_full_continuous_rows {c : ℝ} (hc : 0 < c) : ∀ᶠ n : ℕ in atTop, 0 < prefixD n ∧ ∀ (C : ℝ) (G : Graph n), GoodPrefixGraph n c C G → ∀ t ∈ Set.Icc (0 : ℝ) 1, ∀ (e T : Finset (Fin n)), e ∈ triangleHypergraph G T → messageIntegral (triangleHypergraph G) (cavityLimit (triangleHypergraph G)) e T t ≤ 1/16 ∧ (∏ f ∈ (triangleHypergraph G T).erase e, cavityLimit (triangleHypergraph G) f (some T) t) ≤ (17/16 : ℝ)*cavityWeight (prefixD n) t := by filter_upwards [goodPrefix_continuous_rows hc] with n hn refine ⟨hn.1,?_⟩ intro C G hG t ht e T he have heG := triangleHypergraph_subset G T he have hT : T ∈ triangles G := by by_contra hT simp only [triangleHypergraph,hT,ite_false,Finset.notMem_empty] at he let ee : G := ⟨e,heG⟩ let TT : triangles G := ⟨T,hT⟩ have heact : ee ∈ activeHypergraph G TT := by have hh : edgeEmbedding G ee ∈ (activeHypergraph G TT).map (edgeEmbedding G) := by rw [← triangleHypergraph_reindex] exact he exact Finset.mem_map.mp hh |>.elim (fun _ ha => (edgeEmbedding G).injective ha.2 ▸ ha.1) obtain ⟨h1,h2⟩ := hn.2 C G hG t ht rw [show e = ee.val from rfl,show T = TT.val from rfl, active_messageIntegral,active_cavity_factor_product] exact ⟨h1 ee TT heact,h2 ee TT heact⟩
theorem goodPrefix_full_grid_rows {c : ℝ} (hc : 0 < c) : ∀ᶠ n : ℕ in atTop, ∀ (C : ℝ) (G : Graph n), GoodPrefixGraph n c C G → ∃ N₀ : ℕ, ∀ (N : ℕ) [NeZero N], N₀ ≤ N → GridRowQuality (triangleHypergraph G) N (fun k => cavityWeight (prefixD n) ((k : ℝ)/N)) := by filter_upwards [goodPrefix_full_continuous_rows hc] with n hn intro C G h let H := triangleHypergraph G let A : ℝ := (Fintype.card (Finset (Fin n)) : ℝ)*gridUniformError H + (Fintype.card (Finset (Fin n)) : ℝ)*Fintype.card (Finset (Fin n)) let B : ℝ := 2*gridUniformError H have hA : Tendsto (fun N : ℕ => A/(N : ℝ)) atTop (𝓝 0) := tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop (R := ℝ)) have hB : Tendsto (fun N : ℕ => B/(N : ℝ)) atTop (𝓝 0) := tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop (R := ℝ)) have hsmall : ∀ᶠ N : ℕ in atTop, A/(N : ℝ) ≤ 1/16 ∧ B/(N : ℝ) ≤ cavityWeight (prefixD n) 1/16 := by filter_upwards [hA.eventually_le_const (by norm_num : (0 : ℝ) < 1/16), hB.eventually_le_const (show 0 < cavityWeight (prefixD n) 1/16 from div_pos (cavityWeight_pos hn.1.le zero_le_one) (by norm_num))] with N ha hb exact ⟨ha,hb⟩ obtain ⟨N₀,hN₀⟩ := eventually_atTop.mp hsmall refine ⟨N₀,?_⟩ intro N _ hN have hNpos : (0 : ℝ) < N := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne N) have ht (k : ℕ) (hk : k ≤ N) : (k : ℝ)/N ∈ Set.Icc (0 : ℝ) 1 := ⟨by positivity,(div_le_one hNpos).mpr (by exact_mod_cast hk)⟩ obtain ⟨ha,hb⟩ := hN₀ N hN constructor · intro k hk e T he obtain ⟨hi,_⟩ := hn.2 C G h _ (ht k hk) e T he have herr := gridCandidateFailure_error H N k hk e T change |gridCandidateFailure H N k e T - _| ≤ A/(N : ℝ) at herr have hh := (abs_le.mp herr).1 dsimp only [H] at hh linarith · intro k hk e T he obtain ⟨_,hp⟩ := hn.2 C G h _ (ht k hk) e T he have hT : T ∈ triangles G := by by_contra hh simp only [triangleHypergraph,hh,ite_false,Finset.notMem_empty] at he have hcard : ((H T).erase e).card = 2 := by rw [Finset.card_erase_of_mem he] simp only [triangleHypergraph,hT,ite_true,Finset.card_powersetCard,(mem_triangles.mp hT).1] decide have herr := gridAnswer_uniform_error H N k hk ((H T).erase e) (some T) rw [hcard] at herr have herr' := (abs_le.mp herr).2 have hbl := cavityWeight_lower hn.1.le (ht k hk) dsimp only [B,H] at hb herr' linarith
end SharpTerminalLeave
open scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361import Mathlibimport OAI.Combinatorics.TriangleRemoval.Coupling.UnitTimeimport OAI.Combinatorics.TriangleRemoval.Process.TripleFactorBoundsimport OAI.Combinatorics.TriangleRemoval.Process.VariationConstants
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen Filteropen scoped BigOperators Topology
sectionopen scoped BigOperators Topology BoundedContinuousFunctionopen scoped BigOperatorsopen Filter MeasureTheoryopen scoped Topology
namespace SharpTerminalLeavesection CavityStabilityvariable {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] [DecidableEq τ]
noncomputable def cavityGenerator (H : τ → Finset ι) (D : ℝ) : (ι → ℝ) →L[ℝ] (ι → ℝ) := ContinuousLinearMap.pi fun e => (1 / D) • ∑ T ∈ messageCandidates H e none, ∑ f ∈ (H T).erase e, ContinuousLinearMap.proj f
omit [Fintype ι] in@[simp] theorem cavityGenerator_apply (H : τ → Finset ι) (D : ℝ) (z : ι → ℝ) (e : ι) : cavityGenerator H D z e = (1 / D) * ∑ T ∈ messageCandidates H e none, ∑ f ∈ (H T).erase e, z f := by simp [cavityGenerator]
noncomputable def cavityVelocity (H : τ → Finset ι) (D : ℝ) (s : ℝ) (e : ι) : ℝ := 1 - Real.exp (2 * s) / D * ∑ T ∈ messageCandidates H e none, (∏ f ∈ (H T).erase e, cavityLimit H f (some T) (cavityTime D s)) / (1 - cavityMessage H D e T s)
noncomputable def cavityResidual (H : τ → Finset ι) (D : ℝ) (s : ℝ) : ι → ℝ := cavityVelocity H D s + cavityGenerator H D (fun e => cavityLog H D e s)
theorem cavityMessage_derivative_bound (H : τ → Finset ι) {D δ s : ℝ} (hD : 0 < D) (hδ : δ ≤ 1 / 2) (hcard : ∀ T, (H T).card = 3) (hz : ∀ f, |cavityLog H D f s| ≤ δ) (hI : ∀ f T, f ∈ H T → cavityMessage H D f T s ≤ 1 / 2) (ht : cavityTime D s ∈ Set.Ioo (0 : ℝ) 1) (e : ι) (T : τ) (he : e ∈ H T) : deriv (cavityMessage H D e T) s ≤ 12 / D := by rw [(cavityMessage_hasDerivAt H D e T ht).deriv] obtain ⟨f, g, hfg, hset, hf, hg⟩ := triangle_children (hcard T) he have heq := cavity_triangle_message_summand H D e T hfg hset hf hg ht.2 have hprod : 1 / 4 ≤ (1 - cavityMessage H D f T s) * (1 - cavityMessage H D g T s) := by have h1 : 1 / 2 ≤ 1 - cavityMessage H D f T s := by linarith [hI f T hf] have h2 : 1 / 2 ≤ 1 - cavityMessage H D g T s := by linarith [hI g T hg] nlinarith [mul_le_mul h1 h2 (by norm_num : (0 : ℝ) ≤ 1 / 2) (by linarith)] have he2 : Real.exp (cavityLog H D f s + cavityLog H D g s) ≤ 3 := by apply (Real.exp_le_exp.mpr (show cavityLog H D f s + cavityLog H D g s ≤ 1 from by linarith [(abs_le.mp (hz f)).2, (abs_le.mp (hz g)).2])).trans exact Real.exp_one_lt_d9.le.trans (by norm_num) have hb : Real.exp (2 * s) * (∏ u ∈ (H T).erase e, cavityLimit H u (some T) (cavityTime D s)) ≤ 12 := by rw [heq] apply (div_le_iff₀ (by linarith : 0 < (1 - cavityMessage H D f T s) * (1 - cavityMessage H D g T s))).mpr linarith calc _ = (Real.exp (2 * s) * ∏ u ∈ (H T).erase e, cavityLimit H u (some T) (cavityTime D s)) / D := by ring _ ≤ _ := div_le_div_of_nonneg_right hb hD.le
theorem cavityMessage_bound (H : τ → Finset ι) {D δ s : ℝ} (hD : 0 < D) (hs : 0 ≤ s) (hδ : δ ≤ 1 / 2) (hcard : ∀ T, (H T).card = 3) (hz : ∀ u ∈ Set.Icc 0 s, ∀ f, |cavityLog H D f u| ≤ δ) (hI : ∀ u ∈ Set.Icc 0 s, ∀ f T, f ∈ H T → cavityMessage H D f T u ≤ 1 / 2) (ht : cavityTime D s < 1) (e : ι) (T : τ) (he : e ∈ H T) : cavityMessage H D e T s ≤ 12 * s / D := by have hi : ∀ u ∈ Set.Ioo 0 s, cavityTime D u ∈ Set.Ioo (0 : ℝ) 1 := by intro u hu exact ⟨cavityTime_pos hD hu.1, (cavityTime_mono hD hu.2.le).trans_lt ht⟩ have hh := (convex_Icc (0 : ℝ) s).image_sub_le_mul_sub_of_deriv_le (continuous_cavityMessage H D e T).continuousOn (fun u hu => ((cavityMessage_hasDerivAt H D e T (hi u (by simpa using hu))).differentiableAt).differentiableWithinAt) (C := 12 / D) (fun u hu => by have hu' : u ∈ Set.Ioo 0 s := by simpa only [interior_Icc] using hu exact cavityMessage_derivative_bound H hD hδ hcard (hz u ⟨hu'.1.le, hu'.2.le⟩) (hI u ⟨hu'.1.le, hu'.2.le⟩) (hi u hu') e T he) 0 ⟨le_rfl, hs⟩ s ⟨hs, le_rfl⟩ hs simpa only [cavityMessage_zero, sub_zero, div_mul_eq_mul_div] using hh
theorem cavityResidual_bound (H : τ → Finset ι) {D δ ε η s : ℝ} (hD : 0 < D) (hδ : δ ≤ 1 / 2) (hε : 0 ≤ ε) (hε' : ε ≤ 1 / 2) (hη : 0 ≤ η) (hcard : ∀ T, (H T).card = 3) (hdeg : ∀ e, |((messageCandidates H e none).card : ℝ) / D - 1| ≤ η) (hrow : ∀ e, ((messageCandidates H e none).card : ℝ) / D ≤ 2) (hz : ∀ e, |cavityLog H D e s| ≤ δ) (hI : ∀ e T, e ∈ H T → cavityMessage H D e T s ≤ ε) (ht : cavityTime D s < 1) : ‖cavityResidual H D s‖ �� η + 64 * δ ^ 2 + 96 * ε := by apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr intro e let R : τ → ℝ := fun T => Real.exp (2 * s) * ((∏ f ∈ (H T).erase e, cavityLimit H f (some T) (cavityTime D s)) / (1 - cavityMessage H D e T s)) let L : τ → ℝ := fun T => ∑ f ∈ (H T).erase e, cavityLog H D f s have hres : cavityResidual H D s e = 1 - (1 / D) * (∑ T ∈ messageCandidates H e none, R T) + (1 / D) * (∑ T ∈ messageCandidates H e none, L T) := by simp only [cavityResidual, Pi.add_apply, cavityVelocity, cavityGenerator_apply, R, L, ← Finset.mul_sum] ring rw [Real.norm_eq_abs, hres] have hb := cavity_row_error (messageCandidates H e none) R L hD (show 0 ≤ 32 * δ ^ 2 + 48 * ε by positivity) (hdeg e) (hrow e) (by intro T hT have he : e ∈ H T := (Finset.mem_filter.mp hT).2.1 obtain ⟨f, g, hfg, hset, hf, hg⟩ := triangle_children (hcard T) he have hR := cavity_triangle_summand H D e T hfg hset hf hg ht have hL : L T = cavityLog H D f s + cavityLog H D g s := by simp only [L, hset, Finset.sum_pair hfg] dsimp only [R] rw [hR, hL] convert cavity_summand_taylor hδ (hz f) (hz g) hε' ⟨cavityMessage_nonneg H D e T s, hI e T he⟩ ⟨cavityMessage_nonneg H D f T s, hI f T hf⟩ ⟨cavityMessage_nonneg H D g T s, hI g T hg⟩ using 1 congr 1 ring) nlinarith
theorem continuousOn_cavityVelocity (H : τ → Finset ι) {D S : ℝ} (hD : 0 < D) (hS : cavityTime D S < 1) : ContinuousOn (cavityVelocity H D) (Set.Icc 0 S) := by apply continuousOn_pi.mpr intro e unfold cavityVelocity apply continuousOn_const.sub apply ContinuousOn.mul · exact ((Real.continuous_exp.comp (continuous_const.mul continuous_id)).div_const D).continuousOn · apply continuousOn_finsetSum intro T _ apply ContinuousOn.div · apply continuousOn_finsetProd intro f _ exact ((continuous_cavityLimit H f (some T)).comp (continuous_cavityTime D)).continuousOn · exact continuousOn_const.sub (continuous_cavityMessage H D e T).continuousOn · intro s hs exact (cavityLimit_factor_pos H e T ((cavityTime_mono hD hs.2).trans_lt hS)).ne'
theorem continuousOn_cavityLog_vector (H : τ → Finset ι) {D S : ℝ} (hD : 0 < D) (hS : cavityTime D S < 1) : ContinuousOn (fun s e => cavityLog H D e s) (Set.Icc 0 S) := continuousOn_pi.mpr (continuousOn_cavityLog H hD hS)
theorem continuousOn_cavityResidual (H : τ → Finset ι) {D S : ℝ} (hD : 0 < D) (hS : cavityTime D S < 1) : ContinuousOn (cavityResidual H D) (Set.Icc 0 S) := (continuousOn_cavityVelocity H hD hS).add ((cavityGenerator H D).continuous.comp_continuousOn (continuousOn_cavityLog_vector H hD hS))
theorem cavityLog_provisional_bound (H : τ → Finset ι) {D δ η K s : ℝ} (hD : 0 < D) (hs : 0 ≤ s) (hδ : δ ≤ 1 / 2) (hη : 0 ≤ η) (hK : 0 ≤ K) (hcard : ∀ T, (H T).card = 3) (hdeg : ∀ e, |((messageCandidates H e none).card : ℝ) / D - 1| ≤ η) (hrow : ∀ e, ((messageCandidates H e none).card : ℝ) / D ≤ 2) (hz : ∀ u ∈ Set.Icc 0 s, ∀ e, |cavityLog H D e u| ≤ δ) (hI : ∀ u ∈ Set.Icc 0 s, ∀ e T, e ∈ H T → cavityMessage H D e T u ≤ 1 / 2) (ht : cavityTime D s < 1) (hsmall : 12 * s / D ≤ 1 / 2) (hsem : ∀ u ∈ Set.Icc 0 s, ‖NormedSpace.exp ((-u) • cavityGenerator H D)‖ ≤ K) : ‖fun e => cavityLog H D e s‖ ≤ K * (η + 64 * δ ^ 2 + 1152 * s / D) * s := by have hi : ∀ u ∈ Set.Icc 0 s, ∀ e T, e ∈ H T → cavityMessage H D e T u ≤ 12 * s / D := by intro u hu e T he apply (cavityMessage_bound H hD hu.1 hδ hcard (fun v hv => hz v ⟨hv.1, hv.2.trans hu.2⟩) (fun v hv => hI v ⟨hv.1, hv.2.trans hu.2⟩) ((cavityTime_mono hD hu.2).trans_lt ht) e T he).trans exact div_le_div_of_nonneg_right (by linarith [hu.2]) hD.le have hh := forcing_norm_bound (cavityGenerator H D) (fun u e => cavityLog H D e u) (cavityResidual H D) hs hK (continuousOn_cavityLog_vector H hD ht) (continuousOn_cavityResidual H hD ht) (funext (cavityLog_zero H D)) (by intro u hu apply hasDerivAt_pi.mpr intro e convert cavityLog_hasDerivAt H D e ⟨cavityTime_pos hD hu.1, (cavityTime_mono hD hu.2.le).trans_lt ht⟩ using 1 dsimp [cavityResidual, cavityVelocity] ring) hsem (d := η + 64 * δ ^ 2 + 1152 * s / D) (by intro u hu have hr := cavityResidual_bound H hD hδ (by positivity : 0 ≤ 12 * s / D) hsmall hη hcard hdeg hrow (hz u hu) (hi u hu) ((cavityTime_mono hD hu.2).trans_lt ht) convert hr using 1 ring) exact hh
noncomputable def cavityIncidentMessages (H : τ → Finset ι) (D s : ℝ) : ι × τ → ℝ := fun p => if p.1 ∈ H p.2 then cavityMessage H D p.1 p.2 s else 0
theorem continuous_cavityIncidentMessages (H : τ → Finset ι) (D : ℝ) : Continuous (cavityIncidentMessages H D) := by apply continuous_pi intro p by_cases hp : p.1 ∈ H p.2 · simpa only [cavityIncidentMessages, ite_eq_left hp] using continuous_cavityMessage H D p.1 p.2 · simpa only [cavityIncidentMessages, ite_eq_right hp] using (continuous_const : Continuous (fun _ : ℝ => (0 : ℝ)))
@[simp] theorem cavityIncidentMessages_zero (H : τ → Finset ι) (D : ℝ) : cavityIncidentMessages H D 0 = 0 := by ext p simp [cavityIncidentMessages]
theorem cavityIncidentMessages_norm_iff (H : τ → Finset ι) (D s b : ℝ) (hb : 0 ≤ b) : ‖cavityIncidentMessages H D s‖ ≤ b ↔ ∀ e T, e ∈ H T → cavityMessage H D e T s ≤ b := by rw [pi_norm_le_iff_of_nonneg hb] constructor · intro hh e T he simpa only [cavityIncidentMessages, ite_eq_left he, Real.norm_eq_abs, abs_of_nonneg (cavityMessage_nonneg H D e T s)] using hh (e, T) · intro hh p by_cases hp : p.1 ∈ H p.2 · simpa only [cavityIncidentMessages, ite_eq_left hp, Real.norm_eq_abs, abs_of_nonneg (cavityMessage_nonneg H D p.1 p.2 s)] using hh p.1 p.2 hp · simpa only [cavityIncidentMessages, ite_eq_right hp, norm_zero] using hb
theorem cavity_strict_continuation (H : τ → Finset ι) {D S δ η K : ℝ} (hD : 0 < D) (hS : 0 ≤ S) (hδ : 0 < δ) (hδ' : δ ≤ 1 / 2) (hη : 0 ≤ η) (hK : 0 ≤ K) (hcard : ∀ T, (H T).card = 3) (hdeg : ∀ e, |((messageCandidates H e none).card : ℝ) / D - 1| ≤ η) (hrow : ∀ e, ((messageCandidates H e none).card : ℝ) / D ≤ 2) (ht : cavityTime D S < 1) (hsmall : 12 * S / D ≤ 1 / 4) (himprove : K * (η + 64 * δ ^ 2 + 1152 * S / D) * S ≤ δ / 2) (hsem : ∀ u ∈ Set.Icc 0 S, ‖NormedSpace.exp ((-u) • cavityGenerator H D)‖ ≤ K) : ∀ s ∈ Set.Icc 0 S, (∀ e, |cavityLog H D e s| ≤ δ / 2) ∧ (∀ e T, e ∈ H T → cavityMessage H D e T s ≤ 12 * s / D) := by let Q : ℝ → ℝ := fun s => max (‖fun e => cavityLog H D e s‖ / δ) (2 * ‖cavityIncidentMessages H D s‖) have hQ : ContinuousOn Q (Set.Icc 0 S) := ((continuousOn_cavityLog_vector H hD ht).norm.div_const δ).sup (continuousOn_const.mul (continuous_cavityIncidentMessages H D).continuousOn.norm) have hzero : Q 0 ≤ 1 := by simp only [Q, cavityLog_zero, show (fun _ : ι => (0 : ℝ)) = 0 from rfl, norm_zero, zero_div, cavityIncidentMessages_zero, mul_zero, max_self, zero_le_one] have hdecode : ∀ s, Q s ≤ 1 → (∀ e, |cavityLog H D e s| ≤ δ) ∧ (∀ e T, e ∈ H T → cavityMessage H D e T s ≤ 1 / 2) := by intro s hh have hm := max_le_iff.mp hh constructor · have hb : ‖fun e => cavityLog H D e s‖ ≤ δ := by exact (div_le_one hδ).mp hm.1 simpa only [Real.norm_eq_abs] using (pi_norm_le_iff_of_nonneg hδ.le).mp hb · apply (cavityIncidentMessages_norm_iff H D s _ (by norm_num)).mp linarith [hm.2] have hboot : ∀ s ∈ Set.Icc 0 S, Q s ≤ 1 / 2 := by apply strict_bootstrap (δ := 1) (by norm_num) hQ hzero intro s hs hp have hz := fun u hu => (hdecode u (hp u hu)).1 have hI := fun u hu => (hdecode u (hp u hu)).2 have ht' : cavityTime D s < 1 := (cavityTime_mono hD hs.2).trans_lt ht have hsmall' : 12 * s / D ≤ 1 / 4 := (div_le_div_of_nonneg_right (by linarith [hs.2]) hD.le).trans hsmall apply max_le_iff.mpr constructor · apply (div_le_iff₀ hδ).mpr have hh := cavityLog_provisional_bound H hD hs.1 hδ' hη hK hcard hdeg hrow hz hI ht' (by linarith) (fun u hu => hsem u ⟨hu.1, hu.2.trans hs.2⟩) have hforce : η + 64 * δ ^ 2 + 1152 * s / D ≤ η + 64 * δ ^ 2 + 1152 * S / D := by have := div_le_div_of_nonneg_right (by linarith [hs.2] : 1152 * s ≤ 1152 * S) hD.le linarith have hcmp : K * (η + 64 * δ ^ 2 + 1152 * s / D) * s ≤ K * (η + 64 * δ ^ 2 + 1152 * S / D) * S := by apply mul_le_mul (mul_le_mul_of_nonneg_left hforce hK) hs.2 hs.1 positivity linarith [hh.trans hcmp, himprove] · have hm : ‖cavityIncidentMessages H D s‖ ≤ 12 * s / D := by apply (cavityIncidentMessages_norm_iff H D s _ (div_nonneg (mul_nonneg (by norm_num) hs.1) hD.le)).mpr exact cavityMessage_bound H hD hs.1 hδ' hcard hz hI ht' linarith intro s hs have hpre : ∀ u ∈ Set.Icc 0 s, Q u ≤ 1 := fun u hu => (hboot u ⟨hu.1, hu.2.trans hs.2⟩).trans (by norm_num) constructor · have hh := (max_le_iff.mp (hboot s hs)).1 have hn : ‖fun e => cavityLog H D e s‖ ≤ δ / 2 := by have := (div_le_iff₀ hδ).mp hh linarith simpa only [Real.norm_eq_abs] using (pi_norm_le_iff_of_nonneg (by positivity)).mp hn · exact cavityMessage_bound H hD hs.1 hδ' hcard (fun u hu => (hdecode u (hpre u hu)).1) (fun u hu => (hdecode u (hpre u hu)).2) ((cavityTime_mono hD hs.2).trans_lt ht)
omit [Fintype ι] [Fintype τ] [DecidableEq ��] [DecidableEq τ] intheorem cavityTime_strictMono {D : ℝ} (hD : 0 < D) : StrictMono (cavityTime D) := by intro s t hst apply div_lt_div_of_pos_right _ (by positivity) exact sub_lt_sub_right (Real.exp_lt_exp.mpr (by linarith)) _
theorem cavity_closed_continuation (H : τ → Finset ι) {D S δ η K : ℝ} (hD : 0 < D) (hS : 0 < S) (hδ : 0 < δ) (hδ' : δ ≤ 1 / 2) (hη : 0 ≤ η) (hK : 0 ≤ K) (hcard : ∀ T, (H T).card = 3) (hdeg : ∀ e, |((messageCandidates H e none).card : ℝ) / D - 1| ≤ η) (hrow : ∀ e, ((messageCandidates H e none).card : ℝ) / D ≤ 2) (ht : cavityTime D S ≤ 1) (hsmall : 12 * S / D ≤ 1 / 4) (himprove : K * (η + 64 * δ ^ 2 + 1152 * S / D) * S ≤ δ / 2) (hsem : ∀ u ∈ Set.Icc 0 S, ‖NormedSpace.exp ((-u) • cavityGenerator H D)‖ ≤ K) : ∀ s ∈ Set.Icc 0 S, (∀ e, Real.exp (-s - δ / 2) ≤ cavityLimit H e none (cavityTime D s) ∧ cavityLimit H e none (cavityTime D s) ≤ Real.exp (-s + δ / 2)) ∧ (∀ e T, e ∈ H T → cavityMessage H D e T s ≤ 12 * s / D) := by have hpre : ∀ s ∈ Set.Ico 0 S, (∀ e, Real.exp (-s - δ / 2) ≤ cavityLimit H e none (cavityTime D s) ∧ cavityLimit H e none (cavityTime D s) ≤ Real.exp (-s + δ / 2)) ∧ (∀ e T, e ∈ H T → cavityMessage H D e T s ≤ 12 * s / D) := by intro s hs have ht' : cavityTime D s < 1 := (cavityTime_strictMono hD hs.2).trans_le ht have hsmall' : 12 * s / D ≤ 1 / 4 := (div_le_div_of_nonneg_right (by linarith [hs.2]) hD.le).trans hsmall have hforce : η + 64 * δ ^ 2 + 1152 * s / D ≤ η + 64 * δ ^ 2 + 1152 * S / D := by linarith [div_le_div_of_nonneg_right (by linarith [hs.2] : 1152 * s ≤ 1152 * S) hD.le] have hcmp : K * (η + 64 * δ ^ 2 + 1152 * s / D) * s ≤ K * (η + 64 * δ ^ 2 + 1152 * S / D) * S := by apply mul_le_mul (mul_le_mul_of_nonneg_left hforce hK) hs.2.le hs.1 positivity have hh := cavity_strict_continuation H hD hs.1 hδ hδ' hη hK hcard hdeg hrow ht' hsmall' (hcmp.trans himprove) (fun u hu => hsem u ⟨hu.1, hu.2.trans hs.2.le⟩) s ⟨hs.1, le_rfl⟩ refine ⟨?_, hh.2⟩ intro e rw [cavityLog_exp H D e ht'] constructor <;> apply Real.exp_le_exp.mpr <;> linarith [(abs_le.mp (hh.1 e)).1, (abs_le.mp (hh.1 e)).2] have hclose {P : ℝ → Prop} (hp : IsClosed {s | P s}) (hh : ∀ s ∈ Set.Ico 0 S, P s) : ∀ s ∈ Set.Icc 0 S, P s := by have hx : closure (Set.Ico 0 S) ⊆ {s | P s} := closure_minimal hh hp simpa only [closure_Ico hS.ne, Set.subset_def, Set.mem_ofPred_eq] using hx intro s hs constructor · intro e have hc := (continuous_cavityLimit H e none).comp (continuous_cavityTime D) constructor · exact hclose (isClosed_le (Real.continuous_exp.comp (continuous_id.neg.sub continuous_const)) hc) (fun u hu => (hpre u hu).1 e |>.1) s hs · exact hclose (isClosed_le hc (Real.continuous_exp.comp (continuous_id.neg.add continuous_const))) (fun u hu => (hpre u hu).1 e |>.2) s hs · intro e T he exact hclose (isClosed_le (continuous_cavityMessage H D e T) ((continuous_const.mul continuous_id).div_const D)) (fun u hu => (hpre u hu).2 e T he) s hs
end CavityStabilityend SharpTerminalLeave
end
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.IncidentTriangleThirdimport OAI.Combinatorics.TriangleRemoval.Process.ActivePairMembershipimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixHorizon
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
lemma goodPrefix_active_degree {n : ℕ} {c C : ℝ} {G : Graph n} (h : GoodPrefixGraph n c C G) (hD : 0 < prefixD n) (e : G) : |((messageCandidates (activeHypergraph G) e none).card : ℝ)/prefixD n-1| ≤ (n : ℝ)^(-c) := by classical rw [active_messageCandidates_card] obtain ⟨u,v,huv,hev⟩ := Finset.card_eq_two.mp (mem_completeGraph.mp (h.1 e.property)) have heG : ({u,v} : Finset (Fin n)) ∈ G := hev ▸ e.property rw [hev,triangleDegree_eq_codegree h.1 heG] have hcode := h.2.2.2.1 u v huv have heq : (currentCodegree G u v : ℝ)/prefixD n-1 = ((currentCodegree G u v : ℝ)-prefixD n)/prefixD n := by rw [sub_div,div_self hD.ne'] rw [heq,abs_div,abs_of_pos hD] exact (div_le_iff₀ hD).mpr hcode
lemma cavityTime_prefixHorizon {n : ℕ} (hD : 0 < prefixD n) : cavityTime (prefixD n) (prefixHorizon n) = 1 := by unfold cavityTime prefixHorizon rw [show 2*(Real.log (1+2*prefixD n)/2)=Real.log (1+2*prefixD n) by ring, Real.exp_log (by linarith : 0 < 1+2*prefixD n)] field_simp ring
theorem goodPrefix_cavity_continuation {c : ℝ} (hc : 0 < c) : ∃ a : ℝ, 0 < a ∧ a < min c (1/1000 : ℝ) ∧ ∀ᶠ n : ℕ in atTop, ∀ (C : ℝ) (G : Graph n), GoodPrefixGraph n c C G → ∀ s ∈ Set.Icc (0 : ℝ) (prefixHorizon n), (∀ e : G, Real.exp (-s-(n : ℝ)^(-a)/2) ≤ cavityLimit (activeHypergraph G) e none (cavityTime (prefixD n) s) ∧ cavityLimit (activeHypergraph G) e none (cavityTime (prefixD n) s) ≤ Real.exp (-s+(n : ℝ)^(-a)/2)) ∧ (∀ (e : G) (T : triangles G), e ∈ activeHypergraph G T → cavityMessage (activeHypergraph G) (prefixD n) e T s ≤ 12*s/prefixD n) := by obtain ⟨C₁,hC₁,J,hsem⟩ := goodPrefix_cavity_semigroup hc obtain ⟨a,ha,hac,hnum⟩ := prefix_bootstrap_numerics hc hC₁ J refine ⟨a,ha,hac,?_⟩ filter_upwards [hsem,hnum,prefix_scales_eventually_pos,eventually_ge_atTop (1 : ℕ)] with n hsem hnum hp hn intro C G h have hD : 0 < prefixD n := lt_of_lt_of_le zero_lt_one hp.2 have hδc : (n : ℝ)^(-c) ≤ (n : ℝ)^(-a) := Real.rpow_le_rpow_of_exponent_le (by exact_mod_cast hn) (by linarith [(lt_min_iff.mp hac).1]) apply cavity_closed_continuation (activeHypergraph G) (K := C₁*(1+Real.log (n : ℝ))^J) hD hnum.2.2.1 hnum.1 hnum.2.1 (Real.rpow_nonneg (Nat.cast_nonneg n) _) (by positivity) (activeHypergraph_card G) (goodPrefix_active_degree h hD) · intro e have hh := (abs_le.mp (goodPrefix_active_degree h hD e)).2 linarith [hnum.2.1] · exact (cavityTime_prefixHorizon hD).le · exact hnum.2.2.2.2.1 · exact hnum.2.2.2.2.2 · intro s hs exact hsem C G h s ⟨hs.1,hs.2.trans hnum.2.2.2.1⟩
noncomputable def cavityReference (D t : ℝ) : ℝ := (1+2*D*t)^(-(1/2 : ℝ))noncomputable def cavityClock (D t : ℝ) : ℝ := Real.log (1+2*D*t)/2
lemma cavityClock_mem {D t : ℝ} (hD : 0 < D) (ht : t ∈ Set.Icc (0 : ℝ) 1) : cavityClock D t ∈ Set.Icc (0 : ℝ) (Real.log (1+2*D)/2) := by have harg : 1 ≤ 1+2*D*t := by nlinarith [ht.1] have hlo := Real.log_nonneg harg have hhi := Real.log_le_log (by linarith : 0 < 1+2*D*t) (by nlinarith [ht.2] : 1+2*D*t ≤ 1+2*D) exact ⟨by dsimp [cavityClock]; linarith,by dsimp [cavityClock]; linarith⟩
lemma cavityTime_clock {D t : ℝ} (hD : 0 < D) (ht : 0 ≤ t) : cavityTime D (cavityClock D t) = t := by unfold cavityTime cavityClock rw [show 2*(Real.log (1+2*D*t)/2)=Real.log (1+2*D*t) by ring, Real.exp_log (by nlinarith : 0 < 1+2*D*t)] field_simp ring
lemma cavityReference_exp {D t : ℝ} (hD : 0 < D) (ht : 0 ≤ t) : cavityReference D t = Real.exp (-cavityClock D t) := by rw [cavityReference,Real.rpow_def_of_pos (by nlinarith : 0 < 1+2*D*t)] congr 1 dsimp [cavityClock] ring
lemma cavityReference_pos {D t : ℝ} (hD : 0 < D) (ht : 0 ≤ t) : 0 < cavityReference D t := by rw [cavityReference_exp hD ht]; positivity
theorem goodPrefix_cavity_relative {c : ℝ} (hc : 0 < c) : ∃ a : ℝ, 0 < a ∧ ∀ᶠ n : ℕ in atTop, let δ := (n : ℝ)^(-a) let Imax := 12*prefixHorizon n/prefixD n Imax ≤ 1/4 ∧ ∀ (C : ℝ) (G : Graph n), GoodPrefixGraph n c C G → ∀ t ∈ Set.Icc (0 : ℝ) 1, (∀ e : G, Real.exp (-δ/2) ≤ cavityLimit (activeHypergraph G) e none t / cavityReference (prefixD n) t ∧ cavityLimit (activeHypergraph G) e none t / cavityReference (prefixD n) t ≤ Real.exp (δ/2)) ∧ (∀ (e : G) (T : triangles G), e ∈ activeHypergraph G T → messageIntegral (activeHypergraph G) (cavityLimit (activeHypergraph G)) e T t ≤ Imax ∧ Real.exp (-δ/2) ≤ cavityLimit (activeHypergraph G) e (some T) t / cavityReference (prefixD n) t ∧ cavityLimit (activeHypergraph G) e (some T) t / cavityReference (prefixD n) t ≤ Real.exp (δ/2)/(1-Imax)) := by obtain ⟨a,ha,hac,hcont⟩ := goodPrefix_cavity_continuation hc obtain ⟨C₁,hC₁,J,_⟩ := goodPrefix_cavity_semigroup hc obtain ⟨b,hb,_,hnum⟩ := prefix_bootstrap_numerics hc hC₁ J refine ⟨a,ha,?_⟩ filter_upwards [hcont,hnum,prefix_scales_eventually_pos] with n hcavity hn hp dsimp only have hD : 0 < prefixD n := lt_of_lt_of_le zero_lt_one hp.2 have hI : 12*prefixHorizon n/prefixD n ≤ 1/4 := hn.2.2.2.2.1 refine ⟨hI,?_⟩ intro C G h t ht let s := cavityClock (prefixD n) t have hs : s ∈ Set.Icc (0 : ℝ) (prefixHorizon n) := cavityClock_mem hD ht have hst : cavityTime (prefixD n) s = t := cavityTime_clock hD ht.1 obtain ⟨hq,hmsg⟩ := hcavity C G h s hs rw [hst] at hq have href := cavityReference_exp hD ht.1 have href0 := cavityReference_pos hD ht.1 have helo : Real.exp (-s-(n : ℝ)^(-a)/2) = Real.exp (-(n : ℝ)^(-a)/2)*cavityReference (prefixD n) t := by rw [href,← Real.exp_add] congr 1 dsimp [s] ring have hehi : Real.exp (-s+(n : ℝ)^(-a)/2) = Real.exp ((n : ℝ)^(-a)/2)*cavityReference (prefixD n) t := by rw [href,← Real.exp_add] congr 1 dsimp [s] ring have hroot (e : G) := hq e simp only [helo,hehi] at hroot constructor · intro e exact ⟨(le_div_iff₀ href0).mpr (hroot e).1,(div_le_iff₀ href0).mpr (hroot e).2⟩ · intro e T he let I := messageIntegral (activeHypergraph G) (cavityLimit (activeHypergraph G)) e T t have hI0 : 0 ≤ I := (messageIntegral_mem_unit _ _ (continuous_cavityLimit _) (cavityLimit_mem_unit _) _ _ _).1 have hIm : I ≤ 12*prefixHorizon n/prefixD n := by have hh := hmsg e T he change messageIntegral _ _ _ _ (cavityTime (prefixD n) s) ≤ _ at hh rw [hst] at hh exact hh.trans (div_le_div_of_nonneg_right (by linarith [hs.2]) hD.le) have hIf : 0 < 1-I := by linarith have hMax : 0 < 1-12*prefixHorizon n/prefixD n := by linarith have ho := cavityLimit_omission (activeHypergraph G) e T he t change cavityLimit (activeHypergraph G) e none t = cavityLimit (activeHypergraph G) e (some T) t * (1-I) at ho have hparent : cavityLimit (activeHypergraph G) e (some T) t = cavityLimit (activeHypergraph G) e none t/(1-I) := (eq_div_iff hIf.ne').mpr ho.symm refine ⟨hIm,?_,?_⟩ · apply (le_div_iff₀ href0).mpr have hpar0 := (cavityLimit_mem_unit (activeHypergraph G) e (some T) t).1 have hm : cavityLimit (activeHypergraph G) e none t ≤ cavityLimit (activeHypergraph G) e (some T) t := by rw [ho]; nlinarith exact (hroot e).1.trans hm · rw [hparent] calc _ = (cavityLimit (activeHypergraph G) e none t/cavityReference (prefixD n) t)/(1-I) := by ring _ ≤ Real.exp ((n : ℝ)^(-a)/2)/(1-12*prefixHorizon n/prefixD n) := div_le_div₀ (by positivity) ((div_le_iff₀ href0).mpr (hroot e).2) hMax (by linarith)end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138import Mathlibimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixMessageEnvelopeSmallimport OAI.Combinatorics.TriangleRemoval.Coupling.GridUniformError
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeave
noncomputable def cavityWeight (D t : ℝ) : ℝ := 1/(1+2*D*t)
lemma cavityReference_sq {D t : ℝ} (hD : 0 ≤ D) (ht : 0 ≤ t) : cavityReference D t ^ 2 = cavityWeight D t := by have hx : 0 ≤ 1+2*D*t := by positivity unfold cavityReference cavityWeight rw [← Real.rpow_mul_natCast hx] norm_num [Real.rpow_neg_one]
lemma cavityWeight_pos {D t : ℝ} (hD : 0 ≤ D) (ht : 0 ≤ t) : 0 < cavityWeight D t := by unfold cavityWeight; positivity
lemma cavityWeight_lower {D t : ℝ} (hD : 0 ≤ D) (ht : t ∈ Set.Icc (0 : ℝ) 1) : cavityWeight D 1 ≤ cavityWeight D t := by unfold cavityWeight have ht0 := ht.1 apply one_div_le_one_div_of_le · positivity · nlinarith [ht.2]
theorem goodPrefix_continuous_rows {c : ℝ} (hc : 0 < c) : ∀ᶠ n : ℕ in atTop, 0 < prefixD n ∧ ∀ (C : ℝ) (G : Graph n), GoodPrefixGraph n c C G → ∀ t ∈ Set.Icc (0 : ℝ) 1, (∀ (e : G) (T : triangles G), e ∈ activeHypergraph G T → messageIntegral (activeHypergraph G) (cavityLimit (activeHypergraph G)) e T t ≤ 1/16) ∧ (∀ (e : G) (T : triangles G), e ∈ activeHypergraph G T → (∏ f ∈ (activeHypergraph G T).erase e, cavityLimit (activeHypergraph G) f (some T) t) ≤ (17/16 : ℝ)*cavityWeight (prefixD n) t) := by obtain ⟨a,ha,hrel⟩ := goodPrefix_cavity_relative hc filter_upwards [goodPrefix_cavity_stability hc (by norm_num : (0 : ℝ) < 1/64), hrel,prefix_message_envelope_small (by norm_num : (0 : ℝ) < 1/16), prefix_scales_eventually_pos] with n hs hr hi hp have hD : 0 < prefixD n := lt_of_lt_of_le zero_lt_one hp.2 refine ⟨hD,?_⟩ intro C G h t ht refine ⟨fun e T he => ((hr.2 C G h t ht).2 e T he).1.trans hi.2,?_⟩ intro e T he have hcard : ((activeHypergraph G T).erase e).card = 2 := by rw [Finset.card_erase_of_mem he,activeHypergraph_card] have href := cavityReference_pos hD ht.1 have hprod : (∏ f ∈ (activeHypergraph G T).erase e, cavityLimit (activeHypergraph G) f (some T) t) ≤ ((65/64 : ℝ)*cavityReference (prefixD n) t)^2 := by calc _ ≤ ∏ _f ∈ (activeHypergraph G T).erase e, (65/64 : ℝ)*cavityReference (prefixD n) t := by apply Finset.prod_le_prod₀ · intro f _; exact (cavityLimit_mem_unit _ _ _ _).1 · intro f hf have hh := (abs_le.mp ((hs C G h t ht).2 f T (Finset.mem_of_mem_erase hf))).2 apply (div_le_iff₀ href).mp linarith _ = _ := by simp [hcard] calc _ ≤ ((65/64 : ℝ)*cavityReference (prefixD n) t)^2 := hprod _ = (65/64 : ℝ)^2*cavityWeight (prefixD n) t := by rw [mul_pow,cavityReference_sq hD.le ht.1] _ ≤ _ := mul_le_mul_of_nonneg_right (by norm_num) (cavityWeight_pos hD.le ht.1).le
theorem goodPrefix_grid_rows {c : ℝ} (hc : 0 < c) : ∀ᶠ n : ℕ in atTop, ∀ (C : ℝ) (G : Graph n), GoodPrefixGraph n c C G → ∃ N₀ : ℕ, ∀ (N : ℕ) [NeZero N], N₀ ≤ N → ∀ k ≤ N, (∀ (e : G) (T : triangles G), e ∈ activeHypergraph G T → (7/8 : ℝ) ≤ gridCandidateFailure (activeHypergraph G) N k e T) ∧ (∀ (e : G) (T : triangles G), e ∈ activeHypergraph G T → gridAnswerProbability (activeHypergraph G) N N k ((activeHypergraph G T).erase e) (some T) ≤ (9/8 : ℝ)*cavityWeight (prefixD n) ((k : ℝ)/N)) := by filter_upwards [goodPrefix_continuous_rows hc] with n hn intro C G h let H := activeHypergraph G let A : ℝ := (Fintype.card G : ℝ)*gridUniformError H + (Fintype.card G : ℝ)*Fintype.card (triangles G) let B : ℝ := 2*gridUniformError H have hA : Tendsto (fun N : ℕ => A/(N : ℝ)) atTop (𝓝 0) := tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop (R := ℝ)) have hB : Tendsto (fun N : ℕ => B/(N : ℝ)) atTop (𝓝 0) := tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop (R := ℝ)) have hsmall : ∀ᶠ N : ℕ in atTop, A/(N : ℝ) ≤ 1/16 ∧ B/(N : ℝ) ≤ cavityWeight (prefixD n) 1/16 := by filter_upwards [hA.eventually_le_const (by norm_num : (0 : ℝ) < 1/16), hB.eventually_le_const (show 0 < cavityWeight (prefixD n) 1/16 from div_pos (cavityWeight_pos hn.1.le zero_le_one) (by norm_num))] with N ha hb exact ⟨ha,hb⟩ obtain ⟨N₀,hN₀⟩ := eventually_atTop.mp hsmall refine ⟨N₀,?_⟩ intro N _ hN k hk have hNpos : (0 : ℝ) < N := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne N) have ht : (k : ℝ)/N ∈ Set.Icc (0 : ℝ) 1 := ⟨by positivity,(div_le_one hNpos).mpr (by exact_mod_cast hk)⟩ obtain ⟨hi,hpair⟩ := hn.2 C G h _ ht obtain ⟨ha,hb⟩ := hN₀ N hN constructor · intro e T he have herr := gridCandidateFailure_error H N k hk e T have herr' := (abs_le.mp herr).1 have hh := hi e T he change _ ≤ A/(N : ℝ) at herr dsimp only [A] at ha dsimp only [H] at herr' linarith · intro e T he have hcard : ((H T).erase e).card = 2 := by rw [Finset.card_erase_of_mem he,activeHypergraph_card] have herr := gridAnswer_uniform_error H N k hk ((H T).erase e) (some T) rw [hcard] at herr have herr' := (abs_le.mp herr).2 have hp := hpair e T he have hbl := cavityWeight_lower hn.1.le ht dsimp only [B,H] at hb herr' norm_num only [Nat.cast_ofNat] at herr' linarith
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119import Mathlibimport OAI.Combinatorics.TriangleRemoval.Stability.CavityWeightimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixWeightimport OAI.Combinatorics.TriangleRemoval.Process.WitnessMu
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filteropen scoped BigOperators
namespace SharpTerminalLeaveopen Filter MeasureTheoryopen scoped BigOperators Topology
lemma cavityWeight_lipschitz {D : ℝ} (hD : 0 ≤ D) {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) : |cavityWeight D x - cavityWeight D y| ≤ (2*D)*|x-y| := by have hx1 : 1 ≤ 1+2*D*x := by nlinarith [mul_nonneg hD hx] have hy1 : 1 ≤ 1+2*D*y := by nlinarith [mul_nonneg hD hy] have hx0 : 0 < 1+2*D*x := by linarith have hy0 : 0 < 1+2*D*y := by linarith have he : cavityWeight D x - cavityWeight D y = (2*D*(y-x))/((1+2*D*x)*(1+2*D*y)) := by unfold cavityWeight field_simp ring rw [he,abs_div,abs_mul,abs_of_nonneg (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) hD), abs_of_pos (mul_pos hx0 hy0),abs_sub_comm y x] have hden : 1 ≤ (1+2*D*x)*(1+2*D*y) := by nlinarith exact (div_le_iff₀ (mul_pos hx0 hy0)).mpr (by nlinarith [mul_nonneg (mul_nonneg (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) hD) (abs_nonneg (x-y))) (sub_nonneg.mpr hden)])
lemma continuous_clipped_cavityWeight {D : ℝ} (hD : 0 ≤ D) : Continuous (fun t => cavityWeight D (unitTime t)) := by unfold cavityWeight apply Continuous.div continuous_const (continuous_const.add (continuous_const.mul continuous_unitTime)) intro t change 1 + 2*D*unitTime t ≠ 0 have ht := mul_nonneg (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) hD) (unitTime_nonneg t) linarith
lemma cavityWeight_integral {D : ℝ} (hD : 0 < D) : (∫ t in (0 : ℝ)..1, cavityWeight D (unitTime t)) = witnessMu D := by have hc : 2*D ≠ 0 := by positivity have he : (∫ t in (0 : ℝ)..1, cavityWeight D (unitTime t)) = ∫ t in (0 : ℝ)..1, 1/(1+(2*D)*t) := by apply intervalIntegral.integral_congr intro t ht rw [Set.uIcc_of_le (by norm_num : (0 : ℝ) ≤ 1)] at ht simp only [unitTime_of_mem ht,cavityWeight] rw [he,intervalIntegral.integral_comp_add_mul (fun x : ℝ => 1/x) hc 1] simp only [mul_zero,add_zero,mul_one,smul_eq_mul] rw [integral_one_div_of_pos (by norm_num : (0 : ℝ) < 1) (by linarith : 0 < 1+2*D)] simp only [div_one,witnessMu] ring
theorem gridWitnessWeight_error {D : ℝ} (hD : 0 < D) (N : ℕ) (hN : 0 < N) : |prefixWeight (fun j => (2/(N : ℝ))*cavityWeight D ((j : ℝ)/N)) N - 2*witnessMu D| ≤ 4*D/N := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hh := uniform_grid_quadrature (fun t => cavityWeight D (unitTime t)) (continuous_clipped_cavityWeight hD.le) (by positivity : (0 : ℝ) ≤ 2*D) (fun x hx y hy => by rw [unitTime_of_mem hx,unitTime_of_mem hy] exact cavityWeight_lipschitz hD.le hx.1 hy.1) N N hN le_rfl rw [div_self (ne_of_gt hNr),cavityWeight_integral hD] at hh have hs : (∑ j ∈ Finset.range N, cavityWeight D (unitTime ((j : ℝ)/N))) = ∑ j ∈ Finset.range N, cavityWeight D ((j : ℝ)/N) := by apply Finset.sum_congr rfl intro j hj rw [unitTime_of_mem ⟨by positivity,(div_le_one hNr).mpr (by exact_mod_cast (Finset.mem_range.mp hj).le)⟩] rw [hs,abs_sub_comm] at hh have he : prefixWeight (fun j => (2/(N : ℝ))*cavityWeight D ((j : ℝ)/N)) N - 2*witnessMu D = 2*((1/(N : ℝ))*(∑ j ∈ Finset.range N, cavityWeight D ((j : ℝ)/N)) - witnessMu D) := by unfold prefixWeight rw [← Finset.mul_sum] ring rw [he,abs_mul,abs_of_pos (by norm_num : (0 : ℝ) < 2)] calc _ ≤ 2*(2*D/N) := mul_le_mul_of_nonneg_left hh (by norm_num) _ = _ := by ring
theorem gridWitnessWeight_tendsto {D : ℝ} (hD : 0 < D) : Tendsto (fun N : ℕ => prefixWeight (fun j => (2/((N+1 : ℕ) : ℝ))*cavityWeight D ((j : ℝ)/(N+1 : ℕ))) (N+1)) atTop (𝓝 (2*witnessMu D)) := by have hz : Tendsto (fun N : ℕ => 4*D/((N+1 : ℕ) : ℝ)) atTop (𝓝 0) := by have h := (tendsto_const_nhds (x := 4*D)).mul (tendsto_one_div_add_atTop_nhds_zero_nat : Tendsto (fun N : ℕ => (1 : ℝ)/(N+1)) atTop (𝓝 0)) simpa only [Nat.cast_add,Nat.cast_one,mul_zero,div_eq_mul_inv,one_mul] using h have hl : Tendsto (fun N : ℕ => 2*witnessMu D - 4*D/((N+1 : ℕ) : ℝ)) atTop (𝓝 (2*witnessMu D)) := by simpa only [sub_zero] using (tendsto_const_nhds (x := 2*witnessMu D)).sub hz have hu : Tendsto (fun N : ℕ => 2*witnessMu D + 4*D/((N+1 : ℕ) : ℝ)) atTop (𝓝 (2*witnessMu D)) := by simpa only [add_zero] using (tendsto_const_nhds (x := 2*witnessMu D)).add hz apply tendsto_of_tendsto_of_tendsto_of_le_of_le hl hu · intro N have h := (abs_le.mp (gridWitnessWeight_error hD (N+1) (by omega))).1 linarith · intro N have h := (abs_le.mp (gridWitnessWeight_error hD (N+1) (by omega))).2 linarith
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111import Mathlibimport OAI.Combinatorics.TriangleRemoval.Stability.CavityWeightLipschitz
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeave
lemma continuous_cavityWeight_clip {D : ℝ} (hD : 0 ≤ D) : Continuous (fun t => cavityWeight D (unitTime t)) := by unfold cavityWeight apply continuous_const.div (continuous_const.add ((continuous_const.mul continuous_const).mul continuous_unitTime)) intro t have ht := unitTime_nonneg t apply ne_of_gt change 0 < 1+2*D*unitTime t have hh : 0 ≤ 2*D*unitTime t := mul_nonneg (mul_nonneg (by norm_num) hD) ht linarith
lemma cavityWeight_lipschitz_cell {D x y : ℝ} (hD : 0 ≤ D) (hx : 0 ≤ x) (hy : 0 ≤ y) : |cavityWeight D x - cavityWeight D y| ≤ (2*D)*|x-y| := by have ha : 1 ≤ 1+2*D*x := le_add_of_nonneg_right (mul_nonneg (mul_nonneg (by norm_num) hD) hx) have hb : 1 ≤ 1+2*D*y := le_add_of_nonneg_right (mul_nonneg (mul_nonneg (by norm_num) hD) hy) have ha0 : 0 < 1+2*D*x := lt_of_lt_of_le zero_lt_one ha have hb0 : 0 < 1+2*D*y := lt_of_lt_of_le zero_lt_one hb have hid : 1/(1+2*D*x)-1/(1+2*D*y) = (2*D*(y-x))/((1+2*D*x)*(1+2*D*y)) := by field_simp ring unfold cavityWeight rw [hid,abs_div,abs_mul,abs_of_nonneg (by positivity : 0 ≤ 2*D), abs_of_pos (mul_pos ha0 hb0),abs_sub_comm y x] exact div_le_self (by positivity) (one_le_mul_of_one_le_of_one_le ha hb)
theorem grid_prefixWeight_tendsto {D : ℝ} (hD : 0 < D) : Tendsto (fun j : ℕ => prefixWeight (fun t => (2/((j+1 : ℕ) : ℝ))*cavityWeight D ((t : ℝ)/(j+1 : ℕ))) (j+1)) atTop (𝓝 (2*witnessMu D)) := by have hquad (j : ℕ) : |prefixWeight (fun t => (2/((j+1 : ℕ) : ℝ))*cavityWeight D ((t : ℝ)/(j+1 : ℕ))) (j+1) - 2*witnessMu D| ≤ 4*D/((j+1 : ℕ) : ℝ) := by have hN : 0 < j+1 := Nat.succ_pos j have hNr : (0 : ℝ) < (j+1 : ℕ) := by exact_mod_cast hN have hh := uniform_grid_quadrature (fun t => cavityWeight D (unitTime t)) (continuous_cavityWeight_clip hD.le) (show 0 ≤ 2*D by positivity) (fun x hx y hy => by rw [unitTime_of_mem hx,unitTime_of_mem hy] exact cavityWeight_lipschitz_cell hD.le hx.1 hy.1) (j+1) (j+1) hN le_rfl rw [div_self (ne_of_gt hNr),cavityWeight_integral hD] at hh have heq : (∑ t ∈ Finset.range (j+1), cavityWeight D (unitTime ((t : ℝ)/(j+1 : ℕ)))) = ∑ t ∈ Finset.range (j+1), cavityWeight D ((t : ℝ)/(j+1 : ℕ)) := by apply Finset.sum_congr rfl intro t ht rw [unitTime_of_mem ⟨by positivity,(div_le_one hNr).mpr (by exact_mod_cast (Finset.mem_range.mp ht).le)⟩] rw [heq] at hh have hb := mul_le_mul_of_nonneg_left hh (by norm_num : (0 : ℝ) ≤ 2) calc _ = 2*|witnessMu D - (1/((j+1 : ℕ) : ℝ))* ∑ t ∈ Finset.range (j+1), cavityWeight D ((t : ℝ)/(j+1 : ℕ))| := by unfold prefixWeight rw [← Finset.mul_sum] rw [show (2 : ℝ) = |(2 : ℝ)| by norm_num, ← abs_mul, ← abs_neg] congr 1 ring _ ≤ _ := by calc _ ≤ 2*(2*D/((j+1 : ℕ) : ℝ)) := hb _ = _ := by ring have hden : Tendsto (fun j : ℕ => (4*D)/((j+1 : ℕ) : ℝ)) atTop (𝓝 0) := by have hh := tendsto_one_div_add_atTop_nhds_zero_nat.mul_const (4*D) simpa only [Nat.cast_add,Nat.cast_one,mul_comm,one_div,div_eq_mul_inv,one_mul,zero_mul] using hh apply tendsto_iff_norm_sub_tendsto_zero.mpr exact squeeze_zero (fun _ => norm_nonneg _) (fun j => by rw [Real.norm_eq_abs]; exact hquad j) hden
lemma collision_exponential_identity {D : ℝ} (hD : 0 < D) : (1+2*D)^3*Real.exp (45*D*(2*witnessMu D)) = (1+2*D)^48 := by have he : 45*D*(2*witnessMu D) = 45*Real.log (1+2*D) := by unfold witnessMu field_simp rw [he,show (45 : ℝ) = (45 : ℕ) by norm_num,Real.exp_nat_mul, Real.exp_log (by linarith : 0 < 1+2*D),← pow_add]
lemma collision_power_48_bound {D : ℝ} (hD : 1 ≤ D) : (1+2*D)^48/D^50 ≤ (3 : ℝ)^48/D^2 := by have hpos : 0 < D := lt_of_lt_of_le zero_lt_one hD have hh := div_le_div_of_nonneg_right (pow_le_pow_left₀ (by positivity : 0 ≤ 1+2*D) (by linarith : 1+2*D ≤ 3*D) 48) (by positivity : 0 ≤ D^50) apply hh.trans_eq rw [mul_pow,show 50 = 48+2 by norm_num,pow_add] field_simp
end SharpTerminalLeave
open Filteropen scoped BigOperators Topology
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117import Mathlibimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixEdgeRadiusimport OAI.Combinatorics.TriangleRemoval.Process.TriangleIndex
namespace OAI
sectionnoncomputable sectionopen scoped BigOperatorsopen Filter Classical
namespace SharpTerminalLeave
noncomputable def edgeStabilityRate (s t Q : ℝ) : ℝ := s^2/(Q*t)noncomputable def edgeStabilityScalar (s t Q κ : ℝ) : ℝ := s/t-1-2*edgeStabilityRate s t Q+κ*s/(Q*t)
lemma triangle_relative_inverse_bound {Q S r : ℝ} (hS : 0 < S) (hr : r ≤ 1/2) (h : |Q/S-1| ≤ r) : 0 < Q ∧ |1-S/Q| ≤ 2*r ∧ S/Q ≤ 2 := by obtain ⟨hl,hu⟩ := abs_le.mp h have hlow : S/2 ≤ Q := by have hh : 1/2 ≤ Q/S := by linarith have hh' := (le_div_iff₀ hS).mp hh linarith only [hh'] have hQ : 0 < Q := lt_of_lt_of_le (by positivity) hlow have hab : |Q-S| ≤ r*S := by have he : Q/S-1 = (Q-S)/S := by field_simp rw [he,abs_div,abs_of_pos hS] at h exact (div_le_iff₀ hS).mp h have hratio : S/Q ≤ 2 := (div_le_iff₀ hQ).mpr (by linarith) have hr0 : 0 ≤ r := (abs_nonneg _).trans h refine ⟨hQ,?_,hratio⟩ have he : 1-S/Q = (Q-S)/Q := by field_simp rw [he,abs_div,abs_of_pos hQ] calc _ ≤ r*S/Q := div_le_div_of_nonneg_right hab hQ.le _ = r*(S/Q) := by ring _ ≤ _ := by nlinarith only [mul_le_mul_of_nonneg_left hratio hr0]
lemma edge_stability_coefficients {s t Q S lam r κ : ℝ} (hs : 0 < s) (ht : 0 < t) (hS : 0 < S) (hl : 0 ≤ lam) (hscale : t = s*(1-lam)^2) (hratio : s ≤ 2*t) (hident : s = lam*S) (hr : r ≤ 1/2) (hQerr : |Q/S-1| ≤ r) (hκ : 0 ≤ κ) (hκ1 : κ ≤ 1) : (0 ≤ edgeStabilityRate s t Q ∧ edgeStabilityRate s t Q ≤ 4*lam) ∧ |edgeStabilityScalar s t Q κ| ≤ 8*r*lam+2*lam^2+4*lam/s := by obtain ⟨hQ,habs,hSQ⟩ := triangle_relative_inverse_bound hS hr hQerr have hr0 : 0 ≤ r := (abs_nonneg _).trans hQerr have hsQ : s/Q ≤ 2*lam := by rw [hident,mul_div_assoc] simpa only [mul_comm lam 2] using mul_le_mul_of_nonneg_left hSQ hl have hsQdiff : |lam-s/Q| ≤ 2*r*lam := by have he : lam-s/Q = lam*(1-S/Q) := by rw [hident]; ring rw [he,abs_mul,abs_of_nonneg hl] nlinarith only [mul_le_mul_of_nonneg_left habs hl] have hsT : s/t ≤ 2 := (div_le_iff₀ ht).mpr hratio have haeq : edgeStabilityRate s t Q = (s/t)*(s/Q) := by unfold edgeStabilityRate; ring have hbeq : edgeStabilityScalar s t Q κ = (s/t)*(2*(lam-s/Q)-lam^2+κ/Q) := by unfold edgeStabilityScalar edgeStabilityRate apply (mul_right_cancel₀ ht.ne') field_simp [hs.ne',ht.ne',hQ.ne'] rw [hscale] ring constructor · rw [haeq] exact ⟨by positivity,(mul_le_mul hsT hsQ (by positivity) (by norm_num)).trans_eq (by ring)⟩ · have hκQ : |κ/Q| ≤ 2*lam/s := by rw [abs_of_nonneg (div_nonneg hκ hQ.le)] apply (le_div_iff₀ hs).mpr have hh := div_le_div_of_nonneg_right hκ1 hQ.le have hm := mul_le_mul_of_nonneg_right hh hs.le calc _ ≤ (1/Q)*s := hm _ = s/Q := by ring _ ≤ _ := hsQ have hb : |2*(lam-s/Q)-lam^2+κ/Q| ≤ 4*r*lam+lam^2+2*lam/s := by calc _ ≤ |2*(lam-s/Q)-lam^2|+|κ/Q| := abs_add_le _ _ _ ≤ |2*(lam-s/Q)|+|lam^2|+|κ/Q| := by linarith only [abs_sub (2*(lam-s/Q)) (lam^2)] _ ≤ 4*r*lam+lam^2+2*lam/s := by rw [abs_mul,abs_of_nonneg (by norm_num : (0 : ℝ) ≤ 2),abs_of_nonneg (sq_nonneg lam)] linarith only [hsQdiff,hκQ] rw [hbeq,abs_mul,abs_of_pos (div_pos hs ht)] calc _ ≤ 2*(4*r*lam+lam^2+2*lam/s) := mul_le_mul hsT hb (abs_nonneg _) (by norm_num) _ = _ := by ring
lemma early_codegree_grid {n i : ℕ} (hn : 0 < n) (hp : 1/(n : ℝ) ≤ prefixDensity n) (hi : i < prefixTime n) : earlyTemplateScale 1 2 n (i+1) = earlyTemplateScale 1 2 n i* (1-6/(n : ℝ)^2/earlyDensity n i)^2 ∧ earlyTemplateScale 1 2 n i = (6/(n : ℝ)^2/earlyDensity n i)*earlyTriangleScale n i ∧ 0 ≤ 6/(n : ℝ)^2/earlyDensity n i ∧ 6/(n : ℝ)^2/earlyDensity n i ≤ 6/(n : ℝ) := by have hnR : (0 : ℝ) < n := by exact_mod_cast hn have hpi := early_density_positive hn hp hi.le have hs := earlyDensity_succ n i have he : earlyDensity n (i+1) = earlyDensity n i*(1-6/(n : ℝ)^2/earlyDensity n i) := by have he : earlyDensity n (i+1) = earlyDensity n i-6/(n : ℝ)^2 := by linarith only [hs] rw [he] field_simp refine ⟨?_,?_,by positivity,?_⟩ · simp only [earlyTemplateScale,pow_one,he,mul_pow]; ring · unfold earlyTriangleScale simp only [earlyTemplateScale,pow_one] field_simp · have hp' := hp.trans (earlyDensity_antitone n hi.le) apply (div_le_iff₀ hpi).mpr have hm := mul_le_mul_of_nonneg_left hp' (show 0 ≤ 6/(n : ℝ) by positivity) convert hm using 1 field_simp
end SharpTerminalLeaveendend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123import Mathlib
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeave
theorem geometric_volterra_identity (a c : ℝ) (k : ℕ) : c + a * (∑ j ∈ Finset.range k, c * (1 + a) ^ j) = c * (1 + a) ^ k := by induction k with | zero => simp | succ k ih => rw [Finset.sum_range_succ, pow_succ] nlinarith [ih]
theorem discrete_volterra_bound (E : ℕ → ℝ) (a c : ℝ) (ha : 0 ≤ a) (M : ℕ) (hE : ∀ k ≤ M, E k ≤ c + a * ∑ j ∈ Finset.range k, E j) (k : ℕ) (hk : k ≤ M) : E k ≤ c * (1 + a) ^ k := by induction k using Nat.strong_induction_on with | h k ih => calc E k ≤ c + a * ∑ j ∈ Finset.range k, E j := hE k hk _ ≤ c + a * ∑ j ∈ Finset.range k, c * (1 + a) ^ j := by gcongr with j hj exact ih j (Finset.mem_range.mp hj) ((Nat.le_of_lt (Finset.mem_range.mp hj)).trans hk) _ = c * (1 + a) ^ k := geometric_volterra_identity a c k
theorem discrete_volterra_exp_bound (E : ℕ → ℝ) (A C : ℝ) (hA : 0 ≤ A) (hC : 0 ≤ C) (N : ℕ) (hN : 0 < N) (hE : ∀ k ≤ N, E k ≤ C / N + (A / N) * ∑ j ∈ Finset.range k, E j) (k : ℕ) (hk : k ≤ N) : E k ≤ (C / N) * Real.exp A := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hd : 0 ≤ A / N := div_nonneg hA hNr.le have hh := discrete_volterra_bound E (A / N) (C / N) hd N hE k hk apply hh.trans apply mul_le_mul_of_nonneg_left _ (div_nonneg hC hNr.le) calc (1 + A / N) ^ k ≤ (Real.exp (A / N)) ^ k := by apply pow_le_pow_left₀ (by positivity) simpa only [add_comm] using Real.add_one_le_exp (A / N) _ = Real.exp ((k : ℝ) * (A / N)) := (Real.exp_nat_mul _ _).symm _ ≤ Real.exp A := by apply Real.exp_le_exp.mpr have hkr : (k : ℝ) ≤ N := by exact_mod_cast hk calc (k : ℝ) * (A / N) ≤ (N : ℝ) * (A / N) := mul_le_mul_of_nonneg_right hkr hd _ = A := by field_simp
theorem integral_cell_error (f : ℝ → ℝ) {a b L : ℝ} (hab : a ≤ b) (hf : Continuous f) (hL : 0 ≤ L) (hLip : ∀ x ∈ Set.Icc a b, |f x - f a| ≤ L * (x - a)) : |(∫ x in a..b, f x) - (b - a) * f a| ≤ L * (b - a) ^ 2 := by have heq : (∫ x in a..b, f x) - (b - a) * f a = ∫ x in a..b, f x - f a := by rw [intervalIntegral.integral_sub (hf.intervalIntegrable _ _) (continuous_const.intervalIntegrable _ _)] simp only [intervalIntegral.integral_const, smul_eq_mul] rw [heq, ← Real.norm_eq_abs] have hb := intervalIntegral.norm_integral_le_of_norm_le_const (a := a) (b := b) (f := fun x => f x - f a) (C := L * (b - a)) (by intro x hx rw [Set.uIoc_of_le hab] at hx rw [Real.norm_eq_abs] exact (hLip x ⟨hx.1.le, hx.2⟩).trans (mul_le_mul_of_nonneg_left (sub_le_sub_right hx.2 a) hL)) rw [abs_of_nonneg (sub_nonneg.mpr hab)] at hb convert hb using 1 ring
theorem uniform_grid_quadrature (f : ℝ → ℝ) (hf : Continuous f) {L : ℝ} (hL : 0 ≤ L) (hLip : ∀ x ∈ Set.Icc (0 : ℝ) 1, ∀ y ∈ Set.Icc (0 : ℝ) 1, |f x - f y| ≤ L * |x - y|) (N k : ℕ) (hN : 0 < N) (hk : k ≤ N) : |(∫ x in (0 : ℝ)..((k : ℝ) / N), f x) - (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, f ((j : ℝ) / N)| ≤ L / N := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hsum : (∫ x in (0 : ℝ)..((k : ℝ) / N), f x) = ∑ j ∈ Finset.range k, ∫ x in ((j : ℝ) / N)..(((j + 1 : ℕ) : ℝ) / N), f x := by simpa only [Nat.cast_zero, zero_div] using (intervalIntegral.sum_integral_adjacent_intervals (a := fun j => (j : ℝ) / N) (n := k) (fun _ _ => hf.intervalIntegrable _ _)).symm rw [hsum, Finset.mul_sum, ← Finset.sum_sub_distrib] calc _ ≤ ∑ j ∈ Finset.range k, |(∫ x in ((j : ℝ) / N)..(((j + 1 : ℕ) : ℝ) / N), f x) - (1 / N) * f ((j : ℝ) / N)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _j ∈ Finset.range k, L * (1 / (N : ℝ)) ^ 2 := by apply Finset.sum_le_sum intro j hj have hjk : j < k := Finset.mem_range.mp hj have hjN : (j : ℝ) + 1 ≤ N := by exact_mod_cast (show j + 1 ≤ N by omega) have hja : (j : ℝ) / N ≤ ((j + 1 : ℕ) : ℝ) / N := by gcongr; exact_mod_cast (Nat.le_succ j) have hdif : (((j + 1 : ℕ) : ℝ) / N) - (j : ℝ) / N = 1 / (N : ℝ) := by push_cast; ring have he := integral_cell_error f hja hf hL (by intro x hx have ha0 : (0 : ℝ) ≤ (j : ℝ) / N := by positivity have hb1 : (((j + 1 : ℕ) : ℝ) / N) ≤ 1 := by rw [div_le_one hNr]; simpa using hjN have hh := hLip x ⟨ha0.trans hx.1, hx.2.trans hb1⟩ ((j : ℝ) / N) ⟨ha0, hja.trans hb1⟩ simpa only [abs_of_nonneg (sub_nonneg.mpr hx.1)] using hh) simpa only [hdif] using he _ ≤ L / N := by simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul] have hkr : (k : ℝ) ≤ N := by exact_mod_cast hk calc _ ≤ (N : ℝ) * (L * (1 / (N : ℝ)) ^ 2) := by gcongr _ = L / N := by field_simp
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304import Mathlibimport OAI.Combinatorics.TriangleRemoval.Queries.TreeBindimport OAI.Combinatorics.TriangleRemoval.Stability.GeometricVolterraIdentity
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen scoped BigOperators Topologyopen Filter
namespace SharpTerminalLeaveopen Filteropen scoped BigOperators Topology
section GridApproximationvariable {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] [DecidableEq τ]
theorem messageIntegral_time_lipschitz (H : τ → Finset ι) (e : ι) (T : τ) {s t : ℝ} (hs : s ∈ Set.Icc (0 : ℝ) 1) (ht : t ∈ Set.Icc (0 : ℝ) 1) : |messageIntegral H (cavityLimit H) e T t - messageIntegral H (cavityLimit H) e T s| ≤ |t - s| := by let f : ℝ → ℝ := fun x => ∏ a ∈ (H T).erase e, cavityLimit H a (some T) x have hc : Continuous f := continuous_message_integrand H _ (continuous_cavityLimit H) e T have hf : ∀ x, f x ∈ Set.Icc (0 : ℝ) 1 := by intro x exact ⟨Finset.prod_nonneg (fun a _ => (cavityLimit_mem_unit H a (some T) x).1), Finset.prod_le_one₀ (fun a _ => (cavityLimit_mem_unit H a (some T) x).1) (fun a _ => (cavityLimit_mem_unit H a (some T) x).2)⟩ simp only [messageIntegral, unitTime_of_mem hs, unitTime_of_mem ht] change |(∫ x in (0 : ℝ)..t, f x) - ∫ x in (0 : ℝ)..s, f x| ≤ _ rw [intervalIntegral.integral_interval_sub_left (hc.intervalIntegrable _ _) (hc.intervalIntegrable _ _), ← Real.norm_eq_abs] simpa only [one_mul] using (intervalIntegral.norm_integral_le_of_norm_le_const (a := s) (b := t) (C := (1 : ℝ)) (f := f) (fun x _ => by simpa only [Real.norm_eq_abs, abs_of_nonneg (hf x).1] using (hf x).2))
theorem cavityLimit_time_lipschitz (H : τ → Finset ι) (e : ι) (p : Option τ) {s t : ℝ} (hs : s ∈ Set.Icc (0 : ℝ) 1) (ht : t ∈ Set.Icc (0 : ℝ) 1) : |cavityLimit H e p t - cavityLimit H e p s| ≤ (Fintype.card τ : ℝ) * |t - s| := by rw [cavityLimit_product H e p t, cavityLimit_product H e p s] unfold cavityOperator have hm : ∀ T u, 1 - messageIntegral H (cavityLimit H) e T u ∈ Set.Icc (0 : ℝ) 1 := by intro T u have h := messageIntegral_mem_unit H _ (continuous_cavityLimit H) (cavityLimit_mem_unit H) e T u constructor <;> linarith [h.1, h.2] calc _ ≤ ∑ T ∈ messageCandidates H e p, |(1 - messageIntegral H (cavityLimit H) e T t) - (1 - messageIntegral H (cavityLimit H) e T s)| := abs_prod_sub_prod_le_sum _ _ _ (fun T _ => hm T t) (fun T _ => hm T s) _ ≤ ∑ _T ∈ messageCandidates H e p, |t - s| := by apply Finset.sum_le_sum intro T _ rw [sub_sub_sub_cancel_left, abs_sub_comm] exact messageIntegral_time_lipschitz H e T hs ht _ ≤ (Fintype.card τ : ℝ) * |t - s| := by simp only [Finset.sum_const, nsmul_eq_mul] gcongr exact_mod_cast Finset.card_le_univ (messageCandidates H e p)
theorem cavity_integrand_time_lipschitz (H : τ → Finset ι) (e : ι) (T : τ) {s t : ℝ} (hs : s ∈ Set.Icc (0 : ℝ) 1) (ht : t ∈ Set.Icc (0 : ℝ) 1) : |(∏ f ∈ (H T).erase e, cavityLimit H f (some T) t) - ∏ f ∈ (H T).erase e, cavityLimit H f (some T) s| ≤ ((Fintype.card ι : ℝ) * Fintype.card τ) * |t - s| := by calc _ ≤ ∑ f ∈ (H T).erase e, |cavityLimit H f (some T) t - cavityLimit H f (some T) s| := abs_prod_sub_prod_le_sum _ _ _ (fun f _ => cavityLimit_mem_unit H f (some T) t) (fun f _ => cavityLimit_mem_unit H f (some T) s) _ ≤ ∑ _f ∈ (H T).erase e, (Fintype.card τ : ℝ) * |t - s| := Finset.sum_le_sum (fun f _ => cavityLimit_time_lipschitz H f (some T) hs ht) _ ≤ ((Fintype.card ι : ℝ) * Fintype.card τ) * |t - s| := by simp only [Finset.sum_const, nsmul_eq_mul, mul_assoc] gcongr exact_mod_cast Finset.card_le_univ ((H T).erase e)
omit [Fintype ι] [Fintype τ] [DecidableEq ι] [DecidableEq τ] intheorem sum_fin_filter_lt_eq_range (N k : ℕ) (hk : k ≤ N) (f : ℕ → ℝ) : (∑ u ∈ Finset.univ.filter (fun u : Fin N => u.val < k), f u.val) = ∑ j ∈ Finset.range k, f j := by rw [Finset.sum_filter] calc _ = ∑ j ∈ Finset.range N, if j < k then f j else 0 := Fin.sum_univ_eq_sum_range (fun j => if j < k then f j else 0) N _ = ∑ j ∈ Finset.range k, if j < k then f j else 0 := by symm apply Finset.sum_subset (Finset.range_mono hk) intro j _ hj simp only [Finset.mem_range] at hj simp only [hj, ↓reduceIte] _ = _ := by apply Finset.sum_congr rfl intro j hj simp only [Finset.mem_range.mp hj, ↓reduceIte]
omit [Fintype ι] in
theorem gridMessage_exact_range (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) (hk : k ≤ N) (e : ι) (parent : Option τ) : gridMessage H N N k e parent = ∏ T ∈ messageCandidates H e parent, (1 - (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, ∏ f ∈ (H T).erase e, gridMessage H N N j f (some T)) := by rw [gridMessage_exact H N k hk] apply Finset.prod_congr rfl intro T _ congr 2 exact sum_fin_filter_lt_eq_range N k hk (fun j => ∏ f ∈ (H T).erase e, gridMessage H N N j f (some T))
omit [Fintype ι] [Fintype τ] [DecidableEq ι] [DecidableEq τ] intheorem uniform_subaverage_mem_unit (N k : ℕ) (hN : 0 < N) (hk : k ≤ N) (f : ℕ → ℝ) (hf : ∀ j < k, f j ∈ Set.Icc (0 : ℝ) 1) : 1 - (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, f j ∈ Set.Icc (0 : ℝ) 1 := by have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hs0 : 0 ≤ (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, f j := mul_nonneg (by positivity) (Finset.sum_nonneg (fun j hj => (hf j (Finset.mem_range.mp hj)).1)) have hs1 : (∑ j ∈ Finset.range k, f j) ≤ (N : ℝ) := by calc _ ≤ ∑ _j ∈ Finset.range k, (1 : ℝ) := Finset.sum_le_sum (fun j hj => (hf j (Finset.mem_range.mp hj)).2) _ = (k : ℝ) := by simp _ ≤ (N : ℝ) := by exact_mod_cast hk have hs2 : (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, f j ≤ 1 := by calc _ ≤ (1 / (N : ℝ)) * N := mul_le_mul_of_nonneg_left hs1 (by positivity) _ = 1 := by field_simp constructor <;> linarith
omit [Fintype ι] intheorem gridMessage_mem_unit (H : τ → Finset ι) (N : ℕ) [NeZero N] (d k : ℕ) (e : ι) (p : Option τ) : gridMessage H N d k e p ∈ Set.Icc (0 : ℝ) 1 := gridAnswerProbability_mem_unit H N d k {e} p
noncomputable def gridCavityError (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) : ℝ := ‖(fun ep : ι × Option τ => gridMessage H N N k ep.1 ep.2 - cavityLimit H ep.1 ep.2 ((k : ℝ) / N))‖
theorem gridCavityError_nonneg (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) : 0 ≤ gridCavityError H N k := norm_nonneg _
theorem gridCavityError_coord (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) (e : ι) (p : Option τ) : |gridMessage H N N k e p - cavityLimit H e p ((k : ℝ) / N)| ≤ gridCavityError H N k := by exact norm_le_pi_norm (fun ep : ι × Option τ => gridMessage H N N k ep.1 ep.2 - cavityLimit H ep.1 ep.2 ((k : ℝ) / N)) (e, p)
theorem grid_integrand_error (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) (e : ι) (T : τ) : |(∏ f ∈ (H T).erase e, gridMessage H N N k f (some T)) - ∏ f ∈ (H T).erase e, cavityLimit H f (some T) ((k : ℝ) / N)| ≤ (Fintype.card ι : ℝ) * gridCavityError H N k := by calc _ ≤ ∑ f ∈ (H T).erase e, |gridMessage H N N k f (some T) - cavityLimit H f (some T) ((k : ℝ) / N)| := abs_prod_sub_prod_le_sum _ _ _ (fun f _ => gridMessage_mem_unit H N N k f (some T)) (fun f _ => cavityLimit_mem_unit H f (some T) ((k : ℝ) / N)) _ ≤ ∑ _f ∈ (H T).erase e, gridCavityError H N k := Finset.sum_le_sum (fun f _ => gridCavityError_coord H N k f (some T)) _ ≤ (Fintype.card ι : ℝ) * gridCavityError H N k := by simp only [Finset.sum_const, nsmul_eq_mul] apply mul_le_mul_of_nonneg_right _ (gridCavityError_nonneg H N k) exact_mod_cast Finset.card_le_univ ((H T).erase e)
theorem grid_message_integral_error (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) (hk : k ≤ N) (e : ι) (T : τ) : |(1 / (N : ℝ)) * (∑ j ∈ Finset.range k, ∏ f ∈ (H T).erase e, gridMessage H N N j f (some T)) - messageIntegral H (cavityLimit H) e T ((k : ℝ) / N)| ≤ ((Fintype.card ι : ℝ) / N) * ∑ j ∈ Finset.range k, gridCavityError H N j + ((Fintype.card ι : ℝ) * Fintype.card τ) / N := by have hN : 0 < N := Nat.pos_of_ne_zero (NeZero.ne N) have hNr : (0 : ℝ) < N := by exact_mod_cast hN let f : ℝ → ℝ := fun s => ∏ a ∈ (H T).erase e, cavityLimit H a (some T) s have hc : Continuous f := continuous_message_integrand H _ (continuous_cavityLimit H) e T have hquad := uniform_grid_quadrature f hc (by positivity : 0 ≤ (Fintype.card ι : ℝ) * Fintype.card τ) (fun x hx y hy => cavity_integrand_time_lipschitz H e T hy hx) N k hN hk have htime : (k : ℝ) / N ∈ Set.Icc (0 : ℝ) 1 := ⟨by positivity, (div_le_one hNr).mpr (by exact_mod_cast hk)⟩ have hi : messageIntegral H (cavityLimit H) e T ((k : ℝ) / N) = ∫ s in (0 : ℝ)..((k : ℝ) / N), f s := by simp only [messageIntegral, unitTime_of_mem htime, f] rw [hi] calc _ ≤ |(1 / (N : ℝ)) * (∑ j ∈ Finset.range k, ∏ a ∈ (H T).erase e, gridMessage H N N j a (some T)) - (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, f ((j : ℝ) / N)| + |(1 / (N : ℝ)) * (∑ j ∈ Finset.range k, f ((j : ℝ) / N)) - ∫ s in (0 : ℝ)..((k : ℝ) / N), f s| := abs_sub_le _ _ _ _ ≤ ((Fintype.card ι : ℝ) / N) * ∑ j ∈ Finset.range k, gridCavityError H N j + ((Fintype.card ι : ℝ) * Fintype.card τ) / N := by apply add_le_add _ (by simpa only [abs_sub_comm] using hquad) rw [← mul_sub, abs_mul, abs_of_nonneg (by positivity : 0 ≤ 1 / (N : ℝ)), ← Finset.sum_sub_distrib] calc _ ≤ (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, |(∏ a ∈ (H T).erase e, gridMessage H N N j a (some T)) - f ((j : ℝ) / N)| := mul_le_mul_of_nonneg_left (Finset.abs_sum_le_sum_abs _ _) (by positivity) _ ≤ (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, (Fintype.card ι : ℝ) * gridCavityError H N j := by gcongr with j hj exact grid_integrand_error H N j e T _ = _ := by rw [← Finset.mul_sum]; ring
theorem gridCavityError_volterra (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) (hk : k ≤ N) : gridCavityError H N k ≤ ((Fintype.card τ : ℝ) ^ 2 * Fintype.card ι) / N + ((Fintype.card τ : ℝ) * Fintype.card ι / N) * ∑ j ∈ Finset.range k, gridCavityError H N j := by have hN : 0 < N := Nat.pos_of_ne_zero (NeZero.ne N) have hNr : (0 : ℝ) < N := by exact_mod_cast hN have hb : 0 ≤ ((Fintype.card ι : ℝ) / N) * ∑ j ∈ Finset.range k, gridCavityError H N j + ((Fintype.card ι : ℝ) * Fintype.card τ) / N := by have := Finset.sum_nonneg (s := Finset.range k) (fun j _ => gridCavityError_nonneg H N j) positivity unfold gridCavityError apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr intro ep rw [Real.norm_eq_abs, gridMessage_exact_range H N k hk, cavityLimit_product H ep.1 ep.2 ((k : ℝ) / N)] unfold cavityOperator let g : τ → ℝ := fun T => 1 - (1 / (N : ℝ)) * ∑ j ∈ Finset.range k, ∏ f ∈ (H T).erase ep.1, gridMessage H N N j f (some T) let q : τ → ℝ := fun T => 1 - messageIntegral H (cavityLimit H) ep.1 T ((k : ℝ) / N) have hg : ∀ T, g T ∈ Set.Icc (0 : ℝ) 1 := by intro T apply uniform_subaverage_mem_unit N k hN hk intro j _ exact ⟨Finset.prod_nonneg (fun f _ => (gridMessage_mem_unit H N N j f (some T)).1), Finset.prod_le_one₀ (fun f _ => (gridMessage_mem_unit H N N j f (some T)).1) (fun f _ => (gridMessage_mem_unit H N N j f (some T)).2)⟩ have hq : ∀ T, q T ∈ Set.Icc (0 : ℝ) 1 := by intro T have h := messageIntegral_mem_unit H _ (continuous_cavityLimit H) (cavityLimit_mem_unit H) ep.1 T ((k : ℝ) / N) change 1 - _ ∈ _ constructor <;> linarith [h.1, h.2] change |(∏ T ∈ messageCandidates H ep.1 ep.2, g T) - ∏ T ∈ messageCandidates H ep.1 ep.2, q T| ≤ _ calc _ ≤ ∑ T ∈ messageCandidates H ep.1 ep.2, |g T - q T| := abs_prod_sub_prod_le_sum _ _ _ (fun T _ => hg T) (fun T _ => hq T) _ ≤ ∑ _T ∈ messageCandidates H ep.1 ep.2, (((Fintype.card ι : ℝ) / N) * ∑ j ∈ Finset.range k, gridCavityError H N j + ((Fintype.card ι : ℝ) * Fintype.card τ) / N) := by apply Finset.sum_le_sum intro T _ dsimp only [g, q] rw [sub_sub_sub_cancel_left, abs_sub_comm] exact grid_message_integral_error H N k hk ep.1 T _ ≤ (Fintype.card τ : ℝ) * (((Fintype.card ι : ℝ) / N) * ∑ j ∈ Finset.range k, gridCavityError H N j + ((Fintype.card ι : ℝ) * Fintype.card τ) / N) := by simp only [Finset.sum_const, nsmul_eq_mul] apply mul_le_mul_of_nonneg_right _ hb exact_mod_cast Finset.card_le_univ (messageCandidates H ep.1 ep.2) _ = _ := by unfold gridCavityError; ring
theorem gridCavityError_bound (H : τ → Finset ι) (N : ℕ) [NeZero N] (k : ℕ) (hk : k ≤ N) : gridCavityError H N k ≤ (((Fintype.card τ : ℝ) ^ 2 * Fintype.card ι) / N) * Real.exp ((Fintype.card τ : ℝ) * Fintype.card ι) := by exact discrete_volterra_exp_bound (gridCavityError H N) ((Fintype.card τ : ℝ) * Fintype.card ι) ((Fintype.card τ : ℝ) ^ 2 * Fintype.card ι) (by positivity) (by positivity) N (Nat.pos_of_ne_zero (NeZero.ne N)) (gridCavityError_volterra H N) k hk
theorem gridMessage_tendsto_terminal (H : τ → Finset ι) (e : ι) (p : Option τ) : Tendsto (fun n : ℕ => gridMessage H (n + 1) (n + 1) (n + 1) e p) atTop (𝓝 (cavityLimit H e p 1)) := by have hden : Tendsto (fun n : ℕ => (1 : ℝ) / ((n + 1 : ℕ) : ℝ)) atTop (𝓝 0) := by simpa only [Nat.cast_add, Nat.cast_one] using (tendsto_one_div_add_atTop_nhds_zero_nat : Tendsto (fun n : ℕ => (1 : ℝ) / (n + 1)) atTop (𝓝 0)) let C : ℝ := ((Fintype.card τ : ℝ) ^ 2 * Fintype.card ι) * Real.exp ((Fintype.card τ : ℝ) * Fintype.card ι) have hbound : ∀ n : ℕ, ‖gridMessage H (n + 1) (n + 1) (n + 1) e p - cavityLimit H e p 1‖ ≤ C * (1 / ((n + 1 : ℕ) : ℝ)) := by intro n have hn : ((n + 1 : ℕ) : ℝ) ≠ 0 := by positivity have hx := (gridCavityError_coord H (n + 1) (n + 1) e p).trans (gridCavityError_bound H (n + 1) (n + 1) le_rfl) simpa only [div_self hn, Real.norm_eq_abs, C, div_eq_mul_inv, one_mul, mul_assoc, mul_comm, mul_left_comm] using hx apply tendsto_iff_norm_sub_tendsto_zero.mpr exact squeeze_zero (fun n => norm_nonneg _) hbound (by simpa using tendsto_const_nhds.mul hden)
end GridApproximationend SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import Mathlibimport OAI.Combinatorics.TriangleRemoval.Queries.CanonicalCollisionSingletonSumimport OAI.Combinatorics.TriangleRemoval.Stability.ActiveCavityFactorProductimport OAI.Combinatorics.TriangleRemoval.Stability.ContinuousCavityWeightClipimport OAI.Combinatorics.TriangleRemoval.Probability.PmfMeanLiminfTendsto
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
lemma grid_cavityWeight_lower {D : ℝ} (hD : 0 ≤ D) (N : ℕ) [NeZero N] : ∀ t ≤ N, 1 ≤ (1+2*D)*cavityWeight D ((t : ℝ)/N) := by intro t ht have hNr : (0 : ℝ) < N := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne N) have hmem : (t : ℝ)/N ∈ Set.Icc (0 : ℝ) 1 := ⟨by positivity,(div_le_one hNr).mpr (by exact_mod_cast ht)⟩ have hh := mul_le_mul_of_nonneg_left (cavityWeight_lower hD hmem) (show 0 ≤ 1+2*D by positivity) have heq : (1+2*D)*cavityWeight D 1 = 1 := by unfold cavityWeight rw [mul_one,mul_one_div_cancel (by positivity : 1+2*D ≠ 0)] rwa [heq] at hh
lemma grid_collision_majorant_tendsto (K : ℝ) {D : ℝ} (hD : 0 < D) : Tendsto (fun j : ℕ => (K*(1+2*D)^3/D^50)* Real.exp (45*D*prefixWeight (fun t => (2/((j+1 : ℕ) : ℝ))* cavityWeight D ((t : ℝ)/(j+1 : ℕ))) (j+1))) atTop (𝓝 (K*(1+2*D)^48/D^50)) := by have hh := (Real.continuous_exp.continuousAt.tendsto.comp ((grid_prefixWeight_tendsto hD).const_mul (45*D))).const_mul (K*(1+2*D)^3/D^50) have he : (K*(1+2*D)^3/D^50)*Real.exp (45*D*(2*witnessMu D)) = K*(1+2*D)^48/D^50 := by calc _ = K*((1+2*D)^3*Real.exp (45*D*(2*witnessMu D)))/D^50 := by ring _ = _ := by rw [collision_exponential_identity hD] rwa [he] at hh
theorem averaged_disjoint_collisionCost (c₀ C₀ : ℝ) (hc₀ : 0 < c₀) : ∀ᶠ n : ℕ in atTop, ∀ (G : Graph n), GoodPrefixGraph n c₀ C₀ G → ∀ hne : G.Nonempty, pmfMean (PMF.uniformOfFinset G hne) (fun e => pmfMean (PMF.uniformOfFinset G hne) (fun f => if Disjoint e f then collisionCost (triangleHypergraph G) {e,f} none else 0)) ≤ 65536*(1+2*prefixD n)^48/prefixD n^50 := by classical filter_upwards [averaged_disjoint_grid_collision c₀ C₀ hc₀, goodPrefix_full_grid_rows hc₀,goodPrefix_full_continuous_rows hc₀] with n hfinite hrows hn intro G hGood hne let D := prefixD n let P := PMF.uniformOfFinset G hne let PP := P.bind (fun e => P.map (Prod.mk e)) let f : (Finset (Fin n) × Finset (Fin n)) → ℕ → ℝ := fun ef j => if Disjoint ef.1 ef.2 then gridCollision (triangleHypergraph G) {ef.1,ef.2} none j else 0 let g : ℕ → ℝ := fun j => (65536*(1+2*D)^3/D^50)* Real.exp (45*D*prefixWeight (fun t => (2/((j+1 : ℕ) : ℝ))* cavityWeight D ((t : ℝ)/(j+1 : ℕ))) (j+1)) have hbound (ef : Finset (Fin n) × Finset (Fin n)) (j : ℕ) : 0 ≤ f ef j := by dsimp only [f] split_ifs <;> first | exact (gridCollision_mem_unit _ _ _ _).1 | rfl obtain ⟨N₀,hN₀⟩ := hrows C₀ G hGood have hupper : ∀ᶠ j : ℕ in atTop, pmfMean PP (fun ef => f ef j) ≤ g j := by filter_upwards [eventually_ge_atTop N₀] with j hj dsimp only [PP] rw [pmfMean_bind] simp_rw [pmfMean_map] have hh := hfinite G hGood hne (j+1) (fun t => cavityWeight D ((t : ℝ)/(j+1 : ℕ))) (fun t => (cavityWeight_pos hn.1.le (by positivity)).le) (hN₀ (j+1) (by omega)) (1+2*D) (by dsimp only [D]; linarith [hn.1]) (grid_cavityWeight_lower hn.1.le (j+1)) (j+1) (j+1) le_rfl le_rfl simpa only [gridCollision_eq_trace,P,f,g,D] using hh have hh := pmfMean_liminf_le_of_tendsto_upper PP f hbound g (grid_collision_majorant_tendsto 65536 hn.1) hupper dsimp only [PP] at hh rw [pmfMean_bind] at hh simp_rw [pmfMean_map] at hh have hf (e f' : Finset (Fin n)) : Filter.liminf (f (e,f')) atTop = if Disjoint e f' then collisionCost (triangleHypergraph G) {e,f'} none else 0 := by by_cases hd : Disjoint e f' · simp only [f,hd,ite_true,collisionCost] · simp only [f,hd,ite_false,Filter.liminf_const] simp_rw [hf] at hh exact hh
theorem averaged_singleton_collisionCost (c₀ C₀ : ℝ) (hc₀ : 0 < c₀) : ∀ᶠ n : ℕ in atTop, ∀ (G : Graph n), GoodPrefixGraph n c₀ C₀ G → ∀ hne : G.Nonempty, pmfMean (PMF.uniformOfFinset G hne) (fun e => collisionCost (triangleHypergraph G) {e} none) ≤ 8192*(1+2*prefixD n)^48/prefixD n^50 := by classical filter_upwards [averaged_singleton_grid_collision c₀ C₀ hc₀, goodPrefix_full_grid_rows hc₀,goodPrefix_full_continuous_rows hc₀] with n hfinite hrows hn intro G hGood hne let D := prefixD n let P := PMF.uniformOfFinset G hne let f : Finset (Fin n) → ℕ → ℝ := fun e j => gridCollision (triangleHypergraph G) {e} none j let g : ℕ → ℝ := fun j => (8192*(1+2*D)^3/D^50)* Real.exp (45*D*prefixWeight (fun t => (2/((j+1 : ℕ) : ℝ))* cavityWeight D ((t : ℝ)/(j+1 : ℕ))) (j+1)) have hbound (e : Finset (Fin n)) (j : ℕ) : 0 ≤ f e j := (gridCollision_mem_unit _ _ _ _).1 obtain ⟨N₀,hN₀⟩ := hrows C₀ G hGood have hupper : ∀ᶠ j : ℕ in atTop, pmfMean P (fun e => f e j) ≤ g j := by filter_upwards [eventually_ge_atTop N₀] with j hj have hh := hfinite G hGood hne (j+1) (fun t => cavityWeight D ((t : ℝ)/(j+1 : ℕ))) (fun t => (cavityWeight_pos hn.1.le (by positivity)).le) (hN₀ (j+1) (by omega)) (1+2*D) (by dsimp only [D]; linarith [hn.1]) (grid_cavityWeight_lower hn.1.le (j+1)) (j+1) (j+1) le_rfl le_rfl simpa only [gridCollision_eq_trace,P,f,g,D] using hh exact pmfMean_liminf_le_of_tendsto_upper P f hbound g (grid_collision_majorant_tendsto 8192 hn.1) hupper
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import Mathlib
namespace OAI
sectionnoncomputable sectionopen scoped BigOperators
namespace SharpTerminalLeave
theorem moving_perturbation_finite_expansion {X : Type*} [AddCommGroup X] [Module ℝ X] (V : Module.End ℝ X) (x y : X) (h : x = y + V x) (K : ℕ) : x = (∑ j ∈ Finset.range K, (V^j) y) + (V^K) x := by induction K with | zero => simp | succ K ih => rw [Finset.sum_range_succ, pow_succ] calc x = (∑ j ∈ Finset.range K, (V^j) y) + (V^K) x := ih _ = (∑ j ∈ Finset.range K, (V^j) y) + (V^K) (y + V x) := by rw [← h] _ = _ := by simp [Module.End.mul_apply, add_assoc]
lemma seminorm_end_pow_le {X : Type*} [AddCommGroup X] [Module ℝ X] (p : Seminorm ℝ X) (V : Module.End ℝ X) {A : ℝ} (hA : 0 ≤ A) (hV : ∀ x, p (V x) ≤ A * p x) (K : ℕ) (x : X) : p ((V^K) x) ≤ A^K * p x := by induction K with | zero => simp | succ K ih => rw [pow_succ',Module.End.mul_apply,pow_succ'] exact (hV _).trans (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left ih hA)
lemma seminorm_finset_sum_le {X I : Type*} [AddCommGroup X] [Module ℝ X] (p : Seminorm ℝ X) (s : Finset I) (f : I → X) : p (∑ i ∈ s, f i) ≤ ∑ i ∈ s, p (f i) := by classical induction s using Finset.induction_on with | empty => simp | @insert i s hi ih => simp only [Finset.sum_insert hi] exact (map_add_le_add p _ _).trans (add_le_add le_rfl ih)
theorem moving_perturbation_mixed_norm_bound {X : Type*} [AddCommGroup X] [Module ℝ X] (p q : Seminorm ℝ X) (V : Module.End ℝ X) (x y : X) {A B C : ℝ} (hA : 0 ≤ A) (hB : 0 ≤ B) (hVp : ∀ z, p (V z) ≤ A * p z) (hVq : ∀ z, q (V z) ≤ B * q z) (hpq : ∀ z, p z ≤ q z) (hqp : ∀ z, q z ≤ C * p z) (h : x = y + V x) (K : ℕ) : p x ≤ (∑ j ∈ Finset.range K, A^j) * p y + B^K * C * p x := by have he := moving_perturbation_finite_expansion V x y h K calc p x = p ((∑ j ∈ Finset.range K, (V^j) y) + (V^K) x) := congrArg p he _ ≤ p (∑ j ∈ Finset.range K, (V^j) y) + p ((V^K) x) := map_add_le_add p _ _ _ ≤ (∑ j ∈ Finset.range K, p ((V^j) y)) + q ((V^K) x) := add_le_add (seminorm_finset_sum_le p _ _) (hpq _) _ ≤ (∑ j ∈ Finset.range K, A^j * p y) + B^K * q x := add_le_add (Finset.sum_le_sum (fun j _ => seminorm_end_pow_le p V hA hVp j y)) (seminorm_end_pow_le q V hB hVq K x) _ ≤ (∑ j ∈ Finset.range K, A^j * p y) + B^K * (C * p x) := add_le_add le_rfl (mul_le_mul_of_nonneg_left (hqp x) (pow_nonneg hB K)) _ = _ := by rw [Finset.sum_mul]; ring
theorem moving_perturbation_mixed_norm_absorb {X : Type*} [AddCommGroup X] [Module ℝ X] (p q : Seminorm ℝ X) (V : Module.End ℝ X) (x y : X) {A B C : ℝ} (hA : 0 ≤ A) (hB : 0 ≤ B) (hVp : ∀ z, p (V z) ≤ A * p z) (hVq : ∀ z, q (V z) ≤ B * q z) (hpq : ∀ z, p z ≤ q z) (hqp : ∀ z, q z ≤ C * p z) (h : x = y + V x) (K : ℕ) (hK : B^K*C ≤ 1/2) : p x ≤ 2*(∑ j ∈ Finset.range K, A^j)*p y := by have hb := moving_perturbation_mixed_norm_bound p q V x y hA hB hVp hVq hpq hqp h K have hp : 0 ≤ p x := apply_nonneg p x have ht := mul_le_mul_of_nonneg_right hK hp nlinarith only [hb,ht]
theorem moving_perturbation_mixed_norm_absorb_modulo {X : Type*} [AddCommGroup X] [Module ℝ X] (p q : Seminorm ℝ X) (V : Module.End ℝ X) (x y : X) {A B C : ℝ} (hA : 0 ≤ A) (hB : 0 ≤ B) (hVp : ∀ z, p (V z) ≤ A * p z) (hVq : ∀ z, q (V z) ≤ B * q z) (hpq : ∀ z, p z ≤ q z) (hqp : ∀ z, q z ≤ C * p z) (h : p (x-y-V x) = 0) (K : ℕ) (hK : B^K*C ≤ 1/2) : p x ≤ 2*(∑ j ∈ Finset.range K, A^j)*p y := by let z := x-y-V x have he : x = (y+z)+V x := by dsimp only [z]; abel have hb := moving_perturbation_mixed_norm_absorb p q V x (y+z) hA hB hVp hVq hpq hqp he K hK have hy : p (y+z) ≤ p y := by have hh := map_add_le_add p y z change p z = 0 at h linarith only [hh,h] apply hb.trans exact mul_le_mul_of_nonneg_left hy (by positivity)
end SharpTerminalLeaveendend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171import Mathlibimport OAI.Combinatorics.TriangleRemoval.Stability.MovingPerturbationFiniteExpansionimport OAI.Combinatorics.TriangleRemoval.Asymptotics.ActiveL2Map
namespace OAI
sectionnoncomputable sectionopen scoped BigOperators
namespace SharpTerminalLeaveopen Classical
lemma moving_active_subset {E : Type*} (active : ℕ → Finset E) (T : ℕ) (hnest : ∀ k < T, active (k+1) ⊆ active k) {i j : ℕ} (hij : i ≤ j) (hj : j ≤ T) : active j ⊆ active i := by induction j, hij using Nat.le_induction with | base => exact Finset.Subset.refl _ | succ k hik ih => exact (hnest k (by omega)).trans (ih (by omega))
lemma activeLinf_mono {E : Type*} [Fintype E] {s t : Finset E} (h : s ⊆ t) (x : E → ℝ) : activeLinf s x ≤ activeLinf t x := activeLinf_bound s x (apply_nonneg _ _) (fun _ he => activeLinf_coordinate t x (h he))
noncomputable def movingResidualForcing {E : Type*} [Fintype E] (a : ℕ → ℝ) (R : ℕ → Module.End ℝ (E → ℝ)) : Module.End ℝ (ℕ → E → ℝ) where toFun x t := ∑ i ∈ Finset.range t, (-a i) • (R i (x i)) map_add' x y := by funext t simp only [Pi.add_apply,map_add,smul_add,Finset.sum_add_distrib] map_smul' c x := by funext t simp only [Pi.smul_apply,map_smul,smul_comm (-a _) c,Finset.smul_sum,RingHom.id_apply]
lemma movingResidualForcing_zero {E : Type*} [Fintype E] (a : ℕ → ℝ) (R : ℕ → Module.End ℝ (E → ℝ)) (x : ℕ → E → ℝ) : movingResidualForcing a R x 0 = 0 := by simp [movingResidualForcing]
lemma movingResidualForcing_succ {E : Type*} [Fintype E] (a : ℕ → ℝ) (R : ℕ → Module.End ℝ (E → ℝ)) (x : ℕ → E → ℝ) (t : ℕ) : movingResidualForcing a R x (t+1) = movingResidualForcing a R x t-a t • R t (x t) := by simp [movingResidualForcing,Finset.sum_range_succ,sub_eq_add_neg,add_comm]
lemma movingResidualForcing_bound {E : Type*} [Fintype E] (P : ℕ → Seminorm ℝ (E → ℝ)) (a : ℕ → ℝ) (R : ℕ → Module.End ℝ (E → ℝ)) (T : ℕ) (ha : ∀ i < T, 0 ≤ a i) (hmono : ∀ i j, i ≤ j → j ≤ T → ∀ x, P j x ≤ P i x) {B : ℝ} (hB : 0 ≤ B) (hR : ∀ i < T, ∀ x, P i (R i x) ≤ B*P i x) (x : ℕ → E → ℝ) : trajectorySeminorm P T (movingResidualForcing a R x) ≤ (∑ i ∈ Finset.range T, a i)*B*trajectorySeminorm P T x := by have hS : 0 ≤ ∑ i ∈ Finset.range T, a i := Finset.sum_nonneg (fun i hi => ha i (Finset.mem_range.mp hi)) have hx0 := apply_nonneg (trajectorySeminorm P T) x apply trajectorySeminorm_bound _ _ _ (by positivity) intro t ht change P t (∑ i ∈ Finset.range t, (-a i) • R i (x i)) ≤ _ calc _ ≤ ∑ i ∈ Finset.range t, P t ((-a i) • R i (x i)) := seminorm_finset_sum_le _ _ _ _ ≤ ∑ i ∈ Finset.range t, a i*(B*trajectorySeminorm P T x) := by apply Finset.sum_le_sum intro i hi have hit : i < t := Finset.mem_range.mp hi have hiT : i < T := by omega rw [map_smul_eq_mul,Real.norm_eq_abs,abs_neg,abs_of_nonneg (ha i hiT)] apply mul_le_mul_of_nonneg_left _ (ha i hiT) exact (hmono i t hit.le ht _).trans ((hR i hiT _).trans (mul_le_mul_of_nonneg_left (trajectorySeminorm_at P T x (by omega)) hB)) _ ≤ ∑ i ∈ Finset.range T, a i*(B*trajectorySeminorm P T x) := Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono ht) (fun i hi _ => mul_nonneg (ha i (Finset.mem_range.mp hi)) (mul_nonneg hB hx0)) _ = _ := by rw [← Finset.sum_mul]; ring
lemma movingStar_actual_response {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (active : ℕ → Finset E) (a : ℕ → ℝ) (R : ℕ → Module.End ℝ (E → ℝ)) (M x : ℕ → E → ℝ) (T : ℕ) (hnest : ∀ k < T, active (k+1) ⊆ active k) (hinit : ∀ e ∈ active 0, x 0 e = M 0 e) (hstep : ∀ k < T, ∀ e ∈ active (k+1), x (k+1) e = x k e - a k*(movingStarLift ends (movingStarMean ends (active k) (x k)) e+R k (x k) e) + (M (k+1) e-M k e)) : trajectorySeminorm (fun t => activeLinf (active t)) T (x-movingStarResponse ends active a M- movingStarResponse ends active a (movingResidualForcing a R x)) = 0 := by let F := M+movingResidualForcing a R x have hi : ∀ e ∈ active 0, x 0 e = F 0 e := by intro e he simp only [F,Pi.add_apply,movingResidualForcing_zero,Pi.zero_apply,add_zero] exact hinit e he have hs : ∀ k < T, ∀ e ∈ active (k+1), x (k+1) e = x k e - a k*movingStarLift ends (movingStarMean ends (active k) (x k)) e + (F (k+1) e-F k e) := by intro k hk e he rw [hstep k hk e he] simp only [F,Pi.add_apply,movingResidualForcing_succ,Pi.sub_apply,Pi.smul_apply,smul_eq_mul] ring apply le_antisymm _ (apply_nonneg _ _) apply trajectorySeminorm_bound _ _ _ le_rfl intro t ht apply activeLinf_bound _ _ le_rfl intro e he have h₁ := movingStar_trajectory_representation ends active a F x t (fun k hk => hnest k (by omega)) hi (fun k hk => hs k (by omega)) e he have h₂ := movingStar_trajectory_representation ends active a F (movingStarSolve ends active a F) t (fun k hk => hnest k (by omega)) (fun _ _ => rfl) (fun _ _ _ _ => rfl) e he have h_eq : x t e = movingStarResponse ends active a F t e := h₁.trans h₂.symm change |x t e-movingStarResponse ends active a M t e- movingStarResponse ends active a (movingResidualForcing a R x) t e| ≤ 0 have hadd := congrFun (congrFun (map_add (movingStarResponse ends active a) M (movingResidualForcing a R x)) t) e change movingStarResponse ends active a F t e = _ at hadd rw [h_eq,hadd] simp
theorem movingStar_mixed_stability {E V : Type*} [Fintype E] [Fintype V] (ends : E → Finset V) (hends : ∀ e, (ends e).card = 2) (active : ℕ → Finset E) (a : ℕ → ℝ) (R : ℕ → Module.End ℝ (E → ℝ)) (M x : ℕ → E → ℝ) (T K : ℕ) (hnest : ∀ k < T, active (k+1) ⊆ active k) (ha : ∀ k < T, 0 ≤ a k ∧ a k ≤ 1) (hinit : ∀ e ∈ active 0, x 0 e = M 0 e) (hstep : ∀ k < T, ∀ e ∈ active (k+1), x (k+1) e = x k e - a k*(movingStarLift ends (movingStarMean ends (active k) (x k)) e+R k (x k) e) + (M (k+1) e-M k e)) {B δ : ℝ} (hB : 0 ≤ B) (hδ : 0 ≤ δ) (hRinf : ∀ k < T, ∀ z, activeLinf (active k) (R k z) ≤ B*activeLinf (active k) z) (hR₂ : ∀ k < T, ∀ z, activeL2 (active k) (R k z) ≤ δ*activeL2 (active k) z) (hK : ((1+2*∑ k ∈ Finset.range T, a k)*(∑ k ∈ Finset.range T, a k)*δ)^K* (Fintype.card E : ℝ) ≤ 1/2) : trajectorySeminorm (fun t => activeLinf (active t)) T x ≤ 2*(∑ j ∈ Finset.range K, ((1+2*∑ k ∈ Finset.range T, a k)*(∑ k ∈ Finset.range T, a k)*B)^j)* (1+2*∑ k ∈ Finset.range T, a k)*trajectorySeminorm (fun t => activeLinf (active t)) T M := by let p := trajectorySeminorm (fun t => activeLinf (active t)) T let q := trajectorySeminorm (fun t => activeL2 (active t)) T let V₁ := (movingStarResponse ends active a).comp (movingResidualForcing a R) let S := ∑ k ∈ Finset.range T, a k let L := 1+2*S have hS : 0 ≤ S := Finset.sum_nonneg (fun k hk => (ha k (Finset.mem_range.mp hk)).1) have hL : 0 ≤ L := by dsimp [L]; positivity have hVp : ∀ z, p (V₁ z) ≤ L*S*B*p z := by intro z have hb := movingStarResponse_linf ends hends active a T hnest ha (movingResidualForcing a R z) have hf := movingResidualForcing_bound (fun t => activeLinf (active t)) a R T (fun k hk => (ha k hk).1) (fun i j hij hj z => activeLinf_mono (moving_active_subset active T hnest hij hj) z) hB hRinf z exact hb.trans (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hf hL) have hVq : ∀ z, q (V₁ z) ≤ L*S*δ*q z := by intro z have hb := movingStarResponse_l2 ends hends active a T hnest ha (movingResidualForcing a R z) have hf := movingResidualForcing_bound (fun t => activeL2 (active t)) a R T (fun k hk => (ha k hk).1) (fun i j hij hj z => activeL2_mono (moving_active_subset active T hnest hij hj) z) hδ hR₂ z exact hb.trans (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hf hL) have hb := moving_perturbation_mixed_norm_absorb_modulo p q V₁ x (movingStarResponse ends active a M) (by positivity : 0 ≤ L*S*B) (by positivity : 0 ≤ L*S*δ) hVp hVq (fun z => (trajectory_mixed_seminorms active T z).1) (fun z => (trajectory_mixed_seminorms active T z).2) (movingStar_actual_response ends active a R M x T hnest hinit hstep) K hK have hy := movingStarResponse_linf ends hends active a T hnest ha M apply hb.trans calc _ ≤ 2*(∑ j ∈ Finset.range K, (L*S*B)^j)*(L*p M) := mul_le_mul_of_nonneg_left hy (by positivity) _ = _ := by dsimp only [p,L,S]; ring
end SharpTerminalLeaveendend
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.RelativeScaleBudgetimport OAI.Combinatorics.TriangleRemoval.Process.TriangleLiftCount
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
noncomputable def relativeTemplateResidual {n : ℕ} {α : Type*} [Fintype α] (required : α → Graph n) (s : ℕ → ℝ) (T j : ℕ) (ω : History (Graph n) T) : ℝ := copyCount required (ω (historyIndex T j))/s j - copyCount required (ω (historyIndex T 0))/s 0 - historyNoise (fun _ => step) (fun k H => copyCount required H/s k) T j ω + historyCounter (fun k G => triangleLiftCount required G/ ((triangles G).card*s (k+1))) T j ω - ∑ k ∈ Finset.range j, copyCount required (ω (historyIndex T k))*(1/s (k+1)-1/s k)
lemma relativeTemplateResidual_eq {n : ℕ} {α : Type*} [Fintype α] (required : α → Graph n) (s : ℕ → ℝ) (T j : ℕ) (hj : j ≤ T) (ω : History (Graph n) T) : relativeTemplateResidual required s T j ω = historyCounter (fun k G => (pmfMean (step G) (copyCount required)-copyCount required G+ triangleLiftCount required G/(triangles G).card)/s (k+1)) T j ω := by have hid := history_relative_loss_counter (fun _ => step) (copyCount required) s T j hj ω have hsum : historyCounter (fun k G => (pmfMean (step G) (copyCount required)-copyCount required G+ triangleLiftCount required G/(triangles G).card)/s (k+1)) T j ω = historyCounter (fun k G => triangleLiftCount required G/ ((triangles G).card*s (k+1))) T j ω - historyCounter (fun k G => (copyCount required G- pmfMean (step G) (copyCount required))/s (k+1)) T j ω := by unfold historyCounter rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro k _ simp only [div_eq_mul_inv,mul_inv_rev] ring rw [hsum,hid] unfold relativeTemplateResidual ring
theorem history_relative_template_hierarchy {n : ℕ} {α : Type*} [Fintype α] (required : α → Graph n) (b : ℕ) (hsize : ∀ a, (required a).card ≤ b) (s : ℕ → ℝ) (T j : ℕ) (hj : j ≤ T) (hs : ∀ k < j, 0 < s (k+1)) (ω : History (Graph n) T) : 0 ≤ relativeTemplateResidual required s T j ω ∧ relativeTemplateResidual required s T j ω ≤ historyCounter (fun k G => ((b : ℝ)^2/(triangles G).card*copyCount required G)/s (k+1)) T j ω := by rw [relativeTemplateResidual_eq required s T j hj] constructor · apply Finset.sum_nonneg intro k hk have hkj : k < j := by simpa only [Nat.min_eq_left hj,Finset.mem_range] using hk exact div_nonneg (copyCount_triangleLift_drift_all required (ω (historyIndex T k)) b hsize).1 (hs k hkj).le · apply Finset.sum_le_sum intro k hk have hkj : k < j := by simpa only [Nat.min_eq_left hj,Finset.mem_range] using hk exact div_le_div_of_nonneg_right (copyCount_triangleLift_drift_all required (ω (historyIndex T k)) b hsize).2 (hs k hkj).le
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231import Mathlib
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheory
namespace SharpTerminalLeave
theorem exp_neg_smul_perturbation {A : Type*} [NormedRing A] [NormedAlgebra ℝ A] [CompleteSpace A] (P R : A) (s : ℝ) : NormedSpace.exp ((-s) • (P + R)) = NormedSpace.exp ((-s) • P) - ∫ t in (0 : ℝ)..s, NormedSpace.exp ((t - s) • P) * R * NormedSpace.exp ((-t) • (P + R)) := by let f : ℝ → A := fun t => NormedSpace.exp ((t - s) • P) * NormedSpace.exp ((-t) • (P + R)) let g : ℝ → A := fun t => NormedSpace.exp ((t - s) • P) * R * NormedSpace.exp ((-t) • (P + R)) have hd : ∀ t, HasDerivAt f (-g t) t := by intro t have h1 := (hasDerivAt_exp_smul_const (𝕂 := ℝ) P (t - s)).scomp t ((hasDerivAt_id t).sub_const s) have h2 := (hasDerivAt_exp_smul_const' (𝕂 := ℝ) (P + R) (-t)).scomp t ((hasDerivAt_id t).neg) have hh := h1.mul h2 simp only [Function.comp_apply, id_eq, one_smul, neg_one_smul] at hh convert hh using 1 · rfl · dsimp [g] noncomm_ring have hg : Continuous (fun t => -g t) := by have hP := (differentiable_exp_smul_const ℝ P).continuous have hA := (differentiable_exp_smul_const ℝ (P + R)).continuous exact (((hP.comp (continuous_id.sub continuous_const)).mul continuous_const).mul (hA.comp continuous_neg)).neg have hi := intervalIntegral.integral_eq_sub_of_hasDerivAt (a := 0) (b := s) (fun t _ => hd t) (hg.intervalIntegrable 0 s) simp only [f, sub_self, zero_smul, NormedSpace.exp_zero, one_mul, neg_zero, mul_one, zero_sub, intervalIntegral.integral_neg] at hi change _ = _ - ∫ t in (0 : ℝ)..s, g t rw [neg_eq_iff_eq_neg.mp hi] abel
section Volterravariable {A : Type*} [NormedRing A] [NormedAlgebra ℝ A] [CompleteSpace A]
noncomputable def volterra (P R : A) (f : ℝ → A) (s : ℝ) : A := ∫ t in (0 : ℝ)..s, NormedSpace.exp ((t - s) • P) * R * f t
noncomputable def volterraIter (P R : A) (f : ℝ → A) : ℕ → ℝ → A | 0 => f | k + 1 => volterra P R (volterraIter P R f k)
theorem continuous_volterra_integrand (P R : A) {f : ℝ → A} (hf : Continuous f) : Continuous (fun q : ℝ × ℝ => NormedSpace.exp ((q.2 - q.1) • P) * R * f q.2) := (((differentiable_exp_smul_const ℝ P).continuous.comp (continuous_snd.sub continuous_fst)).mul continuous_const).mul (hf.comp continuous_snd)
theorem continuous_volterra (P R : A) {f : ℝ → A} (hf : Continuous f) : Continuous (volterra P R f) := intervalIntegral.continuous_parametric_intervalIntegral_of_continuous (continuous_volterra_integrand P R hf) continuous_id
theorem continuous_volterraIter (P R : A) {f : ℝ → A} (hf : Continuous f) (k : ℕ) : Continuous (volterraIter P R f k) := by induction k with | zero => exact hf | succ k ih => exact continuous_volterra P R ih
theorem volterra_sub (P R : A) {f g : ℝ → A} (hf : Continuous f) (hg : Continuous g) : volterra P R (fun t => f t - g t) = fun s => volterra P R f s - volterra P R g s := by funext s simp only [volterra, mul_sub] apply intervalIntegral.integral_sub · exact ((continuous_volterra_integrand P R hf).comp (continuous_const.prodMk continuous_id)).intervalIntegrable 0 s · exact ((continuous_volterra_integrand P R hg).comp (continuous_const.prodMk continuous_id)).intervalIntegrable 0 s
theorem volterraIter_sub (P R : A) {f g : ℝ → A} (hf : Continuous f) (hg : Continuous g) (k : ℕ) : volterraIter P R (fun t => f t - g t) k = fun s => volterraIter P R f k s - volterraIter P R g k s := by induction k with | zero => rfl | succ k ih => simp only [volterraIter, ih] exact volterra_sub P R (continuous_volterraIter P R hf k) (continuous_volterraIter P R hg k)
omit [CompleteSpace A] intheorem volterraIter_shift (P R : A) (f : ℝ → A) (k : ℕ) : volterraIter P R (volterra P R f) k = volterraIter P R f (k + 1) := by induction k with | zero => rfl | succ k ih => simp only [volterraIter, ih]
theorem perturbation_iteration (P R : A) (k : ℕ) : volterraIter P R (fun t => NormedSpace.exp ((-t) • (P + R))) k = fun s => volterraIter P R (fun t => NormedSpace.exp ((-t) • P)) k s - volterraIter P R (fun t => NormedSpace.exp ((-t) • (P + R))) (k + 1) s := by have h0 : Continuous (fun t : ℝ => NormedSpace.exp ((-t) • P)) := (differentiable_exp_smul_const ℝ P).continuous.comp continuous_neg have h1 : Continuous (fun t : ℝ => NormedSpace.exp ((-t) • (P + R))) := (differentiable_exp_smul_const ℝ (P + R)).continuous.comp continuous_neg have heq : (fun t : ℝ => NormedSpace.exp ((-t) • (P + R))) = fun s => NormedSpace.exp ((-s) • P) - volterra P R (fun t => NormedSpace.exp ((-t) • (P + R))) s := by funext s exact exp_neg_smul_perturbation P R s conv_lhs => rw [heq] rw [volterraIter_sub P R h0 (continuous_volterra P R h1), volterraIter_shift]
theorem perturbation_finite_expansion (P R : A) (K : ℕ) (s : ℝ) : NormedSpace.exp ((-s) • (P + R)) = (∑ j ∈ Finset.range K, (-1 : ℝ) ^ j • volterraIter P R (fun t => NormedSpace.exp ((-t) • P)) j s) + (-1 : ℝ) ^ K • volterraIter P R (fun t => NormedSpace.exp ((-t) • (P + R))) K s := by induction K with | zero => simp [volterraIter] | succ K ih => rw [ih, Finset.sum_range_succ] have hi := congrFun (perturbation_iteration P R K) s rw [hi, smul_sub, pow_succ] simp only [mul_neg_one, neg_smul] abel
omit [CompleteSpace A] in
theorem volterraIter_norm_le (P R : A) (f : ℝ → A) (T a b : ℝ) (hT : 0 ≤ T) (ha : 0 ≤ a) (hb : 0 ≤ b) (hP : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖NormedSpace.exp ((-t) • P)‖ ≤ a) (hf : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖f t‖ ≤ b) (k : ℕ) (s : ℝ) (hs : s ∈ Set.Icc (0 : ℝ) T) : ‖volterraIter P R f k s‖ ≤ (a * ‖R‖ * T) ^ k * b := by induction k generalizing s with | zero => simpa [volterraIter] using hf s hs | succ k ih => have hn : 0 ≤ a * ‖R‖ * ((a * ‖R‖ * T) ^ k * b) := by positivity have hi : ‖volterraIter P R f (k + 1) s‖ ≤ (a * ‖R‖ * ((a * ‖R‖ * T) ^ k * b)) * |s - 0| := by apply intervalIntegral.norm_integral_le_of_norm_le_const intro t ht rw [Set.uIoc_of_le hs.1] at ht have hst : s - t ∈ Set.Icc (0 : ℝ) T := ⟨sub_nonneg.mpr ht.2, by linarith [ht.1, hs.2]⟩ have htt : t ∈ Set.Icc (0 : ℝ) T := ⟨ht.1.le, ht.2.trans hs.2⟩ have hPe : ‖NormedSpace.exp ((t - s) • P)‖ ≤ a := by simpa only [neg_sub] using hP (s - t) hst exact (norm_mul_le _ _).trans (mul_le_mul ((norm_mul_le _ _).trans (mul_le_mul_of_nonneg_right hPe (norm_nonneg R))) (ih t htt) (norm_nonneg _) (mul_nonneg ha (norm_nonneg R))) calc _ ≤ (a * ‖R‖ * ((a * ‖R‖ * T) ^ k * b)) * s := by simpa only [sub_zero, abs_of_nonneg hs.1] using hi _ ≤ (a * ‖R‖ * ((a * ‖R‖ * T) ^ k * b)) * T := mul_le_mul_of_nonneg_left hs.2 hn _ = (a * ‖R‖ * T) ^ (k + 1) * b := by rw [pow_succ]; ring
variable {B : Type*} [NormedRing B] [NormedAlgebra ℝ B] [CompleteSpace B]
omit [CompleteSpace B] intheorem continuous_algHom_map_exp (F : A →ₐ[ℝ] B) (hF : Continuous F) (x : A) : F (NormedSpace.exp x) = NormedSpace.exp (F x) := by apply NormedSpace.map_exp_of_mem_ball (𝕂 := ℝ) F hF rw [NormedSpace.expSeries_radius_eq_top] exact edist_lt_top _ _
theorem map_volterraIter (F : A →ₐ[ℝ] B) (hF : Continuous F) (P R : A) {f : ℝ → A} (hf : Continuous f) (k : ℕ) (s : ℝ) : F (volterraIter P R f k s) = volterraIter (F P) (F R) (fun t => F (f t)) k s := by let L : A →L[ℝ] B := ⟨F.toLinearMap, hF⟩ induction k generalizing s with | zero => rfl | succ k ih => change L (∫ t in (0 : ℝ)..s, NormedSpace.exp ((t - s) • P) * R * volterraIter P R f k t) = _ have hint : IntervalIntegrable (fun t => NormedSpace.exp ((t - s) • P) * R * volterraIter P R f k t) volume 0 s := ((continuous_volterra_integrand P R (continuous_volterraIter P R hf k)).comp (continuous_const.prodMk continuous_id)).intervalIntegrable 0 s rw [← L.intervalIntegral_comp_comm hint] change (∫ t in (0 : ℝ)..s, F (NormedSpace.exp ((t - s) • P) * R * volterraIter P R f k t)) = _ simp only [map_mul, continuous_algHom_map_exp F hF, map_smul, ih] rfl
theorem perturbation_mixed_norm_bound (F : A →ₐ[ℝ] B) (hF : Continuous F) (P R : A) (T a b N : ℝ) (hT : 0 ≤ T) (ha : 0 ≤ a) (hb : 0 ≤ b) (hN : 0 ≤ N) (hcompare : ∀ x : A, ‖x‖ ≤ N * ‖F x‖) (hbase : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖NormedSpace.exp ((-t) • P)‖ ≤ a) (hbase₂ : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖NormedSpace.exp ((-t) • F P)‖ ≤ 1) (hfull₂ : ∀ t ∈ Set.Icc (0 : ℝ) T, ‖NormedSpace.exp ((-t) • (F P + F R))‖ ≤ b) (K : ℕ) (s : ℝ) (hs : s ∈ Set.Icc (0 : ℝ) T) : ‖NormedSpace.exp ((-s) • (P + R))‖ ≤ (∑ j ∈ Finset.range K, (a * ‖R‖ * T) ^ j * a) + N * ((‖F R‖ * T) ^ K * b) := by have hc : Continuous (fun t : ℝ => NormedSpace.exp ((-t) • (P + R))) := (differentiable_exp_smul_const ℝ (P + R)).continuous.comp continuous_neg have hr : ‖volterraIter P R (fun t => NormedSpace.exp ((-t) • (P + R))) K s‖ ≤ N * ((‖F R‖ * T) ^ K * b) := by apply (hcompare _).trans apply mul_le_mul_of_nonneg_left _ hN rw [map_volterraIter F hF P R hc] simp_rw [continuous_algHom_map_exp F hF, map_smul, map_add] simpa only [one_mul] using volterraIter_norm_le (F P) (F R) (fun t => NormedSpace.exp ((-t) • (F P + F R))) T 1 b hT zero_le_one hb hbase₂ hfull₂ K s hs rw [perturbation_finite_expansion P R K s] calc _ ≤ (∑ j ∈ Finset.range K, ‖(-1 : ℝ) ^ j • volterraIter P R (fun t => NormedSpace.exp ((-t) • P)) j s‖) + ‖(-1 : ℝ) ^ K • volterraIter P R (fun t => NormedSpace.exp ((-t) • (P + R))) K s‖ := (norm_add_le _ _).trans (add_le_add (norm_sum_le _ _) (le_refl _)) _ = (∑ j ∈ Finset.range K, ‖volterraIter P R (fun t => NormedSpace.exp ((-t) • P)) j s‖) + ‖volterraIter P R (fun t => NormedSpace.exp ((-t) • (P + R))) K s‖ := by simp only [norm_smul, norm_pow, norm_neg, norm_one, one_pow, one_mul] _ ≤ _ := by apply add_le_add _ hr exact Finset.sum_le_sum fun j _ => volterraIter_norm_le P R _ T a a hT ha ha hbase hbase j s hs
end Volterraend SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205import Mathlibimport OAI.Combinatorics.TriangleRemoval.Tracking.RootedTemplateEdgesCardimport OAI.Combinatorics.TriangleRemoval.Process.RelativeNoiseExitimport OAI.Combinatorics.TriangleRemoval.Tracking.CodegreeVertexCountimport OAI.Combinatorics.TriangleRemoval.Tracking.CodegreeNoiseRadiusimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixEdgeRadius
namespace OAI
sectionnoncomputable sectionopen scoped BigOperatorsopen Filter Classical
namespace SharpTerminalLeave
lemma earlyTemplateScale_uniform_regular (H : ℕ) : ∀ᶠ n : ℕ in atTop, ∀ a ≤ H, ∀ b ≤ H^2, (∀ i ≤ prefixTime n, 0 < earlyTemplateScale a b n i) ∧ (∀ i < prefixTime n, earlyTemplateScale a b n (i+1) ≤ earlyTemplateScale a b n i) ∧ (∀ i < prefixTime n, earlyTemplateScale a b n i ≤ 2*earlyTemplateScale a b n (i+1)) ∧ relativeScaleBudget (earlyTemplateScale a b n) (prefixTime n) ≤ 2*(b : ℝ)*Real.log n := by have hh : ∀ z : Fin (H+1) × Fin (H^2+1), ∀ᶠ n : ℕ in atTop, (∀ i ≤ prefixTime n, 0 < earlyTemplateScale z.1.val z.2.val n i) ∧ (∀ i < prefixTime n, earlyTemplateScale z.1.val z.2.val n (i+1) ≤ earlyTemplateScale z.1.val z.2.val n i) ∧ (∀ i < prefixTime n, earlyTemplateScale z.1.val z.2.val n i ≤ 2*earlyTemplateScale z.1.val z.2.val n (i+1)) ∧ relativeScaleBudget (earlyTemplateScale z.1.val z.2.val n) (prefixTime n) ≤ 2*(z.2.val : ℝ)*Real.log n := by intro z filter_upwards [earlyTemplateScale_regular z.1.val z.2.val, earlyTemplateScale_log_budget z.1.val z.2.val] with n hr hb exact ⟨hr.1,hr.2.1,hr.2.2,hb⟩ filter_upwards [Filter.eventually_all.mpr hh] with n hn intro a ha b hb exact hn (⟨a,by omega⟩,⟨b,by omega⟩)
noncomputable def balancedJump (n : ℕ) : ℝ := (n : ℝ)^(-1/2000 : ℝ)noncomputable def balancedLoad (H : ℕ) {k : ℕ} (T : RootedTemplate k) (n i : ℕ) : ℝ := 4*(T.edges.card : ℝ)*(1+Real.log (n : ℝ))^(3*H+2)* rootedScaling T n (earlyDensity n i)/((n : ℝ)*earlyDensity n i^2)
lemma balanced_jump_budget (H : ℕ) : ∀ᶠ n : ℕ in atTop, 24*(H : ℝ)^2*(1+Real.log (n : ℝ))^(3*H+2)/prefixD n ≤ balancedJump n := by have hc : 0 < 1/(24*(H : ℝ)^2+1) := by positivity filter_upwards [prefixTemplateFactor_subpower ((3*H+2 : ℕ) : ℝ) (by norm_num : (0 : ℝ) < 1/2000) hc, prefixD_eventual_envelope,eventually_ge_atTop (1 : ℕ)] with n hb hd hn have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn have hln : 0 ≤ 1+Real.log (n : ℝ) := by have := Real.log_nonneg hn1; linarith have hb' : (1+Real.log (n : ℝ))^(3*H+2 : ℕ) ≤ 1/(24*(H : ℝ)^2+1)*(n : ℝ)^(1/2000 : ℝ) := by simpa only [prefixTemplateFactor,Real.rpow_natCast] using hb have hcoef : 24*(H : ℝ)^2/(24*(H : ℝ)^2+1) ≤ 1 := by apply (div_le_one (by positivity)).mpr; linarith have hnum : 24*(H : ℝ)^2*(1+Real.log (n : ℝ))^(3*H+2) ≤ (n : ℝ)^(1/2000 : ℝ) := by have hh := mul_le_mul_of_nonneg_left hb' (show 0 ≤ 24*(H : ℝ)^2 by positivity) have he := mul_le_mul_of_nonneg_right hcoef (Real.rpow_nonneg hn0.le (1/2000 : ℝ)) ring_nf at hh he ⊢ exact hh.trans he calc _ ≤ (n : ℝ)^(1/2000 : ℝ)/(n : ℝ)^(1/1000 : ℝ) := div_le_div₀ (by positivity) hnum (by positivity) hd.1 _ = _ := by unfold balancedJump; rw [← Real.rpow_sub hn0]; norm_num
lemma rooted_initial_ratio_le_two (H : ℕ) : ∀ᶠ n : ℕ in atTop, ∀ k ≤ H, ∀ T : RootedTemplate k, ∀ ψ : {v // v ∈ T.roots} ↪ Fin n, rootedCount T ψ (completeGraph n)/rootedScaling T n (earlyDensity n 0) ≤ 2 := by let C : ℝ := (2 : ℝ)^(H^2)*(2*(H : ℝ)^2) filter_upwards [tendsto_natCast_atTop_atTop.eventually_ge_atTop C, eventually_ge_atTop H,eventually_ge_atTop (2 : ℕ)] with n hC hn hn2 intro k hk T ψ have hh := rootedCount_initial_uniform_error H hk hn hn2 T ψ have hnR : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) have hdiv : C/(n : ℝ) ≤ 1 := (div_le_one hnR).mpr hC have he : earlyDensity n 0 = 1-1/(n : ℝ) := by simp [earlyDensity] rw [he] have hp := (abs_le.mp hh).2 change _ ≤ C/(n : ℝ) at hp linarith only [hp,hdiv]
lemma balanced_noise_exponent_budget (H : ℕ) : ∀ᶠ n : ℕ in atTop, (Real.log (n : ℝ))^2/4 ≤ codegreeNoiseRadius n^2/ (4*(balancedJump n*(2+4*(H : ℝ)^2*Real.log n+codegreeNoiseRadius n+balancedJump n)+ balancedJump n*codegreeNoiseRadius n)) := by let C : ℝ := 20+16*(H : ℝ)^2 have hC : 0 < C := by dsimp [C]; positivity filter_upwards [prefixTemplateFactor_subpower 1 (by norm_num : (0 : ℝ) < 1/10000) (one_div_pos.mpr hC), prefixTemplateFactor_subpower 2 (by norm_num : (0 : ℝ) < 1/5000) (by norm_num : (0 : ℝ) < 4), eventually_ge_atTop (1 : ℕ)] with n hp hl hn have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := lt_of_lt_of_le zero_lt_one hn1 have hlog : 0 ≤ Real.log (n : ℝ) := Real.log_nonneg hn1 have hr : 0 < codegreeNoiseRadius n := Real.rpow_pos_of_pos hn0 _ have hc : 0 < balancedJump n := Real.rpow_pos_of_pos hn0 _ have hr1 : codegreeNoiseRadius n ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos hn1 (by norm_num) have hc1 : balancedJump n ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos hn1 (by norm_num) let d := 4*(balancedJump n*(2+4*(H : ℝ)^2*Real.log n+codegreeNoiseRadius n+balancedJump n)+ balancedJump n*codegreeNoiseRadius n) have hdpos : 0 < d := by dsimp [d]; positivity have hd : d ≤ (n : ℝ)^(-1/2500 : ℝ) := by have hp' : 1+Real.log (n : ℝ) ≤ (1/C)*(n : ℝ)^(1/10000 : ℝ) := by simpa only [prefixTemplateFactor,Real.rpow_one] using hp have hh := mul_le_mul_of_nonneg_left hp' hC.le simp only [← mul_assoc,mul_one_div_cancel hC.ne',one_mul] at hh have hbracket : 4*(2+4*(H : ℝ)^2*Real.log n+codegreeNoiseRadius n+balancedJump n+codegreeNoiseRadius n) ≤ C*(1+Real.log (n : ℝ)) := by dsimp [C]; nlinarith only [hr1,hc1,hlog,sq_nonneg (H : ℝ)] have hm := mul_le_mul_of_nonneg_left (hbracket.trans hh) hc.le have he : balancedJump n*(n : ℝ)^(1/10000 : ℝ) = (n : ℝ)^(-1/2500 : ℝ) := by unfold balancedJump; rw [← Real.rpow_add hn0]; norm_num rw [he] at hm dsimp only [d] nlinarith only [hm] have hr2 : codegreeNoiseRadius n^2 = (n : ℝ)^(-1/5000 : ℝ) := by unfold codegreeNoiseRadius rw [← Real.rpow_mul_natCast hn0.le]; norm_num have hratio : (n : ℝ)^(1/5000 : ℝ) ≤ codegreeNoiseRadius n^2/d := by apply (le_div_iff₀ hdpos).mpr have hh := mul_le_mul_of_nonneg_left hd (Real.rpow_nonneg hn0.le (1/5000 : ℝ)) rw [← Real.rpow_add hn0] at hh rw [hr2] convert hh using 1 norm_num have hl' : (1+Real.log (n : ℝ))^2 ≤ 4*(n : ℝ)^(1/5000 : ℝ) := by simpa only [prefixTemplateFactor,Real.rpow_two] using hl exact (show (Real.log (n : ℝ))^2/4 ≤ (n : ℝ)^(1/5000 : ℝ) by nlinarith only [hl',hlog]).trans hratio
theorem prefix_balanced_noise_single (H : ℕ) : ∀ᶠ n : ℕ in atTop, ∀ k ≤ H, ∀ T : RootedTemplate k, ∀ ψ : {v // v ∈ T.roots} ↪ Fin n, pmfMean (historyLaw (PMF.pure (completeGraph n)) (fun _ => step) (prefixTime n) (prefixTime n)) (fun ω => if RelativeNoiseExit (fun φ : RootedInjection T ψ => imageEdges T φ.val) (balancedLoad H T n) (earlyTemplateScale (k-T.roots.card) T.edges.card n) 2 (codegreeNoiseRadius n) (prefixTime n) ω then 1 else 0) ≤ 2*(prefixTime n+1 : ℝ)*Real.exp (-(Real.log (n : ℝ))^2/4) := by filter_upwards [earlyTemplateScale_uniform_regular H,balanced_jump_budget H, rooted_initial_ratio_le_two H,balanced_noise_exponent_budget H, prefixDensity_eventually_inverse_lower,eventually_ge_atTop (1 : ℕ)] with n hreg hjump hinit hexp hp hn intro k hk T ψ have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := lt_of_lt_of_le zero_lt_one hn1 have hln : 0 ≤ 1+Real.log (n : ℝ) := by have := Real.log_nonneg hn1; linarith have hb : T.edges.card ≤ H^2 := (rootedTemplate_edges_card_le_sq T).trans (Nat.pow_le_pow_left hk 2) have hbR : (T.edges.card : ℝ) ≤ (H : ℝ)^2 := by exact_mod_cast hb have hr := hreg (k-T.roots.card) ((Nat.sub_le _ _).trans hk) T.edges.card hb let s := earlyTemplateScale (k-T.roots.card) T.edges.card n have hD : 0 < prefixD n := by unfold prefixD; have hh : 0 < prefixDensity n := lt_of_lt_of_le (by positivity) hp; positivity have hc : 0 < balancedJump n := Real.rpow_pos_of_pos hn0 _ have hnoise : 0 < codegreeNoiseRadius n := Real.rpow_pos_of_pos hn0 _ have hL : ∀ i < prefixTime n, 0 ≤ balancedLoad H T n i := by intro i hi have hpi := early_density_positive (by omega) hp hi.le unfold balancedLoad rootedScaling positivity have hJ : ∀ i < prefixTime n, 3*balancedLoad H T n i/s (i+1) ≤ balancedJump n := by intro i hi have hsi := hr.1 (i+1) (by omega) have hpi := early_density_positive (by omega) hp hi.le have hDi : prefixD n ≤ (n : ℝ)*earlyDensity n i^2 := by simpa only [earlyTemplateScale,pow_one] using earlyCodegreeScale_ge_prefixD n i hi.le (le_trans (by positivity) hp) have hratio := hr.2.2.1 i hi have hcoeff : 0 ≤ 12*(T.edges.card : ℝ)*(1+Real.log (n : ℝ))^(3*H+2)/((n : ℝ)*earlyDensity n i^2) := by positivity have hm := mul_le_mul_of_nonneg_left hratio hcoeff have hstep : 3*balancedLoad H T n i/s (i+1) ≤ 24*(T.edges.card : ℝ)*(1+Real.log (n : ℝ))^(3*H+2)/((n : ℝ)*earlyDensity n i^2) := by apply (div_le_iff₀ hsi).mpr dsimp only [balancedLoad,rootedScaling,s,earlyTemplateScale] at hm ⊢ convert hm using 1 <;> ring apply hstep.trans (_root_.le_trans _ hjump) apply div_le_div₀ (by positivity) _ hD hDi exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hbR (by norm_num)) (by positivity) have ht := triangle_relative_template_self_bounded_tail (fun φ : RootedInjection T ψ => imageEdges T φ.val) (completeGraph n) (prefixTime n) (balancedLoad H T n) s (balancedJump n) 2 hc (by norm_num) hr.1 hr.2.1 hL hJ (codegreeNoiseRadius n) hnoise refine (show _ ≤ 2*(prefixTime n+1 : ℝ)*Real.exp (-codegreeNoiseRadius n^2/(4*(balancedJump n*(copyCount (fun φ : RootedInjection T ψ => imageEdges T φ.val) (completeGraph n)/s 0+2*relativeScaleBudget s (prefixTime n)+codegreeNoiseRadius n+balancedJump n)+ balancedJump n*codegreeNoiseRadius n))) from ?_).trans ?_ · convert ht using 1 apply congrArg (pmfMean _) funext ω unfold RelativeNoiseExit split_ifs <;> rfl apply mul_le_mul_of_nonneg_left _ (by positivity) apply Real.exp_le_exp.mpr rw [neg_div,neg_div] apply neg_le_neg apply hexp.trans apply div_le_div_of_nonneg_left (sq_nonneg _) · have hscale : 0 ≤ copyCount (fun φ : RootedInjection T ψ => imageEdges T φ.val) (completeGraph n)/s 0 := div_nonneg (copyCount_nonneg _ _) (hr.1 0 (Nat.zero_le _)).le have hbudget := relativeScaleBudget_nonneg s (prefixTime n) hr.1 hr.2.1 positivity · have hi := hinit k hk T ψ change copyCount _ (completeGraph n)/s 0 ≤ 2 at hi have hbgt : relativeScaleBudget s (prefixTime n) ≤ 2*(H : ℝ)^2*Real.log n := hr.2.2.2.trans (by nlinarith only [mul_le_mul_of_nonneg_right hbR (Real.log_nonneg hn1)]) have hh := mul_le_mul_of_nonneg_left (show copyCount (fun φ : RootedInjection T ψ => imageEdges T φ.val) (completeGraph n)/s 0+ 2*relativeScaleBudget s (prefixTime n)+codegreeNoiseRadius n+balancedJump n ≤ 2+4*(H : ℝ)^2*Real.log n+codegreeNoiseRadius n+balancedJump n by linarith only [hi,hbgt]) hc.le linarith only [hh]
end SharpTerminalLeaveendend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.HistoryCompensator
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
noncomputable def centeredCodegreeNeighborSum {n : ℕ} (G : Graph n) (u v : Fin n) (s : ℝ) : ℝ := ∑ w ∈ commonNeighbors G u v, ((currentCodegree G u w : ℝ)+currentCodegree G v w-2*s)
lemma codegree_hazard_centering {n : ℕ} (G : Graph n) (u v : Fin n) (s : ℝ) : (∑ w ∈ commonNeighbors G u v, ((currentCodegree G u w : ℝ)+currentCodegree G v w-if {u,v} ∈ G then 1 else 0)) = (2*s-if {u,v} ∈ G then 1 else 0)*(currentCodegree G u v : ℝ)+ centeredCodegreeNeighborSum G u v s := by classical have he : (∑ w ∈ commonNeighbors G u v, ((currentCodegree G u w : ℝ)+currentCodegree G v w-if {u,v} ∈ G then 1 else 0)) = (∑ _w ∈ commonNeighbors G u v, (2*s-if {u,v} ∈ G then 1 else 0))+ centeredCodegreeNeighborSum G u v s := by rw [centeredCodegreeNeighborSum,← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro w _ ring rw [he] simp only [Finset.sum_const,nsmul_eq_mul,currentCodegree] ring
theorem normalized_codegree_centered_drift {n : ℕ} {G : Graph n} (hG : G ⊆ completeGraph n) (u v : Fin n) (huv : u ≠ v) (s t : ℝ) : pmfMean (step G) (fun H => (currentCodegree H u v : ℝ)/t)- (currentCodegree G u v : ℝ)/s = (currentCodegree G u v : ℝ)*(1/t-1/s)- ((2*s-if {u,v} ∈ G then 1 else 0)*(currentCodegree G u v : ℝ)+ centeredCodegreeNeighborSum G u v s)/((triangles G).card*t) := by by_cases hQ : (triangles G).Nonempty · have hd := step_mean_codegree hG hQ u v huv rw [codegree_hazard_centering G u v s] at hd simp only [div_eq_mul_inv,pmfMean_mul_const] at hd ⊢ rw [hd,mul_inv_rev] ring · have hzero : triangles G = ∅ := Finset.not_nonempty_iff_eq_empty.mp hQ rw [step,dite_eq_right hQ,pmfMean_pure,hzero,Finset.card_empty,Nat.cast_zero,zero_mul,div_zero] ring
theorem prefix_codegree_centered_drift {n : ℕ} {G : Graph n} (hG : G ⊆ completeGraph n) (u v : Fin n) (huv : u ≠ v) (k : ℕ) : pmfMean (step G) (prefixNormalizedCodegree u v (k+1))- prefixNormalizedCodegree u v k G = (currentCodegree G u v : ℝ)*(1/earlyTemplateScale 1 2 n (k+1)-1/earlyTemplateScale 1 2 n k)- ((2*earlyTemplateScale 1 2 n k-if {u,v} ∈ G then 1 else 0)* (currentCodegree G u v : ℝ)+ centeredCodegreeNeighborSum G u v (earlyTemplateScale 1 2 n k))/ ((triangles G).card*earlyTemplateScale 1 2 n (k+1)) := normalized_codegree_centered_drift hG u v huv _ _
end SharpTerminalLeave
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import Mathlibimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixDTendstoTop
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
noncomputable def codegreeNoiseRadius (n : ℕ) : ℝ := (n : ℝ)^(-1/10000 : ℝ)noncomputable def codegreeNoiseDenominator (n : ℕ) : ℝ := 4*((6/prefixD n)*(4+8*Real.log n+codegreeNoiseRadius n+6/prefixD n)+ (6/prefixD n)*codegreeNoiseRadius n)
theorem codegree_noise_exponent_lower : ∀ᶠ n : ℕ in atTop, (n : ℝ)^(1/2500 : ℝ) ≤ codegreeNoiseRadius n^2/codegreeNoiseDenominator n := by have hlog := ((isLittleO_log_rpow_atTop (by norm_num : (0 : ℝ) < 1/2500)).comp_tendsto tendsto_natCast_atTop_atTop).bound (by norm_num : (0 : ℝ) < 1/384) have hpow : Tendsto (fun n : ℕ => (n : ℝ)^(1/2500 : ℝ)) atTop atTop := (tendsto_rpow_atTop (by norm_num : (0 : ℝ) < 1/2500)).comp tendsto_natCast_atTop_atTop filter_upwards [prefixD_eventual_envelope,prefixD_tendsto_atTop.eventually_ge_atTop 6, hlog,hpow.eventually_ge_atTop 336,eventually_ge_atTop (1 : ℕ)] with n hD hD6 hl hn336 hn have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := lt_of_lt_of_le zero_lt_one hn1 have hD0 : 0 < prefixD n := by linarith have hln : 0 ≤ Real.log (n : ℝ) := Real.log_nonneg hn1 have hc0 : 0 < 6/prefixD n := by positivity have hc1 : 6/prefixD n ≤ 1 := (div_le_one hD0).mpr hD6 have hr0 : 0 < codegreeNoiseRadius n := Real.rpow_pos_of_pos hn0 _ have hr1 : codegreeNoiseRadius n ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos hn1 (by norm_num) have hc : 6/prefixD n ≤ 6*(n : ℝ)^(-1/1000 : ℝ) := by have hh := div_le_div_of_nonneg_left (by norm_num : (0 : ℝ) ≤ 6) (Real.rpow_pos_of_pos hn0 (1/1000 : ℝ)) hD.1 calc _ ≤ 6/(n : ℝ)^(1/1000 : ℝ) := hh _ = _ := by rw [show (-1/1000 : ℝ) = -(1/1000 : ℝ) by norm_num,Real.rpow_neg hn0.le] rfl have hr2 : codegreeNoiseRadius n^2 = (n : ℝ)^(-1/5000 : ℝ) := by unfold codegreeNoiseRadius rw [← Real.rpow_natCast,← Real.rpow_mul hn0.le] norm_num have hd0 : 0 < codegreeNoiseDenominator n := by unfold codegreeNoiseDenominator; positivity have hd : codegreeNoiseDenominator n ≤ (n : ℝ)^(-1/1000 : ℝ)*(24*(7+8*Real.log n)) := by unfold codegreeNoiseDenominator calc _ = 4*(6/prefixD n)*(4+8*Real.log n+codegreeNoiseRadius n+6/prefixD n+codegreeNoiseRadius n) := by ring _ ≤ 4*(6/prefixD n)*(7+8*Real.log n) := by apply mul_le_mul_of_nonneg_left _ (by positivity) linarith only [hr1,hc1] _ ≤ 4*(6*(n : ℝ)^(-1/1000 : ℝ))*(7+8*Real.log n) := by exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hc (by norm_num)) (by positivity) _ = _ := by ring have hsmall : 24*(7+8*Real.log (n : ℝ)) ≤ (n : ℝ)^(1/2500 : ℝ) := by dsimp at hl rw [abs_of_nonneg hln,abs_of_nonneg (Real.rpow_nonneg hn0.le (1/2500 : ℝ))] at hl linarith only [hl,hn336] have hd' := hd.trans (mul_le_mul_of_nonneg_left hsmall (Real.rpow_nonneg hn0.le (-1/1000 : ℝ))) apply (le_div_iff₀ hd0).mpr have hh := mul_le_mul_of_nonneg_left hd' (Real.rpow_nonneg hn0.le (1/2500 : ℝ)) rw [← Real.rpow_add hn0,← Real.rpow_add hn0] at hh rw [hr2] convert hh using 1; norm_num
end SharpTerminalLeave
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.RelativeCopyNoiseFirstimport OAI.Combinatorics.TriangleRemoval.Embeddings.FixedEndpointPairInjective
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
open Classical in
theorem codegree_relative_noise_tail {n : ℕ} (u v : Fin n) (G : Graph n) (T : ℕ) (s : ℕ → ℝ) (c B : ℝ) (hc : 0 < c) (hB : 0 ≤ B) (hs : ∀ k ≤ T, 0 < s k) (hdec : ∀ k < T, s (k+1) ≤ s k) (hjump : ∀ k < T, 6/s (k+1) ≤ c) (r : ℝ) (hr : 0 < r) : pmfMean (historyLaw (PMF.pure G) (fun _ => step) T T) (fun ω => if ∃ j ≤ T, (∀ k < j, (currentCodegree (ω (historyIndex T k)) u v : ℝ) ≤ B*s k) ∧ r ≤ |historyNoise (fun _ => step) (fun k H => (currentCodegree H u v : ℝ)/s k) T j ω| then 1 else 0) ≤ 2*(T+1 : ℝ)*Real.exp (-r^2/(4*(c*((currentCodegree G u v : ℝ)/s 0+B*relativeScaleBudget s T+r+c)+c*r))) := by have ht := triangle_relative_template_self_bounded_tail (wedgeEdges u v) G T (fun _ => 2) s c B hc hB hs hdec (fun _ _ => by norm_num) (fun k hk => by simpa only [show (3 : ℝ)*2 = 6 by norm_num] using hjump k hk) r hr simp_rw [← currentCodegree_copyCount] at ht apply le_trans _ ht apply pmfMean_mono intro ω _ by_cases hex : ∃ j ≤ T, (∀ k < j, (currentCodegree (ω (historyIndex T k)) u v : ℝ) ≤ B*s k) ∧ r ≤ |historyNoise (fun _ => step) (fun k H => (currentCodegree H u v : ℝ)/s k) T j ω| · obtain ⟨j,hj,hcounts,hcross⟩ := hex rw [ite_eq_left ⟨j,hj,hcounts,hcross⟩, ite_eq_left ⟨j,hj,wedge_pastRelativeCopyLoadsSafe u v T j ω,hcounts,hcross⟩] · rw [ite_eq_right hex] split <;> norm_num
end SharpTerminalLeave
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.PowersetCardTripleimport OAI.Combinatorics.TriangleRemoval.Process.History
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen Filter MeasureTheoryopen scoped BigOperators ENNReal Classicalopen scoped BigOperatorsopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
theorem pmfMean_centered_sq_le {α : Type*} [Fintype α] (p : PMF α) (f : α → ℝ) (a : ℝ) : pmfMean p (fun b => (f b - pmfMean p f)^2) ≤ pmfMean p (fun b => (f b - a)^2) := by rw [pmfMean_sq_sub,pmfMean_sq_sub] nlinarith [sq_nonneg (pmfMean p f - a)]
theorem codegree_centered_range {n : ℕ} {G H : Graph n} (hG : G ⊆ completeGraph n) (u v : Fin n) (hH : H ∈ (step G).support) : |(currentCodegree H u v : ℝ) - pmfMean (step G) (fun J => (currentCodegree J u v : ℝ))| ≤ 2 := by have hmlo : (currentCodegree G u v : ℝ) - 2 ≤ pmfMean (step G) (fun J => (currentCodegree J u v : ℝ)) := by rw [← pmfMean_const (step G) ((currentCodegree G u v : ℝ) - 2)] apply pmfMean_mono intro J hJ have hJ' := (codegree_step_range hG u v hJ).2 linarith have hmhi : pmfMean (step G) (fun J => (currentCodegree J u v : ℝ)) ≤ (currentCodegree G u v : ℝ) := by rw [← pmfMean_const (step G) (currentCodegree G u v : ℝ)] apply pmfMean_mono intro J hJ have hJ' := (codegree_step_range hG u v hJ).1 linarith obtain ⟨hlo,hhi⟩ := codegree_step_range hG u v hH exact abs_le.mpr ⟨by linarith,by linarith⟩
theorem codegree_centered_variance {n : ℕ} {G : Graph n} (hG : G ⊆ completeGraph n) (u v : Fin n) : pmfMean (step G) (fun H => ((currentCodegree H u v : ℝ) - pmfMean (step G) (fun J => (currentCodegree J u v : ℝ)))^2) ≤ 2 * ((currentCodegree G u v : ℝ) - pmfMean (step G) (fun H => (currentCodegree H u v : ℝ))) := by exact (pmfMean_centered_sq_le _ _ (currentCodegree G u v : ℝ)).trans (codegree_step_second_moment hG u v)
@[simp] theorem markovLaw_triangle_step {n : ℕ} (G : Graph n) (k : ℕ) : markovLaw (PMF.pure G) (fun _ => step) k = evolve G k := by induction k with | zero => rfl | succ k ih => rw [markovLaw,evolve,ih]
noncomputable def codegreeVarianceRate {n : ℕ} (u v : Fin n) (_k : ℕ) (G : Graph n) : ℝ := 2 * ((currentCodegree G u v : ℝ) - pmfMean (step G) (fun H => (currentCodegree H u v : ℝ)))
theorem triangle_codegree_noise_freedman {n : ℕ} (G : Graph n) (hG : G ⊆ completeGraph n) (u v : Fin n) (T k : ℕ) (r V : ℝ) (hr : 0 < r) (hV : 0 ≤ V) : pmfMean (historyLaw (PMF.pure G) (fun _ => step) T k) (fun ω => if r ≤ historyNoise (fun _ => step) (fun _ H => (currentCodegree H u v : ℝ)) T k ω ∧ historyCounter (codegreeVarianceRate u v) T k ω ≤ V then 1 else 0) ≤ Real.exp (-r ^ 2 / (4 * (V + 2 * r))) := by apply history_noise_freedman (PMF.pure G) (fun _ => step) (fun _ H => (currentCodegree H u v : ℝ)) (codegreeVarianceRate u v) T 2 (by norm_num) · intro j _ H hH J hJ rw [markovLaw_triangle_step] at hH exact codegree_centered_range ((evolve_support_subset G j hH).trans hG) u v hJ · intro j _ H hH rw [markovLaw_triangle_step] at hH exact codegree_centered_variance ((evolve_support_subset G j hH).trans hG) u v · exact hr · exact hV
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103import Mathlibimport OAI.Combinatorics.TriangleRemoval.Asymptotics.EarlyDensityimport OAI.Combinatorics.TriangleRemoval.Tracking.CodegreeRelativeNoiseTail
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
lemma codegree_le_vertex_count {n : ℕ} (G : Graph n) (u v : Fin n) : currentCodegree G u v ≤ n := by unfold currentCodegree exact (Finset.card_le_univ _).trans (by simp)
lemma earlyCodegreeScale_ge_prefixD (n i : ℕ) (hi : i ≤ prefixTime n) (hp : 0 ≤ prefixDensity n) : prefixD n ≤ earlyTemplateScale 1 2 n i := by unfold earlyTemplateScale prefixD rw [pow_one] exact mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hp (earlyDensity_antitone n hi) 2) (Nat.cast_nonneg n)
lemma initial_codegree_relative_le_four {n : ℕ} (hn : 2 ≤ n) (u v : Fin n) : (currentCodegree (completeGraph n) u v : ℝ)/earlyTemplateScale 1 2 n 0 ≤ 4 := by have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) have hn2 : (2 : ℝ) ≤ n := by exact_mod_cast hn have hp : (1/2 : ℝ) ≤ earlyDensity n 0 := by have hh : 1/(n : ℝ) ≤ 1/2 := (div_le_iff₀ hn0).mpr (by linarith) simp only [earlyDensity,Nat.cast_zero,mul_zero,zero_div,sub_zero] linarith have hs : (n : ℝ)/4 ≤ earlyTemplateScale 1 2 n 0 := by have hh := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 1/2) hp 2) hn0.le unfold earlyTemplateScale norm_num only [pow_one,div_pow,one_pow] at hh ⊢ nlinarith only [hh] apply (div_le_iff₀ (lt_of_lt_of_le (by positivity) hs)).mpr have hh : (currentCodegree (completeGraph n) u v : ℝ) ≤ n := by exact_mod_cast codegree_le_vertex_count (completeGraph n) u v linarith
open Classical in
theorem prefix_codegree_relative_noise_bound : ∀ᶠ n : ℕ in atTop, ∀ u v : Fin n, ∀ r : ℝ, 0 < r → pmfMean (historyLaw (PMF.pure (completeGraph n)) (fun _ => step) (prefixTime n) (prefixTime n)) (fun ω => if ∃ j ≤ prefixTime n, (∀ k < j, (currentCodegree (ω (historyIndex (prefixTime n) k)) u v : ℝ) ≤ 2*earlyTemplateScale 1 2 n k) ∧ r ≤ |historyNoise (fun _ => step) (fun k H => (currentCodegree H u v : ℝ)/earlyTemplateScale 1 2 n k) (prefixTime n) j ω| then 1 else 0) ≤ 2*(prefixTime n+1 : ℝ)*Real.exp (-r^2/(4*((6/prefixD n)*(4+8*Real.log n+r+6/prefixD n)+(6/prefixD n)*r))) := by filter_upwards [earlyTemplateScale_regular 1 2,earlyTemplateScale_log_budget 1 2, prefixDensity_eventually_inverse_lower,eventually_ge_atTop (2 : ℕ)] with n hreg hbudget hp hn intro u v r hr have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) have hpp : 0 < prefixDensity n := lt_of_lt_of_le (by positivity) hp have hD : 0 < prefixD n := by unfold prefixD; positivity have hc : 0 < 6/prefixD n := by positivity have hjump : ∀ k < prefixTime n, 6/earlyTemplateScale 1 2 n (k+1) ≤ 6/prefixD n := by intro k hk exact div_le_div_of_nonneg_left (by norm_num) hD (earlyCodegreeScale_ge_prefixD n (k+1) (by omega) hpp.le) have ht := codegree_relative_noise_tail u v (completeGraph n) (prefixTime n) (earlyTemplateScale 1 2 n) (6/prefixD n) 2 hc (by norm_num) hreg.1 hreg.2.1 hjump r hr apply ht.trans apply mul_le_mul_of_nonneg_left _ (by positivity) apply Real.exp_le_exp.mpr rw [neg_div,neg_div] apply neg_le_neg have hinit := initial_codegree_relative_le_four hn u v have hz := relativeScaleBudget_nonneg (earlyTemplateScale 1 2 n) (prefixTime n) hreg.1 hreg.2.1 have hi0 : 0 ≤ (currentCodegree (completeGraph n) u v : ℝ)/earlyTemplateScale 1 2 n 0 := div_nonneg (Nat.cast_nonneg _) (hreg.1 0 (Nat.zero_le _)).le have hd0 : 0 < 4*((6/prefixD n)* ((currentCodegree (completeGraph n) u v : ℝ)/earlyTemplateScale 1 2 n 0+ 2*relativeScaleBudget (earlyTemplateScale 1 2 n) (prefixTime n)+r+6/prefixD n)+ (6/prefixD n)*r) := by positivity apply div_le_div_of_nonneg_left (sq_nonneg r) hd0 have hh := mul_le_mul_of_nonneg_left (show (currentCodegree (completeGraph n) u v : ℝ)/earlyTemplateScale 1 2 n 0+ 2*relativeScaleBudget (earlyTemplateScale 1 2 n) (prefixTime n)+r+6/prefixD n ≤ 4+8*Real.log n+r+6/prefixD n by norm_num at hbudget; linarith) hc.le linarith
end SharpTerminalLeave
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import Mathlibimport OAI.Combinatorics.TriangleRemoval.Spectral.GraphStarApproximationimport OAI.Combinatorics.TriangleRemoval.Process.LinkSimpleGraph
namespace OAI
sectionsectionopen Filteropen scoped BigOperators Topologyopen InnerProductSpaceopen scoped InnerProductSpaceopen scoped BigOperators NNRealopen Matrixopen scoped BigOperators Matrix.Norms.L2Operatoropen Matrix InnerProductSpaceopen scoped BigOperators
namespace SharpTerminalLeaveopen scoped Matrix.Norms.L2Operator
theorem goodPrefix_star_approximation {n : ℕ} {G : Graph n} {c C : ℝ} (h : GoodPrefixGraph n c C G) (u : Fin n) [Nonempty (neighbors G u)] (j : ℕ) (hj : j+3 ≤ prefixCycleCap) (heven : Even (j+3)) (hD : 1 ≤ prefixD n) (hδ : (n : ℝ)^(-c) ≤ 1) : ‖(prefixD n)⁻¹ • (linkSimpleGraph G h.1 u).adjMatrix ℝ - averagingProjector‖ ≤ 4 * (((j+4 : ℕ) : ℝ) * (n : ℝ)^(-c) + ((j+3 : ℕ) : ℝ)^(j+4) * 2^(j+3) * ((neighbors G u).card / prefixD n^((j+3)/2) + 1/prefixD n)) ^ (1 / ((j+3 : ℕ) : ℝ)) + 7*(n : ℝ)^(-c) := by have hc := h.2.2.2.2.1 have hmain := hc (j+3) (by omega) hj u rw [linkCycleCount_eq_graphEmbeddings (j := j+1) G h.1 u] at hmain have hcyc : ∀ b, 3 ≤ b → b < j+3 → ((graphEmbeddings (SimpleGraph.cycleGraph b) (linkSimpleGraph G h.1 u)).card : ℝ) ≤ 2 * prefixD n ^ b := by intro b hb hbj have hh := (abs_le.mp (hc b hb (by omega) u)).2 have heq : b = b-2+2 := by omega have hcount : linkCycleCount b G u = ((graphEmbeddings (SimpleGraph.cycleGraph b) (linkSimpleGraph G h.1 u)).card : ℝ) := by rw [heq] exact linkCycleCount_eq_graphEmbeddings G h.1 u rw [hcount] at hh have hx := mul_le_mul_of_nonneg_right hδ (pow_nonneg (le_trans zero_le_one hD) b) nlinarith simpa only [Fintype.card_coe] using graph_star_approximation (linkSimpleGraph G h.1 u) j heven (prefixD n) ((n : ℝ)^(-c)) hD (Real.rpow_nonneg (Nat.cast_nonneg _) _) hδ (goodPrefix_link_rows h u) hmain hcyc
theorem goodPrefix_star_fixed {n : ℕ} {G : Graph n} {c C : ℝ} (h : GoodPrefixGraph n c C G) (u : Fin n) [Nonempty (neighbors G u)] (hD : 1 ≤ prefixD n) (hδ : (n : ℝ)^(-c) ≤ 1) : ‖(prefixD n)⁻¹ • (linkSimpleGraph G h.1 u).adjMatrix ℝ - averagingProjector‖ ≤ 4 * ((8001 : ℝ) * (n : ℝ)^(-c) + (8000 : ℝ)^8001 * 2^8000 * ((neighbors G u).card / prefixD n^4000 + 1/prefixD n)) ^ (1 / (8000 : ℝ)) + 7*(n : ℝ)^(-c) := by exact goodPrefix_star_approximation h u 7997 (by decide) (by decide) hD hδ
end SharpTerminalLeave
open scoped BigOperators Matrix.Norms.L2Operatoropen Matrix
endend
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.FinishSupportSubsetimport OAI.Combinatorics.TriangleRemoval.Stability.GridCavityWeightLowerimport OAI.Combinatorics.TriangleRemoval.Process.AveragedSingletonSurvivalError
namespace OAI
sectionopen scoped BigOperators Topology Matrix.Norms.Operatoropen MeasureTheoryopen scoped BigOperatorsopen scoped BigOperators ENNReal Classicalopen Filter MeasureTheoryopen Filteropen scoped BigOperators Topology
namespace SharpTerminalLeave
theorem goodPrefix_survival_moments (c C : ℝ) (hc : 0 < c) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ n : ℕ in atTop, ∀ (G : Graph n), GoodPrefixGraph n c C G → ∀ hne : G.Nonempty, (|pmfMean (PMF.uniformOfFinset G hne) (fun e => focusSurvival G {e})- cavityReference (prefixD n) 1| ≤ 8192*(1+2*prefixD n)^48/prefixD n^50+ε*cavityReference (prefixD n) 1) ∧ (|pmfMean (PMF.uniformOfFinset G hne) (fun e => pmfMean (PMF.uniformOfFinset G hne) (fun f => focusSurvival G {e,f}))- (cavityReference (prefixD n) 1)^2| ≤ 65536*(1+2*prefixD n)^48/prefixD n^50+8/(n : ℝ)+ (2*ε+ε^2)*(cavityReference (prefixD n) 1)^2) := by filter_upwards [goodPrefix_cavity_stability hc hε, averaged_singleton_collisionCost c C hc,averaged_disjoint_collisionCost c C hc, goodPrefix_rootOverlap hc,goodPrefix_full_continuous_rows hc] with n hrel hsingle hpair hover hpos intro G hG hne have hr := (hrel C G hG 1 ⟨by norm_num,le_rfl⟩).1 constructor · exact (averaged_singleton_survival_error G hne (prefixD n) ε hpos.1 hr).trans (add_le_add (hsingle G hG hne) le_rfl) · exact (averaged_pair_survival_error G hne hG.1 (prefixD n) ε hpos.1 hε.le hr).trans (add_le_add (add_le_add (hpair G hG hne) (hover C G hG hne)) le_rfl)
lemma focusSurvival_singleton_mean {n : ℕ} (G : Graph n) (e : Finset (Fin n)) : focusSurvival G {e} = pmfMean (finish G) (fun H => if e ∈ H then 1 else 0) := by classical unfold focusSurvival rw [trueProbability_map] simp only [Finset.singleton_subset_iff,decide_eq_true_eq,pmfMean]
lemma focusSurvival_pair_mean {n : ℕ} (G : Graph n) (e f : Finset (Fin n)) : focusSurvival G {e,f} = pmfMean (finish G) (fun H => if e ∈ H ∧ f ∈ H then 1 else 0) := by classical unfold focusSurvival rw [trueProbability_map] simp only [Finset.insert_subset_iff,Finset.singleton_subset_iff,decide_eq_true_eq,pmfMean]
theorem terminal_first_focus_moment {n : ℕ} (G : Graph n) (hne : G.Nonempty) : pmfMean (PMF.uniformOfFinset G hne) (fun e => focusSurvival G {e}) = pmfMean (finish G) (fun H => (H.card : ℝ))/(G.card : ℝ) := by simp_rw [focusSurvival_singleton_mean] rw [pmfMean_swap] exact terminal_first_edge_moment G hne
theorem terminal_second_focus_moment {n : ℕ} (G : Graph n) (hne : G.Nonempty) : pmfMean (PMF.uniformOfFinset G hne) (fun e => pmfMean (PMF.uniformOfFinset G hne) (fun f => focusSurvival G {e,f})) = pmfMean (finish G) (fun H => (H.card : ℝ)^2)/(G.card : ℝ)^2 := by simp_rw [focusSurvival_pair_mean] calc _ = pmfMean (PMF.uniformOfFinset G hne) (fun e => pmfMean (finish G) (fun H => pmfMean (PMF.uniformOfFinset G hne) (fun f => if e ∈ H ∧ f ∈ H then 1 else 0))) := by apply congrArg funext e exact pmfMean_swap _ _ _ _ = pmfMean (finish G) (fun H => pmfMean (PMF.uniformOfFinset G hne) (fun e => pmfMean (PMF.uniformOfFinset G hne) (fun f => if e ∈ H ∧ f ∈ H then 1 else 0))) := pmfMean_swap _ _ _ _ = _ := terminal_second_edge_moment G hne
end SharpTerminalLeave
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import Mathlibimport OAI.Combinatorics.TriangleRemoval.Process.TriangleNoiseJumpBudgetimport OAI.Combinatorics.TriangleRemoval.Tracking.PrefixPairClosureBudget
namespace OAI
sectionnoncomputable sectionopen scoped BigOperators Topologyopen Filter Classical
namespace SharpTerminalLeave
lemma normalized_tracking_absolute {X s r : ℝ} (hs : 0 < s) (hr : 0 ≤ r) (h : |X/s-1| ≤ r/2) : |X-s| ≤ r*s := by rw [show X/s-1 = (X-s)/s by rw [sub_div,div_self hs.ne'],abs_div,abs_of_pos hs] at h exact ((div_le_iff₀ hs).mp h).trans (mul_le_mul_of_nonneg_right (by linarith only [hr]) hs.le)
theorem prefix_good_history : ∀ᶠ n : ℕ in atTop, ∀ ω : History (Graph n) (prefixTime n), ω ∈ (historyLaw (PMF.pure (completeGraph n)) (fun _ => step) (prefixTime n) (prefixTime n)).support → PrefixRootedUpper 8001 n ω → PrefixBalancedNoise 8001 n ω → PrefixTriangleNoise n ω → PrefixCodegreeNoiseGood n ω → GoodPrefixGraph n (1/80000) (3*(8001 : ℕ)+2 : ℕ) (ω (historyIndex (prefixTime n) (prefixTime n))) := by filter_upwards [prefix_present_edge_closure,prefix_all_pair_closure,prefix_degree_wheel_tracking, prefixDensity_eventually_inverse_lower,eventually_ge_atTop (1 : ℕ)] with n hedge hpair hwheel hp hn intro ω hω hroot hbalanced htri hnoise have hn0 : 0 < n := by omega have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn have hnR : (0 : ℝ) < n := lt_of_lt_of_le zero_lt_one hn1 have hedges := hedge ω hω hroot hbalanced htri hnoise have halive : historyAlive (fun i => densityEdgeSafe n (earlyDensity n i) (prefixEdgeRadius n)) (prefixTime n) (prefixTime n) ω := fun i hi => hedges i hi.le have he := hedges (prefixTime n) le_rfl have hw := hwheel ω hω hroot hbalanced (prefixTime n) le_rfl halive have hc := hpair ω hω hroot hbalanced htri hnoise (prefixTime n) le_rfl have hpp : 0 < prefixDensity n := (div_pos zero_lt_one hnR).trans_le hp have hr : 0 ≤ prefixWheelRadius n := Real.rpow_nonneg hnR.le _ have hdeg := mul_pos hnR hpp have hD : 0 < prefixD n := mul_pos hnR (sq_pos_of_pos hpp) refine ⟨he.1,?_,?_,?_,?_,?_⟩ · simpa only [earlyDensity_prefix,prefixM] using he.2.1 · intro u have hh := hw.1 u rw [earlyDensity_prefix] at hh simpa only [prefixWheelRadius,neg_div] using normalized_tracking_absolute hdeg hr hh · intro u v huv have hh := hc u v huv simp only [prefixNormalizedCodegree,earlyTemplateScale,pow_one,earlyDensity_prefix] at hh simpa only [prefixD,prefixWheelRadius,neg_div] using normalized_tracking_absolute hD hr hh · intro j hj hj' u have hh := hw.2 j hj hj' u rw [earlyDensity_prefix] at hh simpa only [prefixD,prefixWheelRadius,neg_div] using normalized_tracking_absolute (pow_pos hD j) hr hh · intro k hk T ψ have hh := (hroot (prefixTime n) le_rfl halive k hk T ψ).le rw [earlyDensity_prefix] at hh have hfac : (1+Real.log (n : ℝ))^(3*8001+2) = prefixTemplateFactor n (3*(8001 : ℕ)+2 : ℕ) := by simp only [prefixTemplateFactor,Real.rpow_natCast] rw [hfac] at hh have hfac0 : 0 ≤ prefixTemplateFactor n (3*(8001 : ℕ)+2 : ℕ) := Real.rpow_nonneg (by have := Real.log_nonneg hn1; linarith) _ constructor · intro hlarge exact hh.trans (mul_le_mul_of_nonneg_left (rootedCompletionMax_large T hpp.le hlarge) hfac0) · intro hsmall exact hh.trans ((mul_le_mul_of_nonneg_left (rootedCompletionMax_small T hsmall) hfac0).trans_eq (mul_one _))
lemma four_prefix_margins : ∀ᶠ n : ℕ in atTop, 4*Real.exp (-2*(Real.log (n : ℝ))^(4/3 : ℝ)) ≤ Real.exp (-(Real.log (n : ℝ))^(4/3 : ℝ)) := by have ht : Tendsto (fun n : ℕ => (Real.log (n : ℝ))^(4/3 : ℝ)) atTop atTop := (tendsto_rpow_atTop (by norm_num : (0 : ℝ) < 4/3)).comp (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop) filter_upwards [ht.eventually (eventually_ge_atTop (Real.log 4))] with n hn have hh : (4 : ℝ) ≤ Real.exp ((Real.log (n : ℝ))^(4/3 : ℝ)) := by calc (4 : ℝ) = Real.exp (Real.log 4) := (Real.exp_log (by norm_num)).symm _ ≤ _ := Real.exp_le_exp.mpr hn calc _ ≤ Real.exp ((Real.log (n : ℝ))^(4/3 : ℝ))*Real.exp (-2*(Real.log (n : ℝ))^(4/3 : ℝ)) := mul_le_mul_of_nonneg_right hh (Real.exp_pos _).le _ = _ := by rw [← Real.exp_add]; congr 1; ring
theorem uniform_prefix_obligation : UniformPrefixObligation := by refine ⟨1/80000,by norm_num,(3*(8001 : ℕ)+2 : ℕ),?_⟩ filter_upwards [prefix_good_history,prefix_rooted_upper_failure 8001, prefix_balanced_noise_failure 8001,prefix_triangle_noise_failure, prefix_codegree_noise_failure,four_prefix_margins] with n hgood hr hb ht hc hmargin let μ := historyLaw (PMF.pure (completeGraph n)) (fun _ => step) (prefixTime n) (prefixTime n) have hm : μ.map (fun ω => ω (historyIndex (prefixTime n) (prefixTime n))) = prefixLaw n := by rw [historyLaw_marginal _ _ _ _ le_rfl,markovLaw_triangle_step] rfl unfold prefixFailure rw [← hm,pmfMean_map] have hpoint : ∀ ω ∈ μ.support, (if GoodPrefixGraph n (1/80000) (3*(8001 : ℕ)+2 : ℕ) (ω (historyIndex (prefixTime n) (prefixTime n))) then (0 : ℝ) else 1) ≤ (if PrefixRootedUpper 8001 n ω then 0 else 1)+ (if PrefixBalancedNoise 8001 n ω then 0 else 1)+ (if PrefixTriangleNoise n ω then 0 else 1)+ (if PrefixCodegreeNoiseGood n ω then 0 else 1) := by intro ω hω by_cases h₁ : PrefixRootedUpper 8001 n ω <;> by_cases h₂ : PrefixBalancedNoise 8001 n ω <;> by_cases h₃ : PrefixTriangleNoise n ω <;> by_cases h₄ : PrefixCodegreeNoiseGood n ω all_goals simp only [h₁,h₂,h₃,h₄,ite_true,ite_false] · rw [ite_eq_left (hgood ω hω h₁ h₂ h₃ h₄)]; norm_num all_goals split_ifs <;> norm_num have hs := pmfMean_mono μ hpoint simp only [pmfMean_add] at hs apply hs.trans have hs' := add_le_add (add_le_add (add_le_add hr hb) ht) hc calc _ ≤ ((Real.exp (-2*(Real.log (n : ℝ))^(4/3 : ℝ))+ Real.exp (-2*(Real.log (n : ℝ))^(4/3 : ℝ)))+ Real.exp (-2*(Real.log (n : ℝ))^(4/3 : ℝ)))+ Real.exp (-2*(Real.log (n : ℝ))^(4/3 : ℝ)) := hs' _ = 4*Real.exp (-2*(Real.log (n : ℝ))^(4/3 : ℝ)) := by ring _ ≤ _ := hmargin
end SharpTerminalLeaveendend
end OAIlean/OAI/Combinatorics/TriangleRemoval/Spectral/ClosedWalkFamily.leanAdded+145
lean/OAI/Combinatorics/TriangleRemoval/Spectral/ClosedWalkPattern.leanAdded+120
lean/OAI/Combinatorics/TriangleRemoval/Spectral/ClosedWords.leanAdded+123
lean/OAI/Combinatorics/TriangleRemoval/Spectral/CountClosedWalk.leanAdded+99
lean/OAI/Combinatorics/TriangleRemoval/Spectral/DensityGlobalSpectral.leanAdded+111
lean/OAI/Combinatorics/TriangleRemoval/Spectral/EdgeStar.leanAdded+96
lean/OAI/Combinatorics/TriangleRemoval/Spectral/ExtendStarApply.leanAdded+51
lean/OAI/Combinatorics/TriangleRemoval/Spectral/ExtendStarMulVec.leanAdded+86
lean/OAI/Combinatorics/TriangleRemoval/Spectral/FallingFactorialNormalizedProduct.leanAdded+130
lean/OAI/Combinatorics/TriangleRemoval/Spectral/FreshLogCheckNone.leanAdded+49
lean/OAI/Combinatorics/TriangleRemoval/Spectral/FreshLogCheckNone2.leanAdded+54
lean/OAI/Combinatorics/TriangleRemoval/Spectral/FreshLogCheckNone3.leanAdded+47
lean/OAI/Combinatorics/TriangleRemoval/Spectral/GlobalLinkAdjacencyHermitian.leanAdded+85
lean/OAI/Combinatorics/TriangleRemoval/Spectral/GraphStarApproximation.leanAdded+92
lean/OAI/Combinatorics/TriangleRemoval/Spectral/LinkStarMatrix.leanAdded+116
lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixEuclideanAlgHom.leanAdded+74
lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixExpL2Bound.leanAdded+60
lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixInfinityAlgHom.leanAdded+42
lean/OAI/Combinatorics/TriangleRemoval/Spectral/MatrixRowAbsSum.leanAdded+89
lean/OAI/Combinatorics/TriangleRemoval/Spectral/MovingStarDegree.leanAdded+327
lean/OAI/Combinatorics/TriangleRemoval/Spectral/NormalizedOnes.leanAdded+143
lean/OAI/Combinatorics/TriangleRemoval/Spectral/RealTraceAdjMatrix.leanAdded+132
lean/OAI/Combinatorics/TriangleRemoval/Spectral/StarInclusion.leanAdded+127
lean/OAI/Combinatorics/TriangleRemoval/Spectral/TracedGridQueryAddress.leanAdded+133
lean/OAI/Combinatorics/TriangleRemoval/Spectral/TracedGridQueryLog.leanAdded+55
lean/OAI/Combinatorics/TriangleRemoval/Spectral/TracedGridQuerySeparated.leanAdded+88
lean/OAI/Combinatorics/TriangleRemoval/Spectral/WheelSpoke.leanAdded+246
lean/OAI/Combinatorics/TriangleRemoval/Stability/ActiveCavityFactorProduct.leanAdded+129
lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityGenerator.leanAdded+361
lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityReference.leanAdded+183
lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityWeight.leanAdded+138
lean/OAI/Combinatorics/TriangleRemoval/Stability/CavityWeightLipschitz.leanAdded+119
lean/OAI/Combinatorics/TriangleRemoval/Stability/ContinuousCavityWeightClip.leanAdded+111
lean/OAI/Combinatorics/TriangleRemoval/Stability/EdgeStabilityRate.leanAdded+117
lean/OAI/Combinatorics/TriangleRemoval/Stability/GeometricVolterraIdentity.leanAdded+123
lean/OAI/Combinatorics/TriangleRemoval/Stability/GridCavityError.leanAdded+304
lean/OAI/Combinatorics/TriangleRemoval/Stability/GridCavityWeightLower.leanAdded+131
lean/OAI/Combinatorics/TriangleRemoval/Stability/MovingPerturbationFiniteExpansion.leanAdded+96
lean/OAI/Combinatorics/TriangleRemoval/Stability/MovingResidualForcing.leanAdded+171
lean/OAI/Combinatorics/TriangleRemoval/Stability/RelativeTemplateResidual.leanAdded+77
lean/OAI/Combinatorics/TriangleRemoval/Stability/Volterra.leanAdded+231
lean/OAI/Combinatorics/TriangleRemoval/Tracking/BalancedJump.leanAdded+205
lean/OAI/Combinatorics/TriangleRemoval/Tracking/CenteredCodegreeNeighborSum.leanAdded+72
lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeNoiseRadius.leanAdded+79
lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeRelativeNoiseTail.leanAdded+52
lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeVarianceRate.leanAdded+89
lean/OAI/Combinatorics/TriangleRemoval/Tracking/CodegreeVertexCount.leanAdded+103
lean/OAI/Combinatorics/TriangleRemoval/Tracking/GoodPrefixStarApproximation.leanAdded+67
lean/OAI/Combinatorics/TriangleRemoval/Tracking/GoodPrefixSurvivalMoments.leanAdded+85
lean/OAI/Combinatorics/TriangleRemoval/Tracking/NormalizedTrackingAbsolute.leanAdded+125