Add lean source and binary files (part 56)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- lean/OAI/Combinatorics/Sensitivity/RecursiveJointZero.leanAdded+97
- lean/OAI/Combinatorics/Sensitivity/RecursiveOne.leanAdded+150
- lean/OAI/Combinatorics/Sensitivity/RecursiveProfiles.leanAdded+110
- lean/OAI/Combinatorics/Sensitivity/RecursiveRepair.leanAdded+103
- lean/OAI/Combinatorics/Sensitivity/RecursiveSets.leanAdded+89
- lean/OAI/Combinatorics/Sensitivity/RecursiveZero.leanAdded+121
- lean/OAI/Combinatorics/Sensitivity/Reindex.leanAdded+106
- lean/OAI/Combinatorics/Sensitivity/ScalarBounds.leanAdded+54
- lean/OAI/Combinatorics/Sensitivity/SeedAmplification.leanAdded+47
- lean/OAI/Combinatorics/Sensitivity/Separation.leanAdded+57
- lean/OAI/Combinatorics/Sensitivity/SeparationArithmetic.leanAdded+116
- lean/OAI/Combinatorics/Sensitivity/Tournament.leanAdded+68
- lean/OAI/Combinatorics/Sensitivity/TournamentCounts.leanAdded+69
- lean/OAI/Combinatorics/Sensitivity/TournamentCyclic.leanAdded+53
- lean/OAI/Combinatorics/Sensitivity/Tower.leanAdded+161
- lean/OAI/Combinatorics/Sensitivity/TowerProfiles.leanAdded+80
- lean/OAI/Combinatorics/Sensitivity/UniformCoordinates.leanAdded+31
- lean/OAI/Combinatorics/SharpRamsey/Bounds/FromConstruction.leanAdded+79
- lean/OAI/Combinatorics/SharpRamsey/Bounds/Lower.leanAdded+186
- lean/OAI/Combinatorics/SharpRamsey/Bounds/SamplingParameter.leanAdded+313
- lean/OAI/Combinatorics/SharpRamsey/Bounds/SumFiberCenter.leanAdded+461
- lean/OAI/Combinatorics/SharpRamsey/Bounds/Upper.leanAdded+452
- lean/OAI/Combinatorics/SharpRamsey/Construction/FiniteStreamTail.leanAdded+124
- lean/OAI/Combinatorics/SharpRamsey/Construction/FlagConstruction.leanAdded+217
- lean/OAI/Combinatorics/SharpRamsey/Construction/GraphWitness.leanAdded+73
- lean/OAI/Combinatorics/SharpRamsey/Construction/InitialLaw.leanAdded+121
- lean/OAI/Combinatorics/SharpRamsey/Construction/InitialRectangles.leanAdded+137
- lean/OAI/Combinatorics/SharpRamsey/Construction/InitialTools.leanAdded+96
- lean/OAI/Combinatorics/SharpRamsey/Construction/PrimeConstruction.leanAdded+35
- lean/OAI/Combinatorics/SharpRamsey/Construction/RectangleStreamEvent.leanAdded+157
- lean/OAI/Combinatorics/SharpRamsey/Construction/SourceSizes.leanAdded+47
- lean/OAI/Combinatorics/SharpRamsey/Entropy/AnchorEventsRealized.leanAdded+478
- lean/OAI/Combinatorics/SharpRamsey/Entropy/CompleteProgramWeight.leanAdded+463
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ComponentLabelWitness.leanAdded+460
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ExternalMass.leanAdded+478
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ForcedHits.leanAdded+467
- lean/OAI/Combinatorics/SharpRamsey/Entropy/HighMoments.leanAdded+423
- lean/OAI/Combinatorics/SharpRamsey/Entropy/HighRankEntropy.leanAdded+63
- lean/OAI/Combinatorics/SharpRamsey/Entropy/InformationScales.leanAdded+30
- lean/OAI/Combinatorics/SharpRamsey/Entropy/IntegralTypicalScoreSq.leanAdded+450
- lean/OAI/Combinatorics/SharpRamsey/Entropy/LabelledFilterCard.leanAdded+469
- lean/OAI/Combinatorics/SharpRamsey/Entropy/LargeCard.leanAdded+448
- lean/OAI/Combinatorics/SharpRamsey/Entropy/MakePair.leanAdded+470
- lean/OAI/Combinatorics/SharpRamsey/Entropy/MarkingTwoEntropy.leanAdded+66
- lean/OAI/Combinatorics/SharpRamsey/Entropy/NewEvents.leanAdded+487
- lean/OAI/Combinatorics/SharpRamsey/Entropy/PatchNotMem.leanAdded+454
- lean/OAI/Combinatorics/SharpRamsey/Entropy/PoissonLaw.leanAdded+465
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ProtocolEntropy.leanAdded+90
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ReciprocalEntropy.leanAdded+114
- lean/OAI/Combinatorics/SharpRamsey/Entropy/SelectedEntropy.leanAdded+67
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import OAI.Combinatorics.Sensitivity.RecursiveCandidates
namespace OAI
/-! The joint zero recurrence uses the fixed weaker-threshold failure lists. -/
noncomputable sectionopen scoped Classical
namespace Paper320
theorem recursive_joint_zero_at {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (A : GoodLabeling T r) (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) (q q' : Fin h) (hqq : q < q') (x : ((Fin k × Fin r) × I) → Bool) (hx : recursiveFamily T A.label F q x = false) (hx' : recursiveFamily T A.label F q' x = false) : jointSensitivityAt (recursiveFamily T A.label F q) (recursiveFamily T A.label F q') x ≤ 16 * sideSensitivity F false + 3 * jointSensitivity F true := by let TC := targetCandidates T A.label F q x let GC := gateCandidates T A.label F q x let w := gateWitness T A.label F q x let U := TC.biUnion fun i => childChanges F (Fin.last h) x i (targetWitness F x hr i) let V := GC.biUnion fun i => childJointChanges F (gateIndex q') (gateIndex q) x (w i) (A.label i (w i)) have hsub : (Finset.univ.filter fun p => recursiveFamily T A.label F q (flip x {p}) ≠ recursiveFamily T A.label F q x ∧ recursiveFamily T A.label F q' (flip x {p}) ≠ recursiveFamily T A.label F q' x) ⊆ U ∪ V := by rintro ⟨⟨j, c⟩, a⟩ hp have hchange := (Finset.mem_filter.mp hp).2 have hon' : recursiveFamily T A.label F q' (flip x {((j, c), a)}) = true := by cases hy : recursiveFamily T A.label F q' (flip x {((j, c), a)}) · exact False.elim (hchange.2 (hy.trans hx'.symm)) · rfl obtain ⟨i, hi'⟩ := (recursiveFamily_eq_true_iff T A.label F q' _).mp hon' have hi := rowClause_nested T A.label F hF hqq.le _ i hi' have hioff := (recursiveFamily_eq_false_iff T A.label F q x).mp hx i rcases rowClause_repair_cases T A.label F q x i j c a hioff hi with ⟨hit, hji, htoff, hton⟩ | ⟨hig, hij, rfl, hgon, hgoff⟩ · subst j have hc := targetWitness_unique T A.label F q x hr i hit c htoff apply Finset.mem_union_left apply Finset.mem_biUnion.mpr refine ⟨i, hit, ?_⟩ have hn : F (Fin.last h) (flip (recursiveChild x i c) {a}) ≠ F (Fin.last h) (recursiveChild x i c) := by simp [hton, htoff] simpa [childChanges, hc] using hn · have hj := gateWitness_unique T A.label F q x i hig j hij hgon have hgon' := hF.accepts_of_le (gateIndex_strictAnti hqq).le hgon have hgoff' := ((rowClause_eq_true_iff T A.label F q' _ i).mp hi').2 j hij rw [recursiveChild_flip_same] at hgoff' apply Finset.mem_union_right apply Finset.mem_biUnion.mpr refine ⟨i, hig, ?_⟩ have hn : F (gateIndex q') (flip (recursiveChild x j (A.label i j)) {a}) ≠ F (gateIndex q') (recursiveChild x j (A.label i j)) ∧ F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠ F (gateIndex q) (recursiveChild x j (A.label i j)) := by simp [hgon, hgoff, hgon', hgoff'] simpa [childJointChanges, w, hj] using hn have hU : U.card ≤ 16 * sideSensitivity F false := by calc U.card ≤ TC.card * sideSensitivity F false := card_biUnion_le_mul TC _ _ (fun i hi => by rw [childChanges_card] exact sensitivityAt_le_sideSensitivity F false _ _ (targetWitness_false T A.label F q x hr i hi)) _ ≤ 16 * sideSensitivity F false := Nat.mul_le_mul_right _ (Nat.le_of_lt (targetCandidates_card T A F hF q x hr)) have hV : V.card ≤ 3 * jointSensitivity F true := by calc V.card ≤ GC.card * jointSensitivity F true := card_biUnion_le_mul GC _ _ (fun i hi => by rw [childJointChanges_card] have hg := (gateWitness_spec T A.label F q x i hi).2 exact jointSensitivityAt_le_jointSensitivity F true _ _ _ (gateIndex_strictAnti hqq) (hF.accepts_of_le (gateIndex_strictAnti hqq).le hg) hg) _ ≤ 3 * jointSensitivity F true := Nat.mul_le_mul_right _ (gateCandidates_card T A.label F hF q x) calc jointSensitivityAt (recursiveFamily T A.label F q) (recursiveFamily T A.label F q') x ≤ (U ∪ V).card := Finset.card_le_card hsub _ ≤ U.card + V.card := Finset.card_union_le _ _ _ ≤ _ := Nat.add_le_add hU hV
theorem recursive_joint_zero {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (A : GoodLabeling T r) (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) : jointSensitivity (recursiveFamily T A.label F) false ≤ 16 * sideSensitivity F false + 3 * jointSensitivity F true := by apply jointSensitivity_le exact fun q q' x hqq hx hx' => recursive_joint_zero_at T A F hF hr q q' hqq x hx hx'
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150import OAI.Combinatorics.Sensitivity.RecursiveSets
namespace OAI
/-! The two recurrences for inputs at which the parent predicates accept. -/
noncomputable sectionopen scoped Classical
namespace Paper320
theorem recursive_sensitivity_one_at {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (o : ℕ) (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (hx : recursiveFamily T label F q x = true) : sensitivityAt (recursiveFamily T label F q) x ≤ o * sideSensitivity F false + r * sideSensitivity F true := by obtain ⟨i, hi⟩ := (recursiveFamily_eq_true_iff T label F q x).mp hx have hcond := (rowClause_eq_true_iff T label F q x i).mp hi let U := Finset.univ.biUnion fun c => childChanges F (Fin.last h) x i c let V := (Finset.univ.filter (T.Adj i)).biUnion fun j => childChanges F (gateIndex q) x j (label i j) have hsub : (Finset.univ.filter fun p => recursiveFamily T label F q (flip x {p}) ≠ recursiveFamily T label F q x) ⊆ U ∪ V := by rintro ⟨⟨j, c⟩, a⟩ hp have hchange := (Finset.mem_filter.mp hp).2 have hf : recursiveFamily T label F q (flip x {((j, c), a)}) = false := by cases hy : recursiveFamily T label F q (flip x {((j, c), a)}) · rfl · exact False.elim (hchange (hy.trans hx.symm)) have hif := (recursiveFamily_eq_false_iff T label F q _).mp hf i have hic : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by simp [hi, hif] rcases rowClause_flip_change T label F q x i j c a hic with ⟨rfl, ht⟩ | ⟨hij, rfl, hg⟩ · apply Finset.mem_union_left apply Finset.mem_biUnion.mpr exact ⟨c, Finset.mem_univ _, by simpa [childChanges] using ht⟩ · apply Finset.mem_union_right apply Finset.mem_biUnion.mpr exact ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hij⟩, by simpa [childChanges] using hg⟩ have hU : U.card ≤ r * sideSensitivity F true := by simpa [U] using card_biUnion_le_mul Finset.univ (fun c => childChanges F (Fin.last h) x i c) (sideSensitivity F true) (fun c _ => by rw [childChanges_card] exact sensitivityAt_le_sideSensitivity F true _ _ (hcond.1 c)) have hV : V.card ≤ o * sideSensitivity F false := by simpa only [V, ho i] using card_biUnion_le_mul (Finset.univ.filter (T.Adj i)) (fun j => childChanges F (gateIndex q) x j (label i j)) (sideSensitivity F false) (fun j hj => by rw [childChanges_card] exact sensitivityAt_le_sideSensitivity F false _ _ (hcond.2 j (Finset.mem_filter.mp hj).2)) calc sensitivityAt (recursiveFamily T label F q) x ≤ (U ∪ V).card := Finset.card_le_card hsub _ ≤ U.card + V.card := Finset.card_union_le _ _ _ ≤ r * sideSensitivity F true + o * sideSensitivity F false := Nat.add_le_add hU hV _ = _ := Nat.add_comm _ _
theorem recursive_side_one {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (o : ℕ) (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) : sideSensitivity (recursiveFamily T label F) true ≤ o * sideSensitivity F false + r * sideSensitivity F true := by apply sideSensitivity_le exact fun q x hx => recursive_sensitivity_one_at T label F o ho q x hx
theorem recursive_joint_one_at {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (o : ℕ) (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) (q q' : Fin h) (hqq : q < q') (x : ((Fin k × Fin r) × I) → Bool) (hx : recursiveFamily T label F q x = true) (hx' : recursiveFamily T label F q' x = true) : jointSensitivityAt (recursiveFamily T label F q) (recursiveFamily T label F q') x ≤ o * jointSensitivity F false + r * sideSensitivity F true := by obtain ⟨i, hi'⟩ := (recursiveFamily_eq_true_iff T label F q' x).mp hx' have hi := rowClause_nested T label F hF hqq.le x i hi' have hcond := (rowClause_eq_true_iff T label F q x i).mp hi have hcond' := (rowClause_eq_true_iff T label F q' x i).mp hi' let U := Finset.univ.biUnion fun c => childChanges F (Fin.last h) x i c let V := (Finset.univ.filter (T.Adj i)).biUnion fun j => childJointChanges F (gateIndex q') (gateIndex q) x j (label i j) have hsub : (Finset.univ.filter fun p => recursiveFamily T label F q (flip x {p}) ≠ recursiveFamily T label F q x ∧ recursiveFamily T label F q' (flip x {p}) ≠ recursiveFamily T label F q' x) ⊆ U ∪ V := by rintro ⟨⟨j, c⟩, a⟩ hp have hchange := (Finset.mem_filter.mp hp).2 have hf : recursiveFamily T label F q (flip x {((j, c), a)}) = false := by cases hy : recursiveFamily T label F q (flip x {((j, c), a)}) · rfl · exact False.elim (hchange.1 (hy.trans hx.symm)) have hf' : recursiveFamily T label F q' (flip x {((j, c), a)}) = false := by cases hy : recursiveFamily T label F q' (flip x {((j, c), a)}) · rfl · exact False.elim (hchange.2 (hy.trans hx'.symm)) have hif := (recursiveFamily_eq_false_iff T label F q _).mp hf i have hif' := (recursiveFamily_eq_false_iff T label F q' _).mp hf' i have hic : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by simp [hi, hif] have hic' : rowClause T label F q' (flip x {((j, c), a)}) i ≠ rowClause T label F q' x i := by simp [hi', hif'] rcases rowClause_joint_flip_change T label F q q' x i j c a hic hic' with ⟨rfl, ht⟩ | ⟨hij, rfl, hg, hg'⟩ · apply Finset.mem_union_left apply Finset.mem_biUnion.mpr exact ⟨c, Finset.mem_univ _, by simpa [childChanges] using ht⟩ · apply Finset.mem_union_right apply Finset.mem_biUnion.mpr exact ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hij⟩, by simpa [childJointChanges] using And.intro hg' hg⟩ have hU : U.card ≤ r * sideSensitivity F true := by simpa [U] using card_biUnion_le_mul Finset.univ (fun c => childChanges F (Fin.last h) x i c) (sideSensitivity F true) (fun c _ => by rw [childChanges_card] exact sensitivityAt_le_sideSensitivity F true _ _ (hcond.1 c)) have hV : V.card ≤ o * jointSensitivity F false := by simpa only [V, ho i] using card_biUnion_le_mul (Finset.univ.filter (T.Adj i)) (fun j => childJointChanges F (gateIndex q') (gateIndex q) x j (label i j)) (jointSensitivity F false) (fun j hj => by have hij := (Finset.mem_filter.mp hj).2 rw [childJointChanges_card] exact jointSensitivityAt_le_jointSensitivity F false _ _ _ (gateIndex_strictAnti hqq) (hcond'.2 j hij) (hcond.2 j hij)) calc jointSensitivityAt (recursiveFamily T label F q) (recursiveFamily T label F q') x ≤ (U ∪ V).card := Finset.card_le_card hsub _ ≤ U.card + V.card := Finset.card_union_le _ _ _ ≤ r * sideSensitivity F true + o * jointSensitivity F false := Nat.add_le_add hU hV _ = _ := Nat.add_comm _ _
theorem recursive_joint_one {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (o : ℕ) (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) : jointSensitivity (recursiveFamily T label F) true ≤ o * jointSensitivity F false + r * sideSensitivity F true := by apply jointSensitivity_le exact fun q q' x hqq hx hx' => recursive_joint_one_at T label F hF o ho q q' hqq x hx hx'
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110import OAI.Combinatorics.Sensitivity.Model
namespace OAI
/-! The side and joint profiles count literal flips of the same raw input. -/
noncomputable sectionopen scoped Classical
namespace Paper320
/-- Acceptance at a stronger index implies acceptance at every weaker index. -/structure NestedFamily {h : ℕ} {I : Type} (F : Fin h → (I → Bool) → Bool) : Prop where accepts_of_le : ∀ {q q' : Fin h} {x}, q ≤ q' → F q' x = true → F q x = true
theorem NestedFamily.rejects_of_le {h : ℕ} {I : Type} {F : Fin h → (I → Bool) → Bool} (hF : NestedFamily F) {q q' : Fin h} {x} (hqq : q ≤ q') (hx : F q x = false) : F q' x = false := by cases h' : F q' x · rfl · have := hF.accepts_of_le hqq h' simp [hx] at this
/-- The number of coordinates whose one-bit flip changes both predicates. -/def jointSensitivityAt {I : Type} [Fintype I] (f g : (I → Bool) → Bool) (x : I → Bool) : ℕ := (Finset.univ.filter fun i => f (flip x {i}) ≠ f x ∧ g (flip x {i}) ≠ g x).card
/-- Maximum sensitivity over all indices and inputs with the indicated output. -/def sideSensitivity {h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (b : Bool) : ℕ := Finset.univ.sup fun q => Finset.univ.sup fun x => if F q x = b then sensitivityAt (F q) x else 0
/-- Maximum same-input, same-bit joint sensitivity over two distinct ordered indices. -/def jointSensitivity {h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (b : Bool) : ℕ := Finset.univ.sup fun q => Finset.univ.sup fun q' => Finset.univ.sup fun x => if q < q' ∧ F q x = b ∧ F q' x = b then jointSensitivityAt (F q) (F q') x else 0
theorem sensitivityAt_le_sideSensitivity {h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (b : Bool) (q : Fin h) (x : I → Bool) (hx : F q x = b) : sensitivityAt (F q) x ≤ sideSensitivity F b := by apply Finset.le_sup_of_le (Finset.mem_univ q) apply Finset.le_sup_of_le (Finset.mem_univ x) simp [hx]
theorem sideSensitivity_le {h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (b : Bool) (B : ℕ) (hB : ∀ q x, F q x = b → sensitivityAt (F q) x ≤ B) : sideSensitivity F b ≤ B := by apply Finset.sup_le intro q _ apply Finset.sup_le intro x _ split_ifs with hx · exact hB q x hx · exact Nat.zero_le _
theorem jointSensitivityAt_le_jointSensitivity {h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (b : Bool) (q q' : Fin h) (x : I → Bool) (hqq : q < q') (hx : F q x = b) (hx' : F q' x = b) : jointSensitivityAt (F q) (F q') x ≤ jointSensitivity F b := by apply Finset.le_sup_of_le (Finset.mem_univ q) apply Finset.le_sup_of_le (Finset.mem_univ q') apply Finset.le_sup_of_le (Finset.mem_univ x) simp [hqq, hx, hx']
theorem jointSensitivity_le {h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (b : Bool) (B : ℕ) (hB : ∀ q q' x, q < q' → F q x = b → F q' x = b → jointSensitivityAt (F q) (F q') x ≤ B) : jointSensitivity F b ≤ B := by apply Finset.sup_le intro q _ apply Finset.sup_le intro q' _ apply Finset.sup_le intro x _ split_ifs with hx · exact hB q q' x hx.1 hx.2.1 hx.2.2 · exact Nat.zero_le _
theorem jointSensitivityAt_le_left {I : Type} [Fintype I] (f g : (I → Bool) → Bool) (x : I → Bool) : jointSensitivityAt f g x ≤ sensitivityAt f x := by apply Finset.card_le_card intro i hi exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hi).2.1⟩
theorem jointSensitivityAt_comm {I : Type} [Fintype I] (f g : (I → Bool) → Bool) (x : I → Bool) : jointSensitivityAt f g x = jointSensitivityAt g f x := by simp only [jointSensitivityAt, and_comm]
theorem jointSensitivity_one {I : Type} [Fintype I] (F : Fin 1 → (I → Bool) → Bool) (b : Bool) : jointSensitivity F b = 0 := by apply Nat.eq_zero_of_le_zero apply jointSensitivity_le intro q q' x hqq _ _ exact False.elim (by omega)
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103import OAI.Combinatorics.Sensitivity.RecursiveFailures
namespace OAI
/-! A successful raw-bit flip repairs the unique initial failed condition. -/
noncomputable sectionopen scoped Classical
namespace Paper320
theorem repaired_target_location {k r h : ℕ} {I : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (i j : Fin k) (c c' : Fin r) (a : I) (hf : rowClause T label F q (flip x {((j, c), a)}) i = true) (hz : F (Fin.last h) (recursiveChild x i c') = false) : (i, c') = (j, c) := by by_contra hne have ht := ((rowClause_eq_true_iff T label F q _ i).mp hf).1 c' rw [recursiveChild_flip_other x j i c c' a hne, hz] at ht exact Bool.false_ne_true ht
theorem repaired_gate_location {k r h : ℕ} {I : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (i j j' : Fin k) (c : Fin r) (a : I) (hf : rowClause T label F q (flip x {((j, c), a)}) i = true) (hij' : T.Adj i j') (hon : F (gateIndex q) (recursiveChild x j' (label i j')) = true) : (j', label i j') = (j, c) := by by_contra hne have hg := ((rowClause_eq_true_iff T label F q _ i).mp hf).2 j' hij' rw [recursiveChild_flip_other x j j' c (label i j') a hne, hon] at hg exact Bool.false_ne_true hg.symm
theorem rowClause_repair_cases {k r h : ℕ} {I : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (i j : Fin k) (c : Fin r) (a : I) (hi : rowClause T label F q x i = false) (hf : rowClause T label F q (flip x {((j, c), a)}) i = true) : (i ∈ targetCandidates T label F q x ∧ j = i ∧ F (Fin.last h) (recursiveChild x j c) = false ∧ F (Fin.last h) (flip (recursiveChild x j c) {a}) = true) ∨ (i ∈ gateCandidates T label F q x ∧ T.Adj i j ∧ c = label i j ∧ F (gateIndex q) (recursiveChild x j c) = true ∧ F (gateIndex q) (flip (recursiveChild x j c) {a}) = false) := by have hchange : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by simp [hi, hf] rcases rowClause_flip_change T label F q x i j c a hchange with ⟨hji, ht⟩ | ⟨hij, rfl, hg⟩ · subst j have hton := ((rowClause_eq_true_iff T label F q _ i).mp hf).1 c rw [recursiveChild_flip_same] at hton have htoff : F (Fin.last h) (recursiveChild x i c) = false := by cases hc : F (Fin.last h) (recursiveChild x i c) · rfl · exact False.elim (ht (hton.trans hc.symm)) have htargets : targetFailures F x i = {c} := by ext c' simp only [targetFailures, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] constructor · intro hfalse exact congrArg Prod.snd (repaired_target_location T label F q x i i c c' a hf hfalse) · rintro rfl exact htoff have hgates : gateFailures T label F q x i = ∅ := by apply Finset.eq_empty_iff_forall_notMem.mpr intro j' hj' have h := (Finset.mem_filter.mp hj').2 have heq := repaired_gate_location T label F q x i i j' c a hf h.1 h.2 exact T.ne_of_adj h.1 (congrArg Prod.fst heq).symm have hmem : i ∈ targetCandidates T label F q x := by simp [targetCandidates, htargets, hgates] exact Or.inl ⟨hmem, rfl, htoff, hton⟩ · have hgoff := ((rowClause_eq_true_iff T label F q _ i).mp hf).2 j hij rw [recursiveChild_flip_same] at hgoff have hgon : F (gateIndex q) (recursiveChild x j (label i j)) = true := by cases hc : F (gateIndex q) (recursiveChild x j (label i j)) · exact False.elim (hg (hgoff.trans hc.symm)) · rfl have htargets : targetFailures F x i = ∅ := by apply Finset.eq_empty_iff_forall_notMem.mpr intro c' hc' have heq := repaired_target_location T label F q x i j (label i j) c' a hf (Finset.mem_filter.mp hc').2 exact T.ne_of_adj hij (congrArg Prod.fst heq) have hgates : gateFailures T label F q x i = {j} := by ext j' simp only [gateFailures, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] constructor · rintro ⟨hij', hon⟩ exact congrArg Prod.fst (repaired_gate_location T label F q x i j j' (label i j) a hf hij' hon) · rintro rfl exact ⟨hij, hgon⟩ have hmem : i ∈ gateCandidates T label F q x := by simp [gateCandidates, htargets, hgates] exact Or.inr ⟨hmem, hij, rfl, hgon, hgoff⟩
end Paper320
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import OAI.Combinatorics.Sensitivity.RecursiveFlips
namespace OAI
/-! Finite sets of changing raw coordinates inside an individual child. -/
noncomputable sectionopen scoped Classical
namespace Paper320
def childLift {J I : Type} (j : J) (A : Finset I) : Finset (J × I) := A.map ⟨fun a => (j, a), fun _ _ h => congrArg (fun p : J × I => p.2) h⟩
@[simp] theorem mem_childLift {J I : Type} (j : J) (A : Finset I) (p : J × I) : p ∈ childLift j A ↔ p.1 = j ∧ p.2 ∈ A := by rcases p with ⟨k, a⟩ unfold childLift rw [Finset.mem_map] constructor · rintro ⟨b, hb, hp⟩ change (j, b) = (k, a) at hp cases hp exact ⟨rfl, hb⟩ · rintro ⟨rfl, ha⟩ exact ⟨a, ha, rfl⟩
@[simp] theorem childLift_card {J I : Type} (j : J) (A : Finset I) : (childLift j A).card = A.card := Finset.card_map _
def childChanges {k r h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : Finset ((Fin k × Fin r) × I) := childLift (j, c) (Finset.univ.filter fun a => F q (flip (recursiveChild x j c) {a}) ≠ F q (recursiveChild x j c))
def childJointChanges {k r h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (q q' : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : Finset ((Fin k × Fin r) × I) := childLift (j, c) (Finset.univ.filter fun a => F q (flip (recursiveChild x j c) {a}) ≠ F q (recursiveChild x j c) ∧ F q' (flip (recursiveChild x j c) {a}) ≠ F q' (recursiveChild x j c))
@[simp] theorem childChanges_card {k r h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : (childChanges F q x j c).card = sensitivityAt (F q) (recursiveChild x j c) := by simp [childChanges, sensitivityAt]
@[simp] theorem childJointChanges_card {k r h : ℕ} {I : Type} [Fintype I] (F : Fin h → (I → Bool) → Bool) (q q' : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : (childJointChanges F q q' x j c).card = jointSensitivityAt (F q) (F q') (recursiveChild x j c) := by simp [childJointChanges, jointSensitivityAt]
theorem card_biUnion_le_mul {J I : Type} [DecidableEq I] (A : Finset J) (B : J → Finset I) (n : ℕ) (hn : ∀ j ∈ A, (B j).card ≤ n) : (A.biUnion B).card ≤ A.card * n := by calc (A.biUnion B).card ≤ ∑ j ∈ A, (B j).card := Finset.card_biUnion_le _ ≤ ∑ _j ∈ A, n := Finset.sum_le_sum hn _ = A.card * n := by simp
theorem rowClause_joint_flip_change {k r h : ℕ} {I : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) (q q' : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (i j : Fin k) (c : Fin r) (a : I) (hc : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i) (hc' : rowClause T label F q' (flip x {((j, c), a)}) i ≠ rowClause T label F q' x i) : (j = i ∧ F (Fin.last h) (flip (recursiveChild x j c) {a}) ≠ F (Fin.last h) (recursiveChild x j c)) ∨ (T.Adj i j ∧ c = label i j ∧ F (gateIndex q) (flip (recursiveChild x j c) {a}) ≠ F (gateIndex q) (recursiveChild x j c) ∧ F (gateIndex q') (flip (recursiveChild x j c) {a}) ≠ F (gateIndex q') (recursiveChild x j c)) := by rcases rowClause_flip_change T label F q x i j c a hc with ht | ⟨hij, hcl, hq⟩ · exact Or.inl ht · rcases rowClause_flip_change T label F q' x i j c a hc' with ht | hg · exact False.elim ((T.ne_of_adj hij) ht.1.symm) · exact Or.inr ⟨hij, hcl, hq, hg.2.2⟩
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121import OAI.Combinatorics.Sensitivity.RecursiveCandidates
namespace OAI
/-! The zero-side recurrence separates the unique possible gate-list sink. -/
noncomputable sectionopen scoped Classical
namespace Paper320
theorem recursive_sensitivity_zero_at {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (A : GoodLabeling T r) (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) (hx : recursiveFamily T A.label F q x = false) : sensitivityAt (recursiveFamily T A.label F q) x ≤ 16 * sideSensitivity F false + sideSensitivity F true + 3 * jointSensitivity F true := by let TC := targetCandidates T A.label F q x let GC := gateCandidates T A.label F q x let SC := gateSinks T A.label F q x let NC := GC \ SC let w := gateWitness T A.label F q x let U := TC.biUnion fun i => childChanges F (Fin.last h) x i (targetWitness F x hr i) let V := NC.biUnion fun i => childJointChanges F (gateIndex q) (Fin.last h) x (w i) (A.label i (w i)) let W := SC.biUnion fun i => childChanges F (gateIndex q) x (w i) (A.label i (w i)) have hsub : (Finset.univ.filter fun p => recursiveFamily T A.label F q (flip x {p}) ≠ recursiveFamily T A.label F q x) ⊆ U ∪ (V ∪ W) := by rintro ⟨⟨j, c⟩, a⟩ hp have hchange := (Finset.mem_filter.mp hp).2 have hon : recursiveFamily T A.label F q (flip x {((j, c), a)}) = true := by cases hy : recursiveFamily T A.label F q (flip x {((j, c), a)}) · exact False.elim (hchange (hy.trans hx.symm)) · rfl obtain ⟨i, hi⟩ := (recursiveFamily_eq_true_iff T A.label F q _).mp hon have hioff := (recursiveFamily_eq_false_iff T A.label F q x).mp hx i rcases rowClause_repair_cases T A.label F q x i j c a hioff hi with ⟨hit, hji, htoff, hton⟩ | ⟨hig, hij, rfl, hgon, hgoff⟩ · subst j have hc := targetWitness_unique T A.label F q x hr i hit c htoff apply Finset.mem_union_left apply Finset.mem_biUnion.mpr refine ⟨i, hit, ?_⟩ have hn : F (Fin.last h) (flip (recursiveChild x i c) {a}) ≠ F (Fin.last h) (recursiveChild x i c) := by simp [hton, htoff] simpa [childChanges, hc] using hn · have hj := gateWitness_unique T A.label F q x i hig j hij hgon apply Finset.mem_union_right by_cases hs : i ∈ SC · apply Finset.mem_union_right apply Finset.mem_biUnion.mpr refine ⟨i, hs, ?_⟩ have hn : F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠ F (gateIndex q) (recursiveChild x j (A.label i j)) := by simp [hgon, hgoff] simpa [childChanges, w, hj] using hn · have hwg := nonsink_gateWitness_mem T A.label F hF q x i hig hs have hjg : j ∈ gateCandidates T A.label F q x := by simpa [hj] using hwg have hton := (targetFailures_empty_iff F x j).mp (Finset.mem_filter.mp hjg).2.1 (A.label i j) have htoff := hF.rejects_of_le (gateIndex_lt_last q).le hgoff apply Finset.mem_union_left apply Finset.mem_biUnion.mpr refine ⟨i, Finset.mem_sdiff.mpr ⟨hig, hs⟩, ?_⟩ have hn : F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠ F (gateIndex q) (recursiveChild x j (A.label i j)) ∧ F (Fin.last h) (flip (recursiveChild x j (A.label i j)) {a}) ≠ F (Fin.last h) (recursiveChild x j (A.label i j)) := by simp [hgon, hgoff, hton, htoff] simpa [childJointChanges, w, hj] using hn have hU : U.card ≤ 16 * sideSensitivity F false := by calc U.card ≤ TC.card * sideSensitivity F false := card_biUnion_le_mul TC _ _ (fun i hi => by rw [childChanges_card] exact sensitivityAt_le_sideSensitivity F false _ _ (targetWitness_false T A.label F q x hr i hi)) _ ≤ 16 * sideSensitivity F false := Nat.mul_le_mul_right _ (Nat.le_of_lt (targetCandidates_card T A F hF q x hr)) have hV : V.card ≤ 3 * jointSensitivity F true := by calc V.card ≤ NC.card * jointSensitivity F true := card_biUnion_le_mul NC _ _ (fun i hi => by have hg := Finset.mem_sdiff.mp hi have hw := nonsink_gateWitness_mem T A.label F hF q x i hg.1 hg.2 have hgate := (gateWitness_spec T A.label F q x i hg.1).2 have htarget := (targetFailures_empty_iff F x _).mp (Finset.mem_filter.mp hw).2.1 (A.label i (w i)) rw [childJointChanges_card] exact jointSensitivityAt_le_jointSensitivity F true _ _ _ (gateIndex_lt_last q) hgate htarget) _ ≤ GC.card * jointSensitivity F true := Nat.mul_le_mul_right _ (Finset.card_le_card Finset.sdiff_subset) _ ≤ 3 * jointSensitivity F true := Nat.mul_le_mul_right _ (gateCandidates_card T A.label F hF q x) have hW : W.card ≤ sideSensitivity F true := by calc W.card ≤ SC.card * sideSensitivity F true := card_biUnion_le_mul SC _ _ (fun i hi => by rw [childChanges_card] exact sensitivityAt_le_sideSensitivity F true _ _ (gateWitness_spec T A.label F q x i (Finset.mem_filter.mp hi).1).2) _ ≤ 1 * sideSensitivity F true := Nat.mul_le_mul_right _ (gateSinks_card T A.label F q x) _ = _ := Nat.one_mul _ calc sensitivityAt (recursiveFamily T A.label F q) x ≤ (U ∪ (V ∪ W)).card := Finset.card_le_card hsub _ ≤ U.card + (V ∪ W).card := Finset.card_union_le _ _ _ ≤ U.card + (V.card + W.card) := Nat.add_le_add_left (Finset.card_union_le _ _) _ _ ≤ 16 * sideSensitivity F false + (3 * jointSensitivity F true + sideSensitivity F true) := Nat.add_le_add hU (Nat.add_le_add hV hW) _ = _ := by omega
theorem recursive_side_zero {k r h : ℕ} {I : Type} [Fintype I] (T : Tournament k) (A : GoodLabeling T r) (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) : sideSensitivity (recursiveFamily T A.label F) false ≤ 16 * sideSensitivity F false + sideSensitivity F true + 3 * jointSensitivity F true := by apply sideSensitivity_le exact fun q x hx => recursive_sensitivity_zero_at T A F hF hr q x hx
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import OAI.Combinatorics.Sensitivity.Basic
namespace OAI
/-! Coordinate equivalences preserve the two literal Boolean complexity measures. -/
noncomputable sectionopen scoped Classical
namespace Paper320
variable {I J : Type}
def reindex (e : I ≃ J) (f : (I → Bool) → Bool) : (J → Bool) → Bool := fun x => f (fun i => x (e i))
theorem flip_reindex (e : I ≃ J) (x : J → Bool) (B : Finset I) : (fun i => flip x (B.map e.toEmbedding) (e i)) = flip (fun i => x (e i)) B := by funext i simp [flip]
theorem flip_reindex_singleton (e : I ≃ J) (x : J → Bool) (i : I) : (fun a => flip x {e i} (e a)) = flip (fun a => x (e a)) {i} := by simpa using flip_reindex e x {i}
@[simp] theorem reindex_symm (e : I ≃ J) (f : (I → Bool) → Bool) : reindex e.symm (reindex e f) = f := by funext x simp [reindex]
section Finitevariable [Fintype I] [Fintype J]
theorem sensitivityAt_reindex (e : I ≃ J) (f : (I → Bool) → Bool) (x : J → Bool) : sensitivityAt (reindex e f) x = sensitivityAt f (fun i => x (e i)) := by have hs : (Finset.univ.filter fun j => reindex e f (flip x {j}) ≠ reindex e f x).map e.symm.toEmbedding = Finset.univ.filter (fun i => f (flip (fun a => x (e a)) {i}) ≠ f (fun a => x (e a))) := by ext i simp only [Finset.mem_map_equiv, Equiv.symm_symm, Finset.mem_filter, Finset.mem_univ, true_and] change f (fun a => flip x {e i} (e a)) ≠ f (fun a => x (e a)) ↔ _ rw [flip_reindex_singleton] simpa only [sensitivityAt, Finset.card_map] using congrArg Finset.card hs
theorem sensitivity_reindex (e : I ≃ J) (f : (I → Bool) → Bool) : sensitivity (reindex e f) = sensitivity f := by apply Nat.le_antisymm · apply sensitivity_le intro x rw [sensitivityAt_reindex] exact sensitivityAt_le_sensitivity f _ · apply sensitivity_le intro x have h := sensitivityAt_le_sensitivity (reindex e f) (fun j => x (e.symm j)) rw [sensitivityAt_reindex] at h simpa only [Equiv.symm_apply_apply] using h
theorem blockSensitivityAt_le_reindex (e : I ≃ J) (f : (I → Bool) → Bool) (x : J → Bool) : blockSensitivityAt f (fun i => x (e i)) ≤ blockSensitivityAt (reindex e f) x := by apply blockSensitivityAt_le intro blocks hd hb have h := le_blockSensitivityAt_of_family (reindex e f) x (fun B : blocks => B.val.map e.toEmbedding) (fun B => (hb B.val B.property).1.map (f := e.toEmbedding)) (by intro A B hAB apply (Finset.disjoint_map e.toEmbedding).mpr exact hd A.val A.property B.val B.property (fun h => hAB (Subtype.ext h))) (by intro B change f (fun i => flip x (B.val.map e.toEmbedding) (e i)) ≠ _ rw [flip_reindex] exact (hb B.val B.property).2) simpa only [Fintype.card_coe] using h
theorem blockSensitivityAt_reindex (e : I ≃ J) (f : (I → Bool) → Bool) (x : J → Bool) : blockSensitivityAt (reindex e f) x = blockSensitivityAt f (fun i => x (e i)) := by apply Nat.le_antisymm · have h := blockSensitivityAt_le_reindex e.symm (reindex e f) (fun i => x (e i)) simpa only [Equiv.apply_symm_apply, reindex_symm] using h · exact blockSensitivityAt_le_reindex e f x
theorem blockSensitivity_reindex (e : I ≃ J) (f : (I → Bool) → Bool) : blockSensitivity (reindex e f) = blockSensitivity f := by apply Nat.le_antisymm · apply blockSensitivity_le intro x rw [blockSensitivityAt_reindex] exact blockSensitivityAt_le_blockSensitivity f _ · apply blockSensitivity_le intro x have h := blockSensitivityAt_le_blockSensitivity (reindex e f) (fun j => x (e.symm j)) rw [blockSensitivityAt_reindex] at h simpa only [Equiv.symm_apply_apply] using h
end Finiteend Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import Mathlib
namespace OAI
/-! Scalar bounds for the two coupled sensitivity profiles. -/
namespace Paper320
theorem geometric_error_le {d n : ℕ} (hn : n ≤ d) {ε L : ℝ} (hε : 0 ≤ ε) (hL : 0 ≤ L) (hbudget : ε * 3 ^ (d + 1) ≤ 2) : (3 / 2 : ℝ) * ε * L * (3 ^ n - 1) ≤ L := by have hp : (3 : ℝ) ^ (n + 1) ≤ 3 ^ (d + 1) := pow_le_pow_right₀ (by norm_num) (Nat.succ_le_succ hn) have hb := (mul_le_mul_of_nonneg_left hp hε).trans hbudget have hm := mul_le_mul_of_nonneg_right hb hL rw [pow_succ] at hm nlinarith [mul_nonneg hε hL]
theorem coupled_profiles_bound (d : ℕ) (u v : ℕ → ℝ) (ε L : ℝ) (hε : 0 ≤ ε) (hL : 0 ≤ L) (hbudget : ε * 3 ^ (d + 1) ≤ 2) (hu0 : u 0 ≤ L) (hv0 : v 0 ≤ 0) (hu : ∀ n < d, u (n + 1) ≤ (1 + ε) * u n + 3 * v n) (hv : ∀ n < d, v (n + 1) ≤ ε * u n + 3 * v n) : ∀ n ≤ d, u n ≤ 2 * L ∧ v n ≤ ε * L * (3 ^ n - 1) := by have strong : ∀ n ≤ d, u n ≤ L + (3 / 2 : ℝ) * ε * L * (3 ^ n - 1) ∧ v n ≤ ε * L * (3 ^ n - 1) := by intro n induction n with | zero => intro _ simpa using And.intro hu0 hv0 | succ n ih => intro hn have hnd : n ≤ d := by omega obtain ⟨hun, hvn⟩ := ih hnd have he := geometric_error_le hnd hε hL hbudget have hun' : u n ≤ 2 * L := by linarith have heu := mul_le_mul_of_nonneg_left hun' hε have hnu := hu n (by omega) have hnv := hv n (by omega) constructor · rw [pow_succ] nlinarith [mul_nonneg hε hL] · rw [pow_succ] nlinarith intro n hn obtain ⟨hun, hvn⟩ := strong n hn have he := geometric_error_le hn hε hL hbudget exact ⟨by linarith, hvn⟩
end Paper320
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import OAI.Combinatorics.Sensitivity.ConstructedSeedimport OAI.Combinatorics.Sensitivity.PowerAmplificationimport OAI.Combinatorics.Sensitivity.SeparationArithmetic
namespace OAI
/-! The depth-nine seed gives a fixed exponent and explicit ratios. -/
noncomputable sectionopen scoped Classical
namespace Paper320
theorem constructed_power_family : ∃ α : ℝ, 2 < α ∧ ∃ (n : ℕ → ℕ) (F : ∀ m : ℕ, (Fin (n m) → Bool) → Bool), (∀ m : ℕ, 0 < n m ∧ F m (fun _ => false) = false ∧ (∃ x y, F m x ≠ F m y) ∧ (sensitivity (F m) : ℝ) ^ α ≤ (blockSensitivityAt (F m) (fun _ => false) : ℝ) ∧ ((128 : ℝ) / 121) ^ m ≤ (blockSensitivity (F m) : ℝ) / (sensitivity (F m) : ℝ) ^ 2) ∧ Filter.Tendsto (fun m : ℕ => (blockSensitivityAt (F m) (fun _ => false) : ℝ)) Filter.atTop Filter.atTop := by let M : ℕ := 9 ^ 10 have hM : 0 < M := by dsimp [M]; positivity obtain ⟨f, _, hf, _, hs, hb⟩ := exists_constructed_seed 9 M (by norm_num) (by rfl) change sensitivity f ≤ 22 * M ^ 10 at hs obtain ⟨hA, hB⟩ := depth_nine_seed_gap M hM obtain ⟨hα, hall, hlim⟩ := power_amplification f hf (22 * M ^ 10) (M ^ 2 * (2 * M ^ 2 + 1) ^ 9) hs hb hA hB refine ⟨_, hα, _, (fun m => iterateFin f m), ?_, hlim⟩ intro m obtain ⟨hn, hzero, hnc, hpow, hratio⟩ := hall m refine ⟨hn, hzero, hnc, hpow, ?_⟩ apply le_trans _ hratio apply pow_le_pow_left₀ (by norm_num) have hMr : (0 : ℝ) < M := by exact_mod_cast hM simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one] using depth_nine_seed_ratio hMr
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import OAI.Combinatorics.Sensitivity.SeedAmplification
namespace OAI
/-! Quantitative, unbounded quadratic, and fixed-power separations of sensitivity. -/
noncomputable sectionopen scoped Classical
namespace Paper320
theorem quantitative_separation (d : ℕ) (hd : 1 ≤ d) : ∃ (n : ℕ) (f : (Fin n → Bool) → Bool), 0 < n ∧ f (fun _ => false) = false ∧ (∃ x y : Fin n → Bool, f x ≠ f y) ∧ (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤ (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by let M : ℕ := 9 ^ (d + 1) have hM : 0 < M := by dsimp [M]; positivity obtain ⟨f, hn, hf, hnc, hs, hb⟩ := exists_constructed_seed d M hd (by rfl) exact ⟨_, f, hn, hf, hnc, quantitative_ratio_of_bounds f d M hM hnc hs hb⟩
theorem unbounded_quadratic_separation (C : ℝ) (hC : 0 < C) : ∃ (n : ℕ) (f : (Fin n → Bool) → Bool), 0 < n ∧ f (fun _ => false) = false ∧ (∃ x y : Fin n → Bool, f x ≠ f y) ∧ C * (sensitivity f : ℝ) ^ 2 < (blockSensitivity f : ℝ) := by obtain ⟨d, hd, hlarge⟩ := ((Filter.eventually_ge_atTop (1 : ℕ)).and (quantitative_ratio_tendsto.eventually_gt_atTop (max C 0))).exists rw [max_eq_left hC.le] at hlarge obtain ⟨n, f, hn, hf, hnc, hratio⟩ := quantitative_separation d hd have hs : (0 : ℝ) < sensitivity f := by exact_mod_cast sensitivity_pos_of_nonconstant f hnc exact ⟨n, f, hn, hf, hnc, (lt_div_iff₀ (pow_pos hs 2)).mp (hlarge.trans_le hratio)⟩
theorem fixed_power_separation : ∃ α : ℝ, 2 < α ∧ ∃ (n : ℕ → ℕ) (F : ∀ m : ℕ, (Fin (n m) → Bool) → Bool), (∀ m : ℕ, 1 ≤ m → 0 < n m ∧ F m (fun _ => false) = false ∧ (∃ x y : Fin (n m) → Bool, F m x ≠ F m y) ∧ (sensitivity (F m) : ℝ) ^ α ≤ (blockSensitivityAt (F m) (fun _ => false) : ℝ)) ∧ Filter.Tendsto (fun m : ℕ => (blockSensitivityAt (F m) (fun _ => false) : ℝ)) Filter.atTop Filter.atTop := by obtain ⟨α, hα, n, F, hall, hlim⟩ := constructed_power_family refine ⟨α, hα, n, F, ?_, hlim⟩ intro m _ obtain ⟨hn, hf, hnc, hpow, _⟩ := hall m exact ⟨hn, hf, hnc, hpow⟩
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116import OAI.Combinatorics.Sensitivity.Basic
namespace OAI
/-! The exact final ratio, the depth-nine seed gap, and exponential divergence. -/
noncomputable sectionopen Filteropen scoped Topology
namespace Paper320
theorem seed_ratio_identity (d : ℕ) {L M k : ℝ} (hL : L ≠ 0) (hM : M ≠ 0) : (M ^ 2 * k ^ d) / (2 * L * M ^ (d + 1)) ^ 2 = (k / M ^ 2) ^ d / (4 * L ^ 2) := by have hp : (M ^ 2) ^ d = (M ^ d) ^ 2 := by rw [← pow_mul, ← pow_mul, Nat.mul_comm 2 d] rw [div_pow, hp, pow_succ] field_simp ring
theorem seed_ratio_lower (d : ℕ) {M : ℝ} (hM : 0 < M) : (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤ (M ^ 2 * (2 * M ^ 2 + 1) ^ d) / (2 * ((d : ℝ) + 2) * M ^ (d + 1)) ^ 2 := by rw [seed_ratio_identity d (by positivity) (ne_of_gt hM)] have hk : 2 ≤ (2 * M ^ 2 + 1) / M ^ 2 := by apply (le_div_iff₀ (pow_pos hM 2)).mpr linarith exact div_le_div_of_nonneg_right (pow_le_pow_left₀ (by norm_num) hk d) (by positivity)
theorem ratio_of_bounds {I : Type} [Fintype I] (f : (I → Bool) → Bool) (s b : ℝ) (hpos : 0 < (sensitivity f : ℝ)) (hs : (sensitivity f : ℝ) ≤ s) (hb : b ≤ (blockSensitivityAt f (fun _ => false) : ℝ)) (hb0 : 0 ≤ b) : b / s ^ 2 ≤ (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by have hsp : 0 < s := lt_of_lt_of_le hpos hs apply (le_div_iff₀ (pow_pos hpos 2)).mpr calc _ ≤ (b / s ^ 2) * s ^ 2 := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hpos.le hs 2) (div_nonneg hb0 (sq_nonneg s)) _ = b := div_mul_cancel₀ _ (ne_of_gt (pow_pos hsp 2)) _ ≤ (blockSensitivityAt f (fun _ => false) : ℝ) := hb _ ≤ (blockSensitivity f : ℝ) := by exact_mod_cast blockSensitivityAt_le_blockSensitivity f (fun _ => false)
theorem quantitative_ratio_of_bounds {I : Type} [Fintype I] (f : (I → Bool) → Bool) (d M : ℕ) (hM : 0 < M) (hnc : ∃ x y, f x ≠ f y) (hs : sensitivity f ≤ 2 * (d + 2) * M ^ (d + 1)) (hb : M ^ 2 * (2 * M ^ 2 + 1) ^ d ≤ blockSensitivityAt f (fun _ => false)) : (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤ (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by have hMr : 0 < (M : ℝ) := by exact_mod_cast hM apply (seed_ratio_lower d hMr).trans apply ratio_of_bounds · exact_mod_cast sensitivity_pos_of_nonconstant f hnc · exact_mod_cast hs · exact_mod_cast hb · positivity
theorem depth_nine_ratio : (2 : ℝ) ^ 9 / (4 * ((9 : ℝ) + 2) ^ 2) = 128 / 121 := by norm_num
theorem depth_nine_ratio_gt_one : (1 : ℝ) < 128 / 121 := by norm_num
theorem depth_nine_seed_ratio {M : ℝ} (hM : 0 < M) : (128 : ℝ) / 121 ≤ M ^ 2 * (2 * M ^ 2 + 1) ^ 9 / (22 * M ^ 10) ^ 2 := by have h := seed_ratio_lower 9 hM norm_num at h ⊢ exact h
theorem depth_nine_seed_gap (M : ℕ) (hM : 0 < M) : 1 < 22 * M ^ 10 ∧ (22 * M ^ 10) ^ 2 < M ^ 2 * (2 * M ^ 2 + 1) ^ 9 := by constructor · have hp := pow_pos hM 10 omega · have hp := pow_pos hM 20 have hmono : M ^ 2 * (2 * M ^ 2) ^ 9 ≤ M ^ 2 * (2 * M ^ 2 + 1) ^ 9 := by gcongr omega calc _ = 484 * M ^ 20 := by ring _ < 512 * M ^ 20 := by omega _ = M ^ 2 * (2 * M ^ 2) ^ 9 := by ring _ ≤ _ := hmono
theorem quantitative_ratio_tendsto : Tendsto (fun d : ℕ => (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2)) atTop atTop := by have hb := (tendsto_pow_const_div_const_pow_of_one_lt 2 (by norm_num : (1 : ℝ) < 2)).comp (tendsto_add_atTop_nat 2) have hz : Tendsto (fun d : ℕ => 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d) atTop (𝓝 0) := by have h := hb.const_mul (16 : ℝ) convert h using 1 · funext d simp only [Function.comp_apply] push_cast rw [pow_add] norm_num ring · simp have hr : Tendsto (fun d : ℕ => 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d) atTop (𝓝[>] (0 : ℝ)) := by apply tendsto_nhdsWithin_iff.mpr refine ⟨hz, Filter.Eventually.of_forall ?_⟩ intro d change 0 < 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d positivity simpa only [Function.comp_def, inv_div] using tendsto_inv_nhdsGT_zero.comp hr
end Paper320
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768import Mathlib.Combinatorics.Digraph.Basicimport Mathlib.Data.Finset.Cardimport Mathlib.Data.Finset.Prodimport Mathlib.Data.Finset.Powersetimport Mathlib.Data.Fintype.BigOperators
namespace OAI
/-! Finite tournaments and the target-constant labeling condition. -/
noncomputable sectionopen scoped Classical
namespace Paper320
structure Tournament (k : ℕ) extends Digraph (Fin k) where loopless : ∀ i, ¬ Adj i i edge_compl : ∀ {i j}, i ≠ j → (Adj i j ↔ ¬ Adj j i)
structure RegularTournament (M : ℕ) extends Tournament (2 * M^2 + 1) where outdegree : ∀ i, (Finset.univ.filter (Adj i)).card = M^2
structure GoodLabeling {k : ℕ} (T : Tournament k) (r : ℕ) where label : Fin k → Fin k → Fin r good : ∀ I : Finset (Fin k), I.card = 16 → ∀ m : Fin k → Fin r, ∃ i ∈ I, ∃ j ∈ I, T.Adj i j ∧ label i j ≠ m j
namespace Tournamentvariable {k : ℕ} (T : Tournament k)
theorem ne_of_adj {i j : Fin k} (h : T.Adj i j) : i ≠ j := by rintro rfl exact T.loopless i h
theorem not_adj_reverse {i j : Fin k} (h : T.Adj i j) : ¬ T.Adj j i := (T.edge_compl (T.ne_of_adj h)).mp h
theorem adj_or_reverse {i j : Fin k} (h : i ≠ j) : T.Adj i j ∨ T.Adj j i := by by_cases hh : T.Adj j i · exact Or.inr hh · exact Or.inl ((T.edge_compl h).mpr hh)
theorem internal_sink_unique {I : Finset (Fin k)} {i j : Fin k} (hi : i ∈ I) (hj : j ∈ I) (hsi : ∀ v ∈ I, ¬ T.Adj i v) (hsj : ∀ v ∈ I, ¬ T.Adj j v) : i = j := by by_contra h rcases T.adj_or_reverse h with hh | hh · exact hsi j hj hh · exact hsj i hi hh
end Tournament
namespace GoodLabelingvariable {k r : ℕ} {T : Tournament k} (A : GoodLabeling T r)
theorem good_implies_card_lt_sixteen (I : Finset (Fin k)) (m : Fin k → Fin r) (h : ∀ i ∈ I, ∀ j ∈ I, T.Adj i j → A.label i j = m j) : I.card < 16 := by by_contra hn obtain ⟨J, hJI, hJ⟩ := Finset.exists_subset_card_eq (show 16 ≤ I.card by omega) obtain ⟨i, hi, j, hj, hij, hne⟩ := A.good J hJ m exact hne (h i (hJI hi) j (hJI hj) hij)
end GoodLabelingend Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import OAI.Combinatorics.Sensitivity.Tournamentimport Mathlib.Algebra.BigOperators.Group.Finset.Basicimport Mathlib.Algebra.Order.BigOperators.Group.Finsetimport Mathlib.Tactic.Linarith
namespace OAI
/-! The exact internal edge count and the small gate-candidate bound. -/
noncomputable sectionopen scoped Classical BigOperators
namespace Paper320.Tournamentvariable {k : ℕ} (T : Tournament k)
def internalEdges (I : Finset (Fin k)) : Finset (Fin k × Fin k) := (I ×ˢ I).filter fun p => T.Adj p.1 p.2
theorem card_internalEdges (I : Finset (Fin k)) : (T.internalEdges I).card = I.card.choose 2 := by let U := T.internalEdges I let V := (I ×ˢ I).filter fun p => T.Adj p.2 p.1 have hd : Disjoint U V := by apply Finset.disjoint_left.mpr intro p hp hq exact T.not_adj_reverse (Finset.mem_filter.mp hp).2 (Finset.mem_filter.mp hq).2 have hu : U.disjUnion V hd = I.offDiag := by ext ⟨i,j⟩ simp only [Finset.mem_disjUnion, U, V, internalEdges, Finset.mem_filter, Finset.mem_product, Finset.mem_offDiag] constructor · rintro (⟨⟨hi,hj⟩,h⟩ | ⟨⟨hi,hj⟩,h⟩) · exact ⟨hi,hj,T.ne_of_adj h⟩ · exact ⟨hi,hj,(T.ne_of_adj h).symm⟩ · rintro ⟨hi,hj,hne⟩ exact (T.adj_or_reverse hne).imp (fun h => ⟨⟨hi,hj⟩,h⟩) (fun h => ⟨⟨hi,hj⟩,h⟩) have hs : U.card = V.card := Finset.card_equiv (Equiv.prodComm (Fin k) (Fin k)) (by intro p simp only [U,V,internalEdges,Finset.mem_filter,Finset.mem_product,Equiv.prodComm_apply] tauto) have hc := congrArg Finset.card hu rw [Finset.card_disjUnion, ← hs, Finset.offDiag_card] at hc rw [Nat.choose_two_right, Nat.mul_sub_one] change U.card = _ omega
theorem sum_outdegree_eq (I : Finset (Fin k)) : ∑ i ∈ I, (I.filter (T.Adj i)).card = (T.internalEdges I).card := by simp only [internalEdges, Finset.card_eq_sum_ones, Finset.sum_filter, Finset.sum_product]
theorem card_le_three_of_outdegree_le_one (I : Finset (Fin k)) (h : ∀ i ∈ I, (I.filter (T.Adj i)).card ≤ 1) : I.card ≤ 3 := by have hsum := Finset.sum_le_sum h have hc : I.card.choose 2 ≤ I.card := by rw [← T.card_internalEdges, ← T.sum_outdegree_eq] simpa only [Finset.sum_const_nat, mul_one] using hsum have hdouble : I.card * (I.card - 1) ≤ 2 * I.card + 1 := by rw [Nat.choose_two_right] at hc omega by_contra hn have h4 : 4 ≤ I.card := by omega have ht : I.card - 1 + 1 = I.card := by omega nlinarith
end Paper320.Tournament
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import OAI.Combinatorics.Sensitivity.Tournamentimport Mathlib.Algebra.Group.Fin.Basicimport Mathlib.Algebra.Group.Units.Equivimport Mathlib.Order.Interval.Finset.Fin
namespace OAI
/-! The literal regular tournament on an odd cyclic set. -/
noncomputable sectionopen scoped Classical
namespace Paper320
def cyclicTournament (a : ℕ) : Tournament (2*a+1) where Adj i j := 0 < (j-i).val ∧ (j-i).val ≤ a loopless i := by simp edge_compl := by intro i j hij have hδ : j-i ≠ 0 := sub_ne_zero.mpr hij.symm have hp : 0 < (j-i).val := Nat.pos_of_ne_zero (Fin.val_ne_zero_iff.mpr hδ) have hb := (j-i).isLt have hn : (i-j).val = 2*a+1-(j-i).val := by rw [← neg_sub j i, Fin.val_neg, ite_eq_right hδ] change (0 < (j-i).val ∧ (j-i).val ≤ a) ↔ ¬ (0 < (i-j).val ∧ (i-j).val ≤ a) rw [hn] omega
theorem cyclicTournament_outdegree (a : ℕ) (i : Fin (2*a+1)) : (Finset.univ.filter ((cyclicTournament a).Adj i)).card = a := by let z : Fin (2*a+1) := 0 let b : Fin (2*a+1) := ⟨a, by omega⟩ have he : (Finset.Ioc z b).card = (Finset.univ.filter ((cyclicTournament a).Adj i)).card := Finset.card_equiv (Equiv.addLeft i) (by intro x simp only [Finset.mem_Ioc, Finset.mem_filter, Finset.mem_univ, true_and] change (0 < x.val ∧ x.val ≤ a) ↔ (0 < ((i+x)-i).val ∧ ((i+x)-i).val ≤ a) rw [add_sub_cancel_left]) rw [← he, Fin.card_Ioc] change a - 0 = a exact Nat.sub_zero a
def regularCyclicTournament (M : ℕ) : RegularTournament M where toTournament := cyclicTournament (M^2) outdegree := cyclicTournament_outdegree (M^2)
end Paper320
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161import OAI.Combinatorics.Sensitivity.Recursive
namespace OAI
/-! An indexed tower of the literal recursive construction and its common blocks. -/
noncomputable sectionopen scoped Classical
namespace Paper320
def TowerCoordinates (k r : ℕ) (I : Type) : ℕ → Type | 0 => I | n + 1 => (Fin k × Fin r) × TowerCoordinates k r I n
instance towerCoordinatesFintype (k r : ℕ) (I : Type) [Fintype I] : (n : ℕ) → Fintype (TowerCoordinates k r I n) | 0 => inferInstanceAs (Fintype I) | n + 1 => by letI := towerCoordinatesFintype k r I n exact inferInstanceAs (Fintype ((Fin k × Fin r) × TowerCoordinates k r I n))
def TowerBlockIndex (k : ℕ) (K : Type) : ℕ → Type | 0 => K | n + 1 => Fin k × TowerBlockIndex k K n
instance towerBlockIndexFintype (k : ℕ) (K : Type) [Fintype K] : (n : ℕ) → Fintype (TowerBlockIndex k K n) | 0 => inferInstanceAs (Fintype K) | n + 1 => by letI := towerBlockIndexFintype k K n exact inferInstanceAs (Fintype (Fin k × TowerBlockIndex k K n))
def towerFamily {k r : ℕ} {I : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) : (n h : ℕ) → Fin h → (TowerCoordinates k r I n → Bool) → Bool | 0, h => base h | n + 1, h => recursiveFamily T label (towerFamily T label base n (h + 1))
def towerBlocks {k r : ℕ} {I K : Type} (blocks : K → Finset I) : (n : ℕ) → TowerBlockIndex k K n → Finset (TowerCoordinates k r I n) | 0, b => blocks b | n + 1, b => rowLift b.1 (towerBlocks blocks n b.2)
/-- Extend a prescribed initial family to unused index counts without adding assumptions. -/def baseExtension {I : Type} (D : ℕ) (F : Fin D → (I → Bool) → Bool) (h : ℕ) (q : Fin h) (x : I → Bool) : Bool := if he : h = D then F (Fin.cast he q) x else false
@[simp] theorem baseExtension_same {I : Type} (D : ℕ) (F : Fin D → (I → Bool) → Bool) : baseExtension D F D = F := by funext q x simp [baseExtension]
theorem tower_coordinates_card {k r : ℕ} {I : Type} [Fintype I] (n : ℕ) : Fintype.card (TowerCoordinates k r I n) = (k * r) ^ n * Fintype.card I := by induction n with | zero => change Fintype.card I = (k * r) ^ 0 * Fintype.card I simp | succ n ih => change Fintype.card ((Fin k × Fin r) × TowerCoordinates k r I n) = _ simp only [Fintype.card_prod, Fintype.card_fin, ih, pow_succ] ring
theorem tower_block_index_card {k : ℕ} {K : Type} [Fintype K] (n : ℕ) : Fintype.card (TowerBlockIndex k K n) = k ^ n * Fintype.card K := by induction n with | zero => change Fintype.card K = k ^ 0 * Fintype.card K simp | succ n ih => change Fintype.card (Fin k × TowerBlockIndex k K n) = _ simp only [Fintype.card_prod, Fintype.card_fin, ih, pow_succ] ring
theorem towerBlocks_card {k r : ℕ} {I K : Type} (blocks : K → Finset I) (L : ℕ) (hL : ∀ b, (blocks b).card = L) (n : ℕ) (b : TowerBlockIndex k K n) : (towerBlocks (r := r) blocks n b).card = r ^ n * L := by induction n with | zero => change (blocks b).card = r ^ 0 * L simpa only [pow_zero, one_mul] using hL b | succ n ih => change (rowLift b.1 (towerBlocks blocks n b.2)).card = _ rw [rowLift_card, ih] ring
theorem towerBlocks_nonempty {k r : ℕ} {I K : Type} (blocks : K → Finset I) (hr : 0 < r) (hne : ∀ b, (blocks b).Nonempty) (n : ℕ) (b : TowerBlockIndex k K n) : (towerBlocks (r := r) blocks n b).Nonempty := by induction n with | zero => exact hne b | succ n ih => exact rowLift_nonempty b.1 _ hr (ih b.2)
theorem towerBlocks_pairwise {k r : ℕ} {I K : Type} (blocks : K → Finset I) (hd : Pairwise fun a b => Disjoint (blocks a) (blocks b)) (n : ℕ) : Pairwise fun a b => Disjoint (towerBlocks (k := k) (r := r) blocks n a) (towerBlocks blocks n b) := by induction n with | zero => exact hd | succ n ih => exact rowLift_family_disjoint (towerBlocks blocks n) ih
theorem towerFamily_nested {k r : ℕ} {I : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (n h : ℕ) (hbase : NestedFamily (base (h + n))) : NestedFamily (towerFamily T label base n h) := by induction n generalizing h with | zero => change NestedFamily (base h) simpa only [Nat.add_zero] using hbase | succ n ih => apply recursiveFamily_nested apply ih have he : (h + 1) + n = h + (n + 1) := by omega rw [he] exact hbase
theorem towerFamily_zero {k r : ℕ} {I : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (hr : 0 < r) (n h : ℕ) (hbase : ∀ q, base (h + n) q (fun _ => false) = false) : ∀ q, towerFamily T label base n h q (fun _ => false) = false := by induction n generalizing h with | zero => change ∀ q, base h q (fun _ => false) = false simpa only [Nat.add_zero] using hbase | succ n ih => apply recursiveFamily_zero T label _ hr apply ih have he : (h + 1) + n = h + (n + 1) := by omega rw [he] exact hbase
theorem towerFamily_blocks {k r : ℕ} {I K : Type} (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (blocks : K → Finset I) (hr : 0 < r) (n h : ℕ) (hzero : ∀ q, base (h + n) q (fun _ => false) = false) (hblocks : ∀ b q, base (h + n) q (flip (fun _ => false) (blocks b)) = true) : ∀ b q, towerFamily T label base n h q (flip (fun _ => false) (towerBlocks blocks n b)) = true := by induction n generalizing h with | zero => change ∀ b q, base h q (flip (fun _ => false) (blocks b)) = true simpa only [Nat.add_zero] using hblocks | succ n ih => intro b q have he : (h + 1) + n = h + (n + 1) := by omega have hz : ∀ q, base ((h + 1) + n) q (fun _ => false) = false := by rw [he] exact hzero have hb : ∀ b q, base ((h + 1) + n) q (flip (fun _ => false) (blocks b)) = true := by rw [he] exact hblocks exact recursiveFamily_rowLift T label _ (towerFamily_zero T label base hr n (h + 1) hz) (towerBlocks blocks n b.2) (ih (h + 1) hz hb b.2) b.1 q
end Paper320
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import OAI.Combinatorics.Sensitivity.Towerimport OAI.Combinatorics.Sensitivity.RecursiveChildren
namespace OAI
/-! The fixed-initial-height profiles and their exact four recurrences. -/
noncomputable sectionopen scoped Classical
namespace Paper320
def towerSide {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (D n : ℕ) (b : Bool) : ℕ := sideSensitivity (towerFamily T label base n (D - n)) b
def towerJoint {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (D n : ℕ) (b : Bool) : ℕ := jointSensitivity (towerFamily T label base n (D - n)) b
@[simp] theorem towerSide_zero {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (D : ℕ) (b : Bool) : towerSide T label base D 0 b = sideSensitivity (base D) b := by rfl
@[simp] theorem towerJoint_zero {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (D : ℕ) (b : Bool) : towerJoint T label base D 0 b = jointSensitivity (base D) b := by rfl
theorem tower_four_recurrences {M r : ℕ} {I : Type} [Fintype I] (T : RegularTournament M) (A : GoodLabeling T.toTournament r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) (D n : ℕ) (hn : n < D) (hr : 0 < r) (hbase : NestedFamily (base D)) : (towerSide T.toTournament A.label base D (n + 1) true ≤ M ^ 2 * towerSide T.toTournament A.label base D n false + r * towerSide T.toTournament A.label base D n true) ∧ (towerJoint T.toTournament A.label base D (n + 1) true ≤ M ^ 2 * towerJoint T.toTournament A.label base D n false + r * towerSide T.toTournament A.label base D n true) ∧ (towerSide T.toTournament A.label base D (n + 1) false ≤ 16 * towerSide T.toTournament A.label base D n false + towerSide T.toTournament A.label base D n true + 3 * towerJoint T.toTournament A.label base D n true) ∧ (towerJoint T.toTournament A.label base D (n + 1) false ≤ 16 * towerSide T.toTournament A.label base D n false + 3 * towerJoint T.toTournament A.label base D n true) := by have he : (D - (n + 1) + 1) + n = D := by omega have hf : NestedFamily (towerFamily T.toTournament A.label base n (D - (n + 1) + 1)) := by apply towerFamily_nested rwa [he] have H := recursive_four_recurrences T A (towerFamily T.toTournament A.label base n (D - (n + 1) + 1)) hf hr dsimp only at H change (sideSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) true ≤ _) ∧ (jointSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) true ≤ _) ∧ (sideSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) false ≤ _) ∧ (jointSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) false ≤ _) at H have hcount : D - (n + 1) + 1 = D - n := by omega rw [hcount] at H exact H
theorem towerBlocks_family_card {k r : ℕ} {I K : Type} [Fintype K] (blocks : K → Finset I) (hr : 0 < r) (hne : ∀ b, (blocks b).Nonempty) (hd : Pairwise fun a b => Disjoint (blocks a) (blocks b)) (n : ℕ) : (Finset.univ.image (towerBlocks (k := k) (r := r) blocks n)).card = k ^ n * Fintype.card K := by have hinj : Function.Injective (towerBlocks (k := k) (r := r) blocks n) := by intro a b hab by_contra hneab obtain ⟨i, hi⟩ := towerBlocks_nonempty blocks hr hne n a exact Finset.disjoint_left.mp (towerBlocks_pairwise blocks hd n hneab) hi (by simpa [← hab] using hi) rw [Finset.card_image_of_injective _ hinj, Finset.card_univ, tower_block_index_card]
end Paper320
end
end OAI12345678910111213141516171819202122232425262728293031import OAI.Combinatorics.Sensitivity.FixedCoordinatesimport Mathlib.Probability.Distributions.Uniform
namespace OAI
/-! The exact probability of prescribed values under uniform independent labels. -/
noncomputable sectionopen scoped Classical
namespace Paper320
theorem uniform_fixedCoordinates_probability {α β : Type} [Fintype α] [Fintype β] [DecidableEq α] [Nonempty β] (s : Finset α) (v : α → β) : ((PMF.uniformOfFintype (α → β)).toOuterMeasure {f | ∀ i ∈ s, f i = v i}).toReal = 1 / (Fintype.card β : ℝ)^s.card := by rw [PMF.toOuterMeasure_uniformOfFintype_apply] simp only [ENNReal.toReal_div, ENNReal.toReal_natCast] rw [Fintype.card_subtype] simp only [Set.mem_ofPred_eq] rw [card_fixedCoordinates, Fintype.card_fun] simp only [Nat.cast_pow] have hp : (Fintype.card β : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero (α := β) rw [div_eq_div_iff (pow_ne_zero _ hp) (pow_ne_zero _ hp), one_mul, ← pow_add, Nat.sub_add_cancel (Finset.card_le_univ s)]
end Paper320
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import Mathlibimport OAI.Combinatorics.SharpRamsey.Bounds.Lower
namespace OAI
/-! Two-sided Ramsey bounds and the logarithmic limit from a prime-field construction. -/
sectionnamespace SharpLogRamsey
theorem mainLimit_of_mainBounds (s : ℕ) (h : MainBounds s) : MainLimit s := by obtain ⟨C,hC,h⟩ := h have hlog : Filter.Tendsto (fun t : ℕ => Real.log (t:ℝ)) Filter.atTop Filter.atTop := Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop have hloglog : Filter.Tendsto (fun t : ℕ => Real.log (Real.log (t:ℝ))) Filter.atTop Filter.atTop := Real.tendsto_log_atTop.comp hlog apply Metric.tendsto_atTop.mpr intro ε hε obtain ⟨t₀,ht₀⟩ := h (ε/2) (by positivity) obtain ⟨t₁,ht₁⟩ := Filter.eventually_atTop.mp (hloglog.eventually (Filter.eventually_gt_atTop (max 0 (2*|Real.log C|/ε)))) refine ⟨max (max t₀ t₁) 2, fun t ht => ?_⟩ have htl : t₀≤t := (le_max_left t₀ t₁).trans ((le_max_left _ _).trans ht) have htll : t₁≤t := (le_max_right t₀ t₁).trans ((le_max_left _ _).trans ht) have ht2 : 2≤t := (le_max_right _ _).trans ht have htp : (0:ℝ)<t := by exact_mod_cast (by omega : 0<t) have hlt : 0<Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1<t)) have hll0 : 0<Real.log (Real.log (t:ℝ)) := (le_max_left _ _).trans_lt (ht₁ t htll) have hllbig : 2*|Real.log C|/ε<Real.log (Real.log (t:ℝ)) := (le_max_right _ _).trans_lt (ht₁ t htll) obtain ⟨hl,hu⟩ := ht₀ t htl have hp : 0<(t:ℝ)^(s-1)/Real.rpow (Real.log (t:ℝ)) ((s-2:ℕ)+(ε/2)) := div_pos (pow_pos htp _) (Real.rpow_pos_of_pos hlt _) have hr : 0<(ramsey s t:ℝ) := hp.trans_le hl have hl' := Real.log_le_log hp hl change Real.log ((t:ℝ)^(s-1)/(Real.log (t:ℝ))^(((s-2:ℕ):ℝ)+ε/2)) ≤ Real.log (ramsey s t:ℝ) at hl' rw [Real.log_div (pow_ne_zero (s-1) (ne_of_gt htp)) (ne_of_gt (Real.rpow_pos_of_pos hlt (((s-2:ℕ):ℝ)+(ε/2)))), Real.log_pow,Real.log_rpow hlt] at hl' have hu' := Real.log_le_log hr hu rw [Real.log_div (mul_ne_zero (ne_of_gt hC) (pow_ne_zero (s-1) (ne_of_gt htp))) (pow_ne_zero (s-2) (ne_of_gt hlt)), Real.log_mul (ne_of_gt hC) (pow_ne_zero (s-1) (ne_of_gt htp)),Real.log_pow,Real.log_pow] at hu' have herr : |Real.log C| < (ε/2)*Real.log (Real.log (t:ℝ)) := by have he := (div_lt_iff₀ hε).mp hllbig nlinarith have hlow : ((s-2:ℕ):ℝ)-ε/2 < (((s-1:ℕ):ℝ)*Real.log (t:ℝ)-Real.log (ramsey s t:ℝ))/ Real.log (Real.log (t:ℝ)) := by apply (lt_div_iff₀ hll0).mpr have habs := le_abs_self (Real.log C) nlinarith have hupp : (((s-1:ℕ):ℝ)*Real.log (t:ℝ)-Real.log (ramsey s t:ℝ))/ Real.log (Real.log (t:ℝ)) ≤ ((s-2:ℕ):ℝ)+ε/2 := by apply (div_le_iff₀ hll0).mpr nlinarith rw [Real.dist_eq,abs_lt] constructor <;> linarithend SharpLogRamsey
namespace SharpLogRamsey
theorem main_of_primeConstruction (s : ℕ) (hs : 6 ≤ s) (hprime : LowerTransfer.PrimeConstruction (s-1)) : MainBounds s ∧ MainLimit s := by have hb : MainBounds s := by obtain ⟨C,hC,t₀,ht₀⟩ := Upper.ramsey_upper (by omega : 3 ≤ s) refine ⟨C,hC,fun ε hε => ?_⟩ have hl := LowerTransfer.all_epsilon_lower (s-1) (by omega) hprime ε hε have he : s-1+1=s := by omega have he' : s-1-1=s-2 := by omega rw [he,he'] at hl obtain ⟨t₁,ht₁⟩ := Filter.eventually_atTop.mp hl exact ⟨max t₀ t₁,fun t ht => ⟨ht₁ t ((le_max_right _ _).trans ht), ht₀ t ((le_max_left _ _).trans ht)⟩⟩ exact ⟨hb,mainLimit_of_mainBounds s hb⟩end SharpLogRamsey
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186import Mathlibimport OAI.Combinatorics.SharpRamsey.Bounds.SamplingParameter
namespace OAI
/-! Transfer of finite prime-field graph constructions to all sufficiently large orders. -/
sectionnamespace SharpLogRamsey.LowerTransferopen Filter Realopen scoped Topologynoncomputable section
def PrimeConstruction (d : ℕ) : Prop := ∀ η : ℝ, 0 < η → η < 1/10 → ∀ᶠ q : ℕ in atTop, q.Prime → ∃ G : SimpleGraph (Fin ⌊(q:ℝ)^d * Real.log q⌋₊), G.CliqueFree (d+1) ∧ G.indepNum < ⌊(q:ℝ) * (Real.log q)^(1+η)⌋₊
theorem prime_interval (x : ℝ) (hx : 4 ≤ x) : ∃ q : ℕ, q.Prime ∧ x/4 ≤ q ∧ (q:ℝ) ≤ x := by let n := ⌊x/2⌋₊ have hn : 1 ≤ n := (Nat.one_le_floor_iff _).mpr (by linarith) obtain ⟨q,hq,hnq,hqn⟩ := Nat.exists_prime_lt_and_le_two_mul n (by omega) refine ⟨q,hq,?_,?_⟩ · have hnf := Nat.lt_floor_add_one (x/2) have hnqr : (n:ℝ)+1 ≤ q := by exact_mod_cast hnq dsimp [n] at hnqr linarith · have hnf := Nat.floor_le (show 0≤x/2 by linarith) have hqn' : (q:ℝ) ≤ 2*n := by exact_mod_cast hqn dsimp [n] at hqn' linarith
theorem witness_bound (d q t : ℕ) (η : ℝ) (hd : 1≤d) (ht : 1≤t) (G : SimpleGraph (Fin ⌊(q:ℝ)^d * Real.log q⌋₊)) (hG : G.CliqueFree (d+1)) (hI : G.indepNum < ⌊(q:ℝ)*(Real.log q)^(1+η)⌋₊) (hqt : (q:ℝ)*(Real.log q)^(1+η) ≤ t) : (q:ℝ)^d * Real.log q < (ramsey (d+1) t : ℝ) := by have hk : ⌊(q:ℝ)*(Real.log q)^(1+η)⌋₊ ≤ t := Nat.floor_le_of_le hqt have hf : Gᶜ.CliqueFree t := by intro A hA have hi := G.isNClique_compl.mp hA have hle := hi.isIndepSet.card_le_indepNum have hc := hi.card_eq omega have hr := Foundation.order_lt_ramsey G (by omega) ht hG hf simp only [Fintype.card_fin] at hr have hr' : (⌊(q:ℝ)^d * Real.log q⌋₊ :ℝ)+1 ≤ ramsey (d+1) t := by exact_mod_cast hr exact (Nat.lt_floor_add_one _).trans_le hr'
theorem eventual_scale (η : ℝ) : ∀ᶠ t : ℝ in atTop, 1 < t ∧ 1 ≤ Real.log t ∧ 4*t^((1:ℝ)/2) ≤ t/(Real.log t)^(1+η) := by have h := (isLittleO_log_rpow_rpow_atTop (1+η) (show 0<(1:ℝ)/2 by norm_num)).bound (show 0<(1:ℝ)/4 by norm_num) filter_upwards [h,eventually_gt_atTop (1:ℝ),Real.tendsto_log_atTop.eventually_ge_atTop 1] with t ht ht1 hl refine ⟨ht1,hl,?_⟩ have ht0 : 0<t := by linarith have hl0 : 0<Real.log t := by linarith simp only [Real.norm_eq_abs,abs_of_pos (Real.rpow_pos_of_pos hl0 _), abs_of_pos (Real.rpow_pos_of_pos ht0 _)] at ht apply (le_div_iff₀ (Real.rpow_pos_of_pos hl0 _)).mpr have hp : t^((1:ℝ)/2)*t^((1:ℝ)/2)=t := by rw [←Real.rpow_add ht0]; norm_num nlinarith [mul_le_mul_of_nonneg_left ht (Real.rpow_nonneg ht0.le ((1:ℝ)/2))]
theorem interval_bounds (η t q : ℝ) (hη : 0≤η) (ht : 1<t) (hl : 1≤Real.log t) (hscale : 4*t^((1:ℝ)/2) ≤ t/(Real.log t)^(1+η)) (hqlo : (t/(Real.log t)^(1+η))/4 ≤ q) (hqhi : q ≤ t/(Real.log t)^(1+η)) : 0<q ∧ Real.log t/2 ≤ Real.log q ∧ q*(Real.log q)^(1+η) ≤ t := by have ht0 : 0<t := by linarith have hl0 : 0<Real.log t := by linarith have hp : 0<(Real.log t)^(1+η) := Real.rpow_pos_of_pos hl0 _ have hqs : t^((1:ℝ)/2)≤q := by linarith have hq0 : 0<q := (Real.rpow_pos_of_pos ht0 _).trans_le hqs refine ⟨hq0,?_,?_⟩ · have hlog := Real.log_le_log (Real.rpow_pos_of_pos ht0 _) hqs rw [Real.log_rpow ht0] at hlog linarith · have hden : 1≤(Real.log t)^(1+η) := Real.one_le_rpow hl (by linarith) have hqt : q≤t := hqhi.trans (div_le_self ht0.le hden) have hq1 : 1≤q := (Real.one_le_rpow ht.le (by norm_num)).trans hqs have hlogq : 0≤Real.log q := Real.log_nonneg hq1 have hpow : (Real.log q)^(1+η)≤(Real.log t)^(1+η) := Real.rpow_le_rpow hlogq (Real.log_le_log hq0 hqt) (by linarith) calc q*(Real.log q)^(1+η) ≤ q*(Real.log t)^(1+η) := mul_le_mul_of_nonneg_left hpow hq0.le _ ≤ (t/(Real.log t)^(1+η))*(Real.log t)^(1+η) := mul_le_mul_of_nonneg_right hqhi hp.le _ = t := div_mul_cancel₀ _ hp.ne'
theorem scalar_lower (d : ℕ) (hd : 1≤d) (η ε t q : ℝ) (ht : 0≤t) (hl : 0<Real.log t) (hq : 0≤q) (hqlo : (t/(Real.log t)^(1+η))/4 ≤ q) (hlog : Real.log t/2 ≤ Real.log q) (habsorb : 2*(4:ℝ)^d ≤ (Real.log t)^(ε-(d:ℝ)*η)) : t^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) ≤ q^d*Real.log q := by let a : ℝ := ((d-1:ℕ):ℝ)+(d:ℝ)*η have he : (1+η)*(d:ℝ)=a+1 := by dsimp [a] rw [Nat.cast_sub hd] norm_num ring have he' : ((d-1:ℕ):ℝ)+ε=a+(ε-(d:ℝ)*η) := by dsimp [a];ring have hpow : ((Real.log t)^(1+η))^d=(Real.log t)^a*Real.log t := by rw [←Real.rpow_natCast,←Real.rpow_mul hl.le,he,Real.rpow_add_one hl.ne'] have hp : 0<(Real.log t)^a := Real.rpow_pos_of_pos hl _ have hp' : 0<(Real.log t)^(ε-(d:ℝ)*η) := Real.rpow_pos_of_pos hl _ have h4 : 0<(4:ℝ)^d := by positivity have hden : ((Real.log t)^a)*(2*(4:ℝ)^d) ≤ ((Real.log t)^a)*(Real.log t)^(ε-(d:ℝ)*η) := mul_le_mul_of_nonneg_left habsorb hp.le calc t^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) = t^d/((Real.log t)^a*(Real.log t)^(ε-(d:ℝ)*η)) := by rw [he',Real.rpow_add hl] _ ≤ t^d/((Real.log t)^a*(2*(4:ℝ)^d)) := div_le_div_of_nonneg_left (pow_nonneg ht _) (by positivity) hden _ = ((t/(Real.log t)^(1+η))/4)^d*(Real.log t/2) := by rw [div_pow,div_pow,hpow] field_simp _ ≤ q^d*Real.log q := by apply mul_le_mul · exact pow_le_pow_left₀ (by positivity) hqlo _ · exact hlog · positivity · exact pow_nonneg hq _
theorem lower_from_prime_construction (d : ℕ) (hd : 1≤d) (hprime : PrimeConstruction d) (η ε : ℝ) (hη : 0<η) (hη' : η<1/10) (hε : (d:ℝ)*η<ε) : ∀ᶠ t : ℕ in atTop, (t:ℝ)^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) ≤ (ramsey (d+1) t :ℝ) := by obtain ⟨q₀,hq₀⟩ := eventually_atTop.mp (hprime η hη hη') have hcoef : ∀ᶠ t : ℝ in atTop, 2*(4:ℝ)^d ≤ (Real.log t)^(ε-(d:ℝ)*η) := ((tendsto_rpow_atTop (by linarith : 0<ε-(d:ℝ)*η)).comp Real.tendsto_log_atTop).eventually_ge_atTop _ have hsqr : ∀ᶠ t : ℝ in atTop, max 1 (q₀:ℝ) ≤ t^((1:ℝ)/2) := (tendsto_rpow_atTop (by norm_num : 0<(1:ℝ)/2)).eventually_ge_atTop _ have H : ∀ᶠ t : ℝ in atTop, 1<t ∧ 1≤Real.log t ∧ 4*t^((1:ℝ)/2)≤t/(Real.log t)^(1+η) ∧ max 1 (q₀:ℝ)≤t^((1:ℝ)/2) ∧ 2*(4:ℝ)^d≤(Real.log t)^(ε-(d:ℝ)*η) := by filter_upwards [eventual_scale η,hsqr,hcoef] with t ht hs hc exact ⟨ht.1,ht.2.1,ht.2.2,hs,hc⟩ filter_upwards [tendsto_natCast_atTop_atTop.eventually H] with t ht obtain ⟨ht1,hl,hs,hqmin,hcoef⟩ := ht have hx4 : 4 ≤ (t:ℝ)/(Real.log t)^(1+η) := by have := (le_max_left (1:ℝ) q₀).trans hqmin linarith obtain ⟨q,hq,hql,hqu⟩ := prime_interval _ hx4 have hq₀' : q₀≤q := by have hreal : (q₀:ℝ)≤q := by have := (le_max_right (1:ℝ) q₀).trans hqmin linarith exact_mod_cast hreal obtain ⟨G,hG,hI⟩ := hq₀ q hq₀' hq obtain ⟨hqpos,hlog,hsize⟩ := interval_bounds η t q hη.le ht1 hl hs hql hqu have hr := witness_bound d q t η hd (by exact_mod_cast ht1.le) G hG hI hsize exact (scalar_lower d hd η ε t q (by positivity) (by linarith) hqpos.le hql hlog hcoef).trans hr.le
theorem all_epsilon_lower (d : ℕ) (hd : 1≤d) (hprime : PrimeConstruction d) (ε : ℝ) (hε : 0<ε) : ∀ᶠ t : ℕ in atTop, (t:ℝ)^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) ≤ (ramsey (d+1) t :ℝ) := by let η := min (1/20:ℝ) (ε/(2*(d:ℝ))) have hd0 : 0<(d:ℝ) := by exact_mod_cast (show 0<d by omega) have hη : 0<η := lt_min (by norm_num) (by positivity) have hη' : η<1/10 := (min_le_left _ _).trans_lt (by norm_num) have hηε : (d:ℝ)*η<ε := by have h := mul_le_mul_of_nonneg_left (min_le_right (1/20:ℝ) (ε/(2*(d:ℝ)))) hd0.le have he : (d:ℝ)*(ε/(2*(d:ℝ)))=ε/2 := by field_simp rw [he] at h exact h.trans_lt (by linarith) exact lower_from_prime_construction d hd hprime η ε hη hη' hηε
endend SharpLogRamsey.LowerTransfer
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313import Mathlibimport OAI.Combinatorics.SharpRamsey.Bounds.SumFiberCenter
namespace OAI
/-! The off-diagonal Ramsey upper bound. -/
sectionopen scoped BigOperators Classicalopen Finsetopen scoped BigOperators Classicalopen Finsetopen scoped BigOperators Classicalopen Finsetopen scoped BigOperatorsnamespace SharpLogRamsey.Uppertheorem sampling_parameter {h m t : ℝ} (hh : 1 ≤ h) (hm : 1 ≤ m) (ht : 65536 ≤ t) (hratio : m * Real.sqrt t ≤ h) : ∃ p : ℝ, 0 < p ∧ p ≤ 1 ∧ 1 ≤ p*h ∧ p^2*h*m ≤ 1/8 ∧ Real.log t ≤ 8 * Real.log (p*h) := by have hh0 : 0 < h := by linarith have hm0 : 0 < m := by linarith have ht0 : 0 < t := by linarith have hs : 0 < Real.sqrt (h*m) := Real.sqrt_pos.mpr (mul_pos hh0 hm0) let p := 1 / (4 * Real.sqrt (h*m)) have hp : 0 < p := by dsimp [p]; positivity have hs1 : 1 ≤ Real.sqrt (h*m) := by rw [Real.le_sqrt (by norm_num) (by positivity)] nlinarith have hp1 : p ≤ 1 := by dsimp [p] apply (div_le_iff₀ (by positivity)).mpr linarith have hsq := Real.sq_sqrt (show 0 ≤ h*m by positivity) have hmoment : p^2*h*m = 1/16 := by dsimp [p] field_simp nlinarith have hlog : Real.log (p*h) = (Real.log h - Real.log m)/2 - Real.log 4 := by dsimp [p] rw [Real.log_mul (by positivity) hh0.ne', Real.log_div (by norm_num) (by positivity), Real.log_one, Real.log_mul (by norm_num) hs.ne', Real.log_sqrt (by positivity : 0 ≤ h*m), Real.log_mul hh0.ne' hm0.ne'] ring have hratio' := Real.log_le_log (mul_pos hm0 (Real.sqrt_pos.mpr ht0)) hratio rw [Real.log_mul hm0.ne' (Real.sqrt_pos.mpr ht0).ne', Real.log_sqrt ht0.le] at hratio' have htlog := Real.log_le_log (show (0:ℝ) < 65536 by norm_num) ht have h65536 : Real.log (65536:ℝ) = 8 * Real.log 4 := by rw [show (65536:ℝ) = 4^8 by norm_num, Real.log_pow] norm_num rw [h65536] at htlog have hl : Real.log t ≤ 8 * Real.log (p*h) := by linarith have hl0 : 0 ≤ Real.log (p*h) := by have htl : 0 ≤ Real.log t := Real.log_nonneg (by linarith) linarith have hph : 1 ≤ p*h := by exact (Real.log_nonneg_iff (by positivity)).mp hl0 exact ⟨p,hp,hp1,hph,by linarith,hl⟩
end SharpLogRamsey.Upper
namespace SharpLogRamsey.Upperopen Foundation Samplingvariable {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
theorem alteration_bound {h m t : ℕ} (ht : 1 ≤ t) (hG : Gᶜ.CliqueFree t) (hdeg : ∀ x, G.degree x ≤ h) (hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m) {p : ℝ} (hp : 0 < p) (hp1 : p ≤ 1) (hph : 1 ≤ p*h) (hmoment : p^2*h*m ≤ 1/8) : (Fintype.card V : ℝ) * Real.log (p*h) ≤ 256 * t * h := by let n : ℝ := Fintype.card V have hn : 0 ≤ n := Nat.cast_nonneg _ have hhp : (0:ℝ) < h := by nlinarith have hD : 0 < 12*p*h := by positivity obtain ⟨U,hU,hUd,hUt⟩ := sample_prune G hp.le hp1 hD have hsum : (∑ x : V, (G.degree x : ℝ)) ≤ n*h := by calc _ ≤ ∑ _x : V, (h : ℝ) := sum_le_sum (fun x _ => by exact_mod_cast hdeg x) _ = n*h := by simp [n] have htri : ((G.cliqueFinset 3).card : ℝ) ≤ n*h*m := by dsimp [n] exact_mod_cast triangle_count_le G hdeg hcommon have hloss : p^2 * (∑ x : V, (G.degree x : ℝ)) / (12*p*h) ≤ n*p/12 := by apply (div_le_iff₀ hD).mpr calc _ ≤ p^2*(n*h) := mul_le_mul_of_nonneg_left hsum (sq_nonneg _) _ = n*p/12*(12*p*h) := by ring have htri' : p^3 * ((G.cliqueFinset 3).card : ℝ) ≤ n*p/8 := by calc _ ≤ p^3*(n*h*m) := mul_le_mul_of_nonneg_left htri (by positivity) _ = n*p*(p^2*h*m) := by ring _ ≤ n*p*(1/8) := mul_le_mul_of_nonneg_left hmoment (by positivity) _ = n*p/8 := by ring have hUsize : 3/4*n*p ≤ (U.card : ℝ) := by dsimp [n] at *; linarith have hlog : 0 ≤ Real.log (p*h) := Real.log_nonneg hph by_cases hn0 : n = 0 · change n * _ ≤ _ rw [hn0, zero_mul] positivity have hnpos : 0 < n := lt_of_le_of_ne hn (Ne.symm hn0) have hUpos : 0 < U.card := by have hu : (0:ℝ) < U.card := lt_of_lt_of_le (by positivity) hUsize exact_mod_cast hu obtain ⟨x,hx⟩ := card_pos.mp hUpos let : Nonempty (U : Set V) := ⟨⟨x,hx⟩⟩ have ha := TriangleFree.indepNum_lower_bound (G.induce (U : Set V)) hUt (by nlinarith : (1:ℝ) ≤ 12*p*h) hUd have hat : ((G.induce (U : Set V)).indepNum : ℝ) < t := by exact_mod_cast indepNum_lt_of_cliqueFree_compl (G.induce (U : Set V)) (compl_cliqueFree_induce G hG _) have ha' : (U.card : ℝ) * Real.log (12*p*h+1) < t*(8*(12*p*h+1)) := by have H := ha.trans_lt hat rw [div_lt_iff₀ (by positivity)] at H have hc : Fintype.card (U : Set V) = U.card := Fintype.card_coe U simpa only [hc] using H have hl : Real.log (p*h) ≤ Real.log (12*p*h+1) := Real.log_le_log (by positivity) (by nlinarith) have hu : (3/4*n*p) * Real.log (p*h) ≤ (U.card : ℝ) * Real.log (12*p*h+1) := mul_le_mul hUsize hl hlog (Nat.cast_nonneg _) have hd : t*(8*(12*p*h+1)) ≤ 104*t*p*h := by have ht0 : (0:ℝ) ≤ t := Nat.cast_nonneg _ nlinarith [mul_le_mul_of_nonneg_left hph ht0] have H := (hu.trans_lt ha').trans_le hd have ht0 : (0:ℝ) ≤ t := Nat.cast_nonneg _ change n*Real.log (p*h) ≤ _ have : p*(n*Real.log (p*h)) ≤ p*(256*t*h) := by nlinarith exact (mul_le_mul_iff_right₀ hp).mp this
theorem graph_recurrence (j : ℕ) {t : ℕ} (ht : 65536 ≤ t) (hs : G.CliqueFree (j+4)) (hi : Gᶜ.CliqueFree t) : (Fintype.card V : ℝ) ≤ t*((t:ℝ)^(j+1)*Real.sqrt t+1) + 2048*t*(ramsey (j+3) t)/Real.log t := by let h := G.maxDegree let m := ramsey (j+2) t have ht1 : 1 ≤ t := by omega have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega) have hlog : 0 < Real.log t := Real.log_pos (by exact_mod_cast (show 1 < t by omega)) have hm1 : 1 ≤ m := ht1.trans (le_ramsey (by omega) ht1) have hmb : (m : ℝ) ≤ (t:ℝ)^(j+1) := by have H := ramsey_le_pow (s := j+2) (by omega) ht1 norm_num at H exact_mod_cast H have hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m := by intro x y hxy exact (order_lt_ramsey (G.induce (G.commonNeighbors x y)) (by omega) ht1 (cliqueFree_common G hs hxy) (compl_cliqueFree_induce G hi _)).le have hdeg : ∀ x, G.degree x ≤ h := G.degree_le_maxDegree have hhr : h ≤ ramsey (j+3) t := by apply G.maxDegree_le_of_forall_degree_le intro x have H := order_lt_ramsey (G.induce (G.neighborSet x)) (by omega) ht1 (cliqueFree_neighbor G hs x) (compl_cliqueFree_induce G hi _) rw [G.card_neighborSet_eq_degree] at H exact H.le have hright : 0 ≤ 2048*(t:ℝ)*(ramsey (j+3) t)/Real.log t := by positivity by_cases hsmall : (h:ℝ) ≤ m*Real.sqrt t · have hn := card_le_mul_indepNum G (B := h+1) (by intro x; exact Nat.add_le_add_right (hdeg x) 1) have hia := indepNum_lt_of_cliqueFree_compl G hi have Hnat : Fintype.card V ≤ (h+1)*t := hn.trans (Nat.mul_le_mul_left _ hia.le) have H : (Fintype.card V : ℝ) ≤ ((h:ℝ)+1)*t := by exact_mod_cast Hnat have hm' := mul_le_mul_of_nonneg_right hmb (Real.sqrt_nonneg (t:ℝ)) have H' := mul_le_mul_of_nonneg_right (add_le_add_right (hsmall.trans hm') 1) ht0.le nlinarith · have hh : (1:ℝ) ≤ h := by have hsqrt : 1 ≤ Real.sqrt (t:ℝ) := by rw [Real.le_sqrt (by norm_num) ht0.le] exact_mod_cast ht1 have hm1' : (1:ℝ) ≤ m := by exact_mod_cast hm1 nlinarith obtain ⟨p,hp,hp1,hph,hpm,hl⟩ := sampling_parameter hh (by exact_mod_cast hm1) (by exact_mod_cast ht) (le_of_not_ge hsmall) have hab := alteration_bound G ht1 hi hdeg hcommon hp hp1 hph hpm have hn0 : (0:ℝ) ≤ Fintype.card V := Nat.cast_nonneg _ have H : (Fintype.card V : ℝ)*Real.log t ≤ 2048*t*h := by nlinarith [mul_le_mul_of_nonneg_left hl hn0] have H' : (Fintype.card V : ℝ) ≤ 2048*t*h/Real.log t := (le_div_iff₀ hlog).mpr H have H'' : 2048*(t:ℝ)*h/Real.log t ≤ 2048*t*(ramsey (j+3) t)/Real.log t := by apply div_le_div_of_nonneg_right _ hlog.le exact mul_le_mul_of_nonneg_left (by exact_mod_cast hhr) (by positivity) have hleft : 0 ≤ (t:ℝ)*((t:ℝ)^(j+1)*Real.sqrt t+1) := by positivity linarith
theorem ramsey_recurrence (j : ℕ) {t : ℕ} (ht : 65536 ≤ t) : (ramsey (j+4) t : ℝ) ≤ t*((t:ℝ)^(j+1)*Real.sqrt t+1) + 2048*t*(ramsey (j+3) t)/Real.log t + 1 := by classical obtain ⟨G,hG,hGi⟩ := exists_avoiding_pred (s := j+4) (by omega) (by omega : 2 ≤ t) have H := graph_recurrence G j ht hG hGi simp only [Fintype.card_fin] at H have hr : 1 ≤ ramsey (j+4) t := (by omega : 1 ≤ t).trans (le_ramsey (by omega) (by omega)) rw [Nat.cast_sub hr, Nat.cast_one] at H linarith
theorem ramsey_three {t : ℕ} (ht : 2 ≤ t) : (ramsey 3 t : ℝ)*Real.log t ≤ 17*(t:ℝ)^2 := by classical obtain ⟨G,hG,hGi⟩ := exists_avoiding_pred (s := 3) (by omega) ht have hr : 2 ≤ ramsey 3 t := ht.trans (le_ramsey (by omega) (by omega)) have hnon : 0 < ramsey 3 t - 1 := by omega let : Nonempty (Fin (ramsey 3 t - 1)) := Fin.pos_iff_nonempty.mp hnon have hd : ∀ x, (G.degree x : ℝ) ≤ t := by intro x have H := order_lt_ramsey (G.induce (G.neighborSet x)) (by omega : 2 ≤ 2) (by omega : 1 ≤ t) (cliqueFree_neighbor G hG x) (compl_cliqueFree_induce G hGi _) rw [G.card_neighborSet_eq_degree, ramsey_two (by omega)] at H exact_mod_cast H.le have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega) have ht1 : (1:ℝ) ≤ t := by exact_mod_cast (show 1 ≤ t by omega) have hl : 0 ≤ Real.log (t:ℝ) := Real.log_nonneg ht1 have H := TriangleFree.indepNum_lower_bound G hG ht1 hd have hi : (G.indepNum : ℝ) < t := by exact_mod_cast indepNum_lt_of_cliqueFree_compl G hGi have H' := H.trans_lt hi rw [div_lt_iff₀ (by positivity)] at H' have hc : (Fintype.card (Fin (ramsey 3 t - 1)) : ℝ) = (ramsey 3 t : ℝ)-1 := by rw [Fintype.card_fin, Nat.cast_sub (by omega), Nat.cast_one] rw [hc] at H' have hl' : Real.log (t:ℝ) ≤ Real.log ((t:ℝ)+1) := Real.log_le_log ht0 (by linarith) have hn : 0 ≤ (ramsey 3 t : ℝ)-1 := by have H : (2:ℝ) ≤ ramsey 3 t := by exact_mod_cast hr linarith have hh := mul_le_mul_of_nonneg_left hl' hn have hlt := Real.log_le_self ht0.le nlinarith [sq_nonneg ((t:ℝ)-1)]
open Filter in theorem eventually_log_pow_le_sqrt (j : ℕ) : ∀ᶠ t : ℕ in atTop, (Real.log (t:ℝ))^j ≤ Real.sqrt t := by have H := (isLittleO_log_rpow_rpow_atTop (j:ℝ) (by norm_num : (0:ℝ)<1/2)).bound (by norm_num : (0:ℝ)<1) have Hn := tendsto_natCast_atTop_atTop.eventually H filter_upwards [Hn, eventually_ge_atTop (1:ℕ)] with t ht ht1 have hlog := Real.log_nonneg (show (1:ℝ) ≤ t by exact_mod_cast ht1) simpa only [Real.rpow_natCast, Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hlog _), ← Real.sqrt_eq_rpow, abs_of_nonneg (Real.sqrt_nonneg _), one_mul] using ht
open Filter in
theorem ramsey_upper_scaled (j : ℕ) : ∃ C : ℝ, 0 < C ∧ ∀ᶠ t : ℕ in atTop, (ramsey (j+3) t : ℝ)*(Real.log (t:ℝ))^(j+1) ≤ C*(t:ℝ)^(j+2) := by induction j with | zero => refine ⟨17, by norm_num, ?_⟩ filter_upwards [eventually_ge_atTop (2:ℕ)] with t ht simpa using ramsey_three ht | succ j ih => obtain ⟨C,hC,hCb⟩ := ih refine ⟨3+2048*C, by positivity, ?_⟩ filter_upwards [hCb, eventually_log_pow_le_sqrt (j+2), eventually_ge_atTop (65536:ℕ)] with t hCt hL ht have ht1 : (1:ℝ) ≤ t := by exact_mod_cast (show 1 ≤ t by omega) have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega) have hl : 0 < Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (show 1 < t by omega)) have hs := Real.sqrt_nonneg (t:ℝ) have hs2 := Real.sq_sqrt ht0.le have hst : Real.sqrt (t:ℝ) ≤ t := by rw [Real.sqrt_le_iff] exact ⟨ht0.le, by nlinarith⟩ have hpow : (t:ℝ)^2 ≤ (t:ℝ)^(j+3) := pow_le_pow_right₀ ht1 (by omega) have hsmall : (t*((t:ℝ)^(j+1)*Real.sqrt t+1)+1)*(Real.log (t:ℝ))^(j+2) ≤ 3*(t:ℝ)^(j+3) := by calc _ ≤ (t*((t:ℝ)^(j+1)*Real.sqrt t+1)+1)*Real.sqrt t := mul_le_mul_of_nonneg_left hL (by positivity) _ = (t:ℝ)^(j+1)*t*(Real.sqrt t)^2+(t+1)*Real.sqrt t := by ring _ = (t:ℝ)^(j+3)+(t+1)*Real.sqrt t := by rw [hs2] simp only [pow_succ] _ ≤ (t:ℝ)^(j+3)+2*(t:ℝ)^2 := by have H := mul_le_mul_of_nonneg_left hst (by positivity : (0:ℝ) ≤ t+1) nlinarith _ ≤ 3*(t:ℝ)^(j+3) := by linarith have hmain : (2048*t*(ramsey (j+3) t)/Real.log t)*(Real.log (t:ℝ))^(j+2) ≤ (2048*C)*(t:ℝ)^(j+3) := by calc _ = 2048*t*((ramsey (j+3) t : ℝ)*(Real.log (t:ℝ))^(j+1)) := by rw [show j+2 = (j+1)+1 from by omega, pow_succ] field_simp _ ≤ 2048*t*(C*(t:ℝ)^(j+2)) := mul_le_mul_of_nonneg_left hCt (by positivity) _ = (2048*C)*(t:ℝ)^(j+3) := by rw [show j+3 = (j+2)+1 from by omega, pow_succ]; ring have H := mul_le_mul_of_nonneg_right (ramsey_recurrence j ht) (pow_nonneg hl.le (j+2)) linear_combination H + hsmall + hmain
open Filter in theorem ramsey_upper {s : ℕ} (hs : 3 ≤ s) : ∃ C : ℝ, 0 < C ∧ ∃ t₀ : ℕ, ∀ t : ℕ, t₀ ≤ t → (ramsey s t : ℝ) ≤ C*(t:ℝ)^(s-1)/(Real.log (t:ℝ))^(s-2) := by obtain ⟨j,rfl⟩ := Nat.exists_eq_add_of_le hs obtain ⟨C,hC,hCb⟩ := ramsey_upper_scaled j refine ⟨C,hC,?_⟩ have H : ∀ᶠ t : ℕ in atTop, (ramsey (3+j) t : ℝ) ≤ C*(t:ℝ)^(3+j-1)/(Real.log (t:ℝ))^(3+j-2) := by filter_upwards [hCb, eventually_ge_atTop (2:ℕ)] with t ht ht2 have hl : 0 < Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (show 1 < t by omega)) apply (le_div_iff₀ (pow_pos hl _)).mpr simpa [show 3+j = j+3 from by omega] using ht exact eventually_atTop.mp H
end SharpLogRamsey.Upper
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461import Mathlibimport OAI.Combinatorics.SharpRamsey.Construction.FiniteStreamTailimport OAI.Combinatorics.SharpRamsey.Bounds.Upper
namespace OAI
/-! The off-diagonal Ramsey upper bound. -/
sectionopen scoped BigOperators Classicalopen Finsetopen scoped BigOperators Classicalopen Finsetnamespace SharpLogRamsey.TriangleFreevariable {V : Type*} [Fintype V] [DecidableEq V]variable (G : SimpleGraph V)theorem sum_fiber_center (htri : G.CliqueFree 3) {x : V} {J : Finset V} (hJ : Admissible G x J) : ∑ S ∈ fiber G x J, (if x ∈ S then (1:ℝ) else 0) = 1 := by rw [sum_fiber G htri hJ] simp only [mem_insert_self, ite_true] have hx : ∀ K ∈ (available G x J).powerset, x ∉ J ∪ K := by intro K hK h rcases mem_union.mp h with hx | hx · exact admissible_not_center G hJ hx · exact center_not_available G x J (mem_powerset.mp hK hx) rw [sum_eq_zero (fun K hK => ite_eq_right (hx K hK)), add_zero]
theorem twice_sum_fiber_neighbors (htri : G.CliqueFree 3) {x : V} {J : Finset V} (hJ : Admissible G x J) : 2 * (∑ S ∈ fiber G x J, ((S ∩ G.neighborFinset x).card : ℝ)) = (available G x J).card * (2:ℝ)^(available G x J).card := by rw [sum_fiber G htri hJ, center_neighbor_inter G hJ, card_empty, Nat.cast_zero, zero_add] have he : ∑ K ∈ (available G x J).powerset, (((J ∪ K) ∩ G.neighborFinset x).card : ℝ) = ∑ K ∈ (available G x J).powerset, (K.card : ℝ) := by apply sum_congr rfl intro K hK rw [extend_neighbor_inter G hJ (mem_powerset.mp hK)] rw [he] exact twice_sum_powerset_card (available G x J)
noncomputable def Z (x : V) (S : Finset V) : ℕ := (available G x (outside G x S)).card
theorem fiber_empty_of_not_admissible {x : V} {J : Finset V} (hJ : ¬Admissible G x J) : fiber G x J = ∅ := by apply eq_empty_iff_forall_notMem.mpr intro S hS obtain ⟨hS, hout⟩ := mem_filter.mp hS exact hJ (hout ▸ admissible_outside G x hS)
theorem sum_fiber_Z (x : V) (J : Finset V) (f : ℕ → ℝ) : ∑ S ∈ fiber G x J, f (Z G x S) = (fiber G x J).card * f (available G x J).card := by calc _ = ∑ _S ∈ fiber G x J, f (available G x J).card := by apply sum_congr rfl intro S hS simp only [Z, (mem_filter.mp hS).2] _ = _ := by simp
theorem exp_neg_log_two_mul (z : ℕ) : Real.exp (-(Real.log 2) * z) = ((2:ℝ)^z)⁻¹ := by rw [show -(Real.log 2) * z = -((z:ℝ) * Real.log 2) by ring, Real.exp_neg, Real.exp_nat_mul, Real.exp_log (by norm_num)]
theorem half_sum_exp_le_center (htri : G.CliqueFree 3) (x : V) : (∑ S ∈ independentSets G, Real.exp (-Real.log 2 * Z G x S)) / 2 ≤ ∑ S ∈ independentSets G, (if x ∈ S then (1:ℝ) else 0) := by rw [← Finset.sum_fiberwise (independentSets G) (outside G x) (fun S => Real.exp (-Real.log 2 * Z G x S)), ← Finset.sum_fiberwise (independentSets G) (outside G x) (fun S => if x ∈ S then (1:ℝ) else 0), sum_div] apply sum_le_sum intro J _ change (∑ S ∈ fiber G x J, _) / 2 ≤ ∑ S ∈ fiber G x J, _ by_cases hJ : Admissible G x J · rw [sum_fiber_Z G x J (fun z => Real.exp (-Real.log 2 * z)), card_fiber G htri hJ, sum_fiber_center G htri hJ, exp_neg_log_two_mul] push_cast have hp : (1:ℝ) ≤ 2^(available G x J).card := one_le_pow₀ (by norm_num) have hpp : (0:ℝ) < 2^(available G x J).card := by positivity field_simp nlinarith · rw [fiber_empty_of_not_admissible G hJ] simp
theorem sum_Z_le_four_neighbors (htri : G.CliqueFree 3) (x : V) : (∑ S ∈ independentSets G, (Z G x S : ℝ)) ≤ 4 * ∑ S ∈ independentSets G, ((S ∩ G.neighborFinset x).card : ℝ) := by rw [← Finset.sum_fiberwise (independentSets G) (outside G x) (fun S => (Z G x S : ℝ)), ← Finset.sum_fiberwise (independentSets G) (outside G x) (fun S => ((S ∩ G.neighborFinset x).card : ℝ)), mul_sum] apply sum_le_sum intro J _ change (∑ S ∈ fiber G x J, _) ≤ 4 * ∑ S ∈ fiber G x J, _ by_cases hJ : Admissible G x J · rw [sum_fiber_Z G x J (fun z => (z:ℝ)), card_fiber G htri hJ] have hn := twice_sum_fiber_neighbors G htri hJ have hp : (1:ℝ) ≤ 2^(available G x J).card := one_le_pow₀ (by norm_num) have hz : (0:ℝ) ≤ (available G x J).card := by positivity push_cast nlinarith · rw [fiber_empty_of_not_admissible G hJ] simp
theorem sum_center (S : Finset V) : (∑ x : V, if x ∈ S then (1:ℝ) else 0) = S.card := by simp
theorem sum_neighbors (S : Finset V) : (∑ x : V, ((S ∩ G.neighborFinset x).card : ℝ)) = ∑ v ∈ S, (G.degree v : ℝ) := by calc _ = ∑ x : V, ∑ v ∈ S, (if G.Adj x v then (1:ℝ) else 0) := by apply sum_congr rfl intro x _ rw [← sum_filter] simp only [sum_const, nsmul_eq_mul, mul_one] congr 2 ext v simp [] _ = ∑ v ∈ S, ∑ x : V, (if G.Adj x v then (1:ℝ) else 0) := sum_comm _ = _ := by apply sum_congr rfl intro v _ simp_rw [G.adj_comm] rw [← sum_filter] have he : univ.filter (G.Adj v) = G.neighborFinset v := by ext x; simp rw [he] simp
theorem exp_mean_le {α : Type*} (A : Finset α) (hA : A.Nonempty) (f : α → ℝ) : Real.exp ((∑ i ∈ A, f i) / A.card) ≤ (∑ i ∈ A, Real.exp (f i)) / A.card := by have hc : (0:ℝ) < A.card := by exact_mod_cast hA.card_pos have hsum : ∑ _i ∈ A, ((A.card:ℝ)⁻¹) = 1 := by simp [hc.ne'] have hj := convexOn_exp.map_sum_le (t := A) (w := fun _ => (A.card:ℝ)⁻¹) (p := f) (fun _ _ => inv_nonneg.mpr hc.le) hsum (fun _ _ => Set.mem_univ _) simp only [smul_eq_mul, ← mul_sum] at hj simpa only [div_eq_mul_inv, mul_comm] using hj
theorem occupation_lower_bound {D μ : ℝ} (hD : 1 ≤ D) (hμ : 0 ≤ μ) (hkey : Real.exp (-4 * D * μ * Real.log 2) ≤ 2 * μ) : Real.log (D+1) / (8 * (D+1)) ≤ μ := by by_contra! hbad have hu : 0 < D + 1 := by linarith have hlog : 0 < Real.log (D+1) := Real.log_pos (by linarith) have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num) have hl2' : Real.log 2 < 1 := by convert Real.log_lt_sub_one_of_pos (x := (2:ℝ)) (by norm_num) (by norm_num) using 1 ; norm_num have hb : 8 * (D+1) * μ < Real.log (D+1) := by have := (lt_div_iff₀ (show 0 < 8*(D+1) by positivity)).mp hbad nlinarith have hDμ : 0 ≤ D * μ := mul_nonneg (by linarith) hμ have he : -Real.log (D+1)/2 < -4 * D * μ * Real.log 2 := by have hh := mul_le_mul_of_nonneg_left hl2'.le hDμ nlinarith have hlow : Real.exp (-Real.log (D+1)/2) < 2 * μ := (Real.exp_lt_exp.mpr he).trans_le hkey have hid : (D+1) * Real.exp (-Real.log (D+1)/2) = Real.exp (Real.log (D+1)/2) := by conv_lhs => lhs; rw [← Real.exp_log hu] rw [← Real.exp_add] congr 1 ring have hupper := Real.add_one_le_exp (Real.log (D+1)/2) have hmul := mul_lt_mul_of_pos_left hlow (show 0 < 4*(D+1) by positivity) nlinarith
theorem exists_occupation (htri : G.CliqueFree 3) [Nonempty V] {D : ℝ} (hD : ∀ x, (G.degree x : ℝ) ≤ D) : ∃ μ : ℝ, 0 ≤ μ ∧ (Fintype.card V : ℝ) * μ ≤ G.indepNum ∧ Real.exp (-4 * D * μ * Real.log 2) ≤ 2 * μ := by let A := independentSets G let Ω := (univ : Finset V) ×ˢ A let M : ℝ := ∑ S ∈ A, (S.card : ℝ) let m : ℝ := (Fintype.card V : ℝ) * A.card have hn : (0:ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos have ha : (0:ℝ) < A.card := by exact_mod_cast (independentSets_nonempty G).card_pos have hm : 0 < m := mul_pos hn ha have hmcard : (Ω.card:ℝ) = m := by simp [Ω, m] have hM : 0 ≤ M := sum_nonneg (fun _ _ => Nat.cast_nonneg _) have he : (∑ a ∈ Ω, Real.exp (-Real.log 2 * Z G a.1 a.2)) ≤ 2*M := by have hh := sum_le_sum (s := (univ : Finset V)) (fun x _ => half_sum_exp_le_center G htri x) rw [← sum_div] at hh have hcenter : (∑ x : V, ∑ S ∈ independentSets G, (if x ∈ S then (1:ℝ) else 0)) = M := by rw [sum_comm] simp only [sum_center] rfl rw [hcenter] at hh unfold Ω rw [sum_product] dsimp only change (∑ x : V, ∑ S ∈ independentSets G, _) ≤ 2*M linarith have hz : (∑ a ∈ Ω, (Z G a.1 a.2 : ℝ)) ≤ 4*D*M := by have hh := sum_le_sum (s := (univ : Finset V)) (fun x _ => sum_Z_le_four_neighbors G htri x) rw [← mul_sum] at hh have hneigh : (∑ x : V, ∑ S ∈ independentSets G, ((S ∩ G.neighborFinset x).card:ℝ)) = ∑ S ∈ independentSets G, ∑ v ∈ S, (G.degree v:ℝ) := by rw [sum_comm] simp_rw [sum_neighbors] rw [hneigh] at hh have hd : (∑ S ∈ independentSets G, ∑ v ∈ S, (G.degree v : ℝ)) ≤ D*M := by calc _ ≤ ∑ S ∈ independentSets G, ∑ _v ∈ S, D := by apply sum_le_sum intro S _ exact sum_le_sum (fun v _ => hD v) _ = D*M := by simp [M, A, mul_sum, mul_comm] unfold Ω rw [sum_product] dsimp only change (∑ x : V, ∑ S ∈ independentSets G, _) ≤ 4*D*M linarith have hind : M ≤ (A.card:ℝ) * G.indepNum := by calc M ≤ ∑ _S ∈ A, (G.indepNum : ℝ) := by apply sum_le_sum intro S hS exact_mod_cast (mem_independentSets G S |>.mp hS).card_le_indepNum _ = _ := by simp refine ⟨M/m, div_nonneg hM hm.le, ?_, ?_⟩ · rw [← mul_div_assoc] apply (div_le_iff₀ hm).mpr dsimp only [m] nlinarith [mul_le_mul_of_nonneg_left hind hn.le] · have hΩ : Ω.Nonempty := nonempty_product.mpr ⟨univ_nonempty, independentSets_nonempty G⟩ have hj := exp_mean_le Ω hΩ (fun a => -Real.log 2 * Z G a.1 a.2) rw [hmcard, ← mul_sum] at hj have hl : 0 ≤ Real.log 2 := (Real.log_pos (by norm_num : (1:ℝ)<2)).le have hexp : Real.exp (-4*D*(M/m)*Real.log 2) ≤ Real.exp (-Real.log 2 * (∑ a ∈ Ω, (Z G a.1 a.2:ℝ)) / m) := by apply Real.exp_le_exp.mpr rw [show -4*D*(M/m)*Real.log 2 = (-4*D*M*Real.log 2)/m by ring] apply (div_le_div_iff_of_pos_right hm).mpr have hh := mul_le_mul_of_nonpos_left hz (neg_nonpos.mpr hl) convert hh using 1 ; ring have hfinal := hexp.trans hj have hdiv := div_le_div_of_nonneg_right he hm.le calc _ ≤ (∑ a ∈ Ω, Real.exp (-Real.log 2 * Z G a.1 a.2))/m := hfinal _ ≤ 2*M/m := hdiv _ = 2*(M/m) := by ring
theorem indepNum_lower_bound (htri : G.CliqueFree 3) [Nonempty V] {D : ℝ} (hD : 1 ≤ D) (hdeg : ∀ x, (G.degree x : ℝ) ≤ D) : (Fintype.card V : ℝ) * Real.log (D+1) / (8*(D+1)) ≤ G.indepNum := by obtain ⟨μ, hμ, hind, hkey⟩ := exists_occupation G htri hdeg have hb := occupation_lower_bound hD hμ hkey have hh := mul_le_mul_of_nonneg_left hb (show (0:ℝ) ≤ Fintype.card V by positivity) rw [← mul_div_assoc] at hh exact hh.trans hind
end SharpLogRamsey.TriangleFree
open scoped BigOperators Classicalopen Finsetnamespace SharpLogRamsey.Samplingvariable {V : Type*} [Fintype V] [DecidableEq V]
variable (G : SimpleGraph V)
noncomputable def internalDegree (S : Finset V) (x : V) : ℕ := (S.filter (G.Adj x)).card
noncomputable def degreeMass (S : Finset V) : ℕ := ∑ x ∈ S, internalDegree G S x
theorem degreeMass_pair_sum (S : Finset V) : (degreeMass G S : ℝ) = ∑ x : V, ∑ y : V, if G.Adj x y then (if ({x,y} : Finset V) ⊆ S then 1 else 0) else 0 := by have hi (x : V) : (∑ y : V, if G.Adj x y then (if ({x,y} : Finset V) ⊆ S then (1:ℝ) else 0) else 0) = if x ∈ S then (internalDegree G S x : ℝ) else 0 := by by_cases hx : x ∈ S · rw [ite_eq_left hx] have he : S = univ.filter (· ∈ S) := by simp change _ = ((S.filter (G.Adj x)).card : ℝ) conv_rhs => rw [he] rw [filter_filter, ← sum_boole] apply sum_congr rfl intro y _ simp only [insert_subset_iff, singleton_subset_iff, hx, true_and] by_cases h : G.Adj x y <;> by_cases hy : y ∈ S <;> simp [h, hy] · simp [insert_subset_iff, singleton_subset_iff, hx] simp_rw [hi] rw [← sum_filter] simp [degreeMass, Nat.cast_sum]
theorem degreeMass_moment (p : ℝ) : (∑ f : V → Bool, weight p f * degreeMass G (selected f)) = p^2 * ∑ x : V, (G.degree x : ℝ) := by simp_rw [degreeMass_pair_sum, mul_sum] rw [sum_comm] calc _ = ∑ x : V, ∑ y : V, if G.Adj x y then p^2 else 0 := by apply sum_congr rfl intro x _ rw [sum_comm] apply sum_congr rfl intro y _ by_cases h : G.Adj x y · simp only [ite_eq_left h] rw [containment_moment] simp [h.ne] · simp [h] _ = p^2 * ∑ x : V, (G.degree x : ℝ) := by rw [mul_sum] apply sum_congr rfl intro x _ rw [← sum_filter] simp [← G.card_neighborFinset_eq_degree, SimpleGraph.neighborFinset_def, mul_comm] _ = _ := by simp [mul_sum]
omit [Fintype V] in
theorem exists_avoid_family (F : Finset (Finset V)) (hF : ∀ A ∈ F, A.Nonempty) (S : Finset V) : ∃ U ⊆ S, S.card ≤ U.card + F.card ∧ ∀ A ∈ F, ¬ A ⊆ U := by induction F using Finset.induction_on generalizing S with | empty => exact ⟨S, Subset.rfl, by simp, by simp⟩ | @insert A F hAF ih => obtain ⟨U, hUS, hUcard, hU⟩ := ih (fun B hB => hF B (mem_insert_of_mem hB)) S by_cases hAU : A ⊆ U · obtain ⟨x, hx⟩ := hF A (mem_insert_self A F) refine ⟨U.erase x, (erase_subset x U).trans hUS, ?_, ?_⟩ · have he := card_erase_of_mem (hAU hx) rw [card_insert_of_notMem hAF] omega · intro B hB hBU rcases mem_insert.mp hB with rfl | hB · exact (notMem_erase x U) (hBU hx) · exact hU B hB (hBU.trans (erase_subset x U)) · refine ⟨U, hUS, ?_, ?_⟩ · rw [card_insert_of_notMem hAF] omega · intro B hB hBU rcases mem_insert.mp hB with rfl | hB · exact hAU hBU · exact hU B hB hBU
theorem prune (S : Finset V) {D : ℝ} (hD : 0 < D) : ∃ U ⊆ S, (S.card : ℝ) - degreeMass G S / D - count (G.cliqueFinset 3) S ≤ U.card ∧ (∀ x ∈ U, (internalDegree G U x : ℝ) ≤ D) ∧ (G.induce (U : Set V)).CliqueFree 3 := by let bad := S.filter (fun x => D < (internalDegree G S x : ℝ)) have hbad : (bad.card : ℝ) ≤ degreeMass G S / D := by apply (le_div_iff₀ hD).mpr calc (bad.card : ℝ) * D = ∑ _x ∈ bad, D := by simp _ ≤ ∑ x ∈ bad, (internalDegree G S x : ℝ) := by exact sum_le_sum (fun x hx => (mem_filter.mp hx).2.le) _ ≤ ∑ x ∈ S, (internalDegree G S x : ℝ) := sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (by intros; positivity) _ = degreeMass G S := by simp [degreeMass, Nat.cast_sum] let T := S \ bad let F := (G.cliqueFinset 3).filter (· ⊆ S) have hF : ∀ A ∈ F, A.Nonempty := by intro A hA have ha := (SimpleGraph.mem_cliqueFinset_iff.mp (mem_filter.mp hA).1).2 exact card_pos.mp (by omega) obtain ⟨U, hUT, hcard, havoid⟩ := exists_avoid_family F hF T have hUS : U ⊆ S := hUT.trans sdiff_subset refine ⟨U, hUS, ?_, ?_, ?_⟩ · have hc : (S.card : ℝ) ≤ T.card + bad.card := by exact_mod_cast card_le_card_sdiff_add_card have hu : (T.card : ℝ) ≤ U.card + F.card := by exact_mod_cast hcard change (S.card : ℝ) - degreeMass G S / D - F.card ≤ _ linarith · intro x hx have hxT := mem_sdiff.mp (hUT hx) have hd : (internalDegree G S x : ℝ) ≤ D := by by_contra! hh exact hxT.2 (mem_filter.mpr ⟨hxT.1, hh⟩) exact (Nat.cast_le.mpr (card_le_card (filter_subset_filter _ hUS))).trans hd · rw [G.cliqueFree_induce_iff] intro A hAU hA have hAF : A ∈ F := mem_filter.mpr ⟨SimpleGraph.mem_cliqueFinset_iff.mpr hA, (show A ⊆ U from hAU).trans hUS⟩ exact havoid A hAF hAU
omit [Fintype V] [DecidableEq V] intheorem induced_degree (U : Finset V) (x : (U : Set V)) : (G.induce (U : Set V)).degree x = internalDegree G U x := by rw [← SimpleGraph.card_neighborSet_eq_degree] let e : ((G.induce (U : Set V)).neighborSet x) ≃ {y : V // y ∈ U.filter (G.Adj x)} := { toFun := fun y => ⟨y.1, mem_filter.mpr ⟨y.1.2, y.2⟩⟩ invFun := fun y => ⟨⟨y.1, (mem_filter.mp y.2).1⟩, (mem_filter.mp y.2).2⟩ left_inv := by intro y; rfl right_inv := by intro y; rfl } exact (Fintype.card_congr e).trans (Fintype.card_coe (U.filter (G.Adj x)))
theorem sample_prune {p D : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) (hD : 0 < D) : ∃ U : Finset V, p * Fintype.card V - p^2 * (∑ x, (G.degree x : ℝ)) / D - p^3 * (G.cliqueFinset 3).card ≤ U.card ∧ (∀ x : (U : Set V), ((G.induce (U : Set V)).degree x : ℝ) ≤ D) ∧ (G.induce (U : Set V)).CliqueFree 3 := by let X (f : V → Bool) : ℝ := (selected f).card - degreeMass G (selected f) / D - count (G.cliqueFinset 3) (selected f) have hmean : (∑ f, weight p f * X f) = p * Fintype.card V - p^2 * (∑ x, (G.degree x : ℝ)) / D - p^3 * (G.cliqueFinset 3).card := by simp only [X, mul_sub, ← mul_div_assoc, sum_sub_distrib, ← sum_div] rw [size_moment, degreeMass_moment, family_moment] intro A hA exact (SimpleGraph.mem_cliqueFinset_iff.mp hA).2 obtain ⟨f, hf⟩ := exists_ge_mean hp hp1 X rw [hmean] at hf obtain ⟨U, _hUS, hU, hdeg, htri⟩ := prune G (selected f) hD refine ⟨U, hf.trans hU, ?_, htri⟩ intro x rw [induced_degree] exact hdeg x x.2
theorem triangle_count_le {h m : ℕ} (hdeg : ∀ x, G.degree x ≤ h) (hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m) : (G.cliqueFinset 3).card ≤ Fintype.card V * h * m := by let T := Σ x : V, Σ y : G.neighborSet x, G.commonNeighbors x y have hex (A : {A // A ∈ G.cliqueFinset 3}) : ∃ t : T, A.1 = {t.1, t.2.1.1, t.2.2.1} := by obtain ⟨x,y,z,hxy,hxz,hyz,hA⟩ := SimpleGraph.is3Clique_iff.mp (SimpleGraph.mem_cliqueFinset_iff.mp A.2) exact ⟨⟨x, ⟨y,hxy⟩, ⟨z,hxz,hyz⟩⟩, hA⟩ choose f hf using hex have hinj : Function.Injective f := by intro A B hAB apply Subtype.ext rw [hf A, hf B, hAB] calc (G.cliqueFinset 3).card = Fintype.card {A // A ∈ G.cliqueFinset 3} := (Fintype.card_coe _).symm _ ≤ Fintype.card T := Fintype.card_le_of_injective f hinj _ = ∑ x : V, ∑ y : G.neighborSet x, Fintype.card (G.commonNeighbors x y) := by simp [T, Fintype.card_sigma] _ ≤ ∑ x : V, ∑ _y : G.neighborSet x, m := by exact sum_le_sum (fun x _ => sum_le_sum (fun y _ => hcommon x y y.2)) _ ≤ ∑ _x : V, h*m := by apply sum_le_sum intro x _ simpa [G.card_neighborSet_eq_degree] using Nat.mul_le_mul_right m (hdeg x) _ = Fintype.card V * h * m := by simp [mul_assoc]
end SharpLogRamsey.Sampling
open scoped BigOperatorsnamespace SharpLogRamsey.Upper
end SharpLogRamsey.Upperend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452import Mathlibimport OAI.Combinatorics.SharpRamsey.Modelimport OAI.Combinatorics.SharpRamsey.Geometry.SpanPairLine
namespace OAI
/-! The off-diagonal Ramsey upper bound. -/
sectionopen scoped BigOperators Classicalopen Finsetnamespace SharpLogRamsey
namespace Foundationvariable {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
omit [Fintype V] [DecidableEq V] intheorem indepNum_lt_of_cliqueFree_compl {t : ℕ} (ht : Gᶜ.CliqueFree t) : G.indepNum < t := by by_contra! h obtain ⟨A, hA⟩ := G.exists_isNIndepSet_indepNum exact (ht.mono h) A (G.isNClique_compl.mpr hA)
omit [DecidableEq V] intheorem maximum_indep_dominates {A : Finset V} (hA : G.IsMaximumIndepSet A) (x : V) : x ∈ A ∨ ∃ y ∈ A, G.Adj x y := by by_contra! hn have hi : G.IsIndepSet ((insert x A : Finset V) : Set V) := by intro u hu v hv huv simp only [mem_coe, mem_insert] at hu hv rcases hu with rfl | hu <;> rcases hv with rfl | hv · simp · exact hn.2 v hv · exact fun h => hn.2 u hu h.symm · exact hA.1 hu hv huv have hc := hA.2 (insert x A) hi rw [card_insert_of_notMem hn.1] at hc omega
theorem card_le_mul_indepNum {B : ℕ} (hdeg : ∀ x, G.degree x + 1 ≤ B) : Fintype.card V ≤ B * G.indepNum := by obtain ⟨A, hA⟩ := G.maximumIndepSet_exists have hcover : (univ : Finset V) ⊆ A.biUnion (fun x => insert x (G.neighborFinset x)) := by intro v _ obtain hv | ⟨x, hx, hadj⟩ := maximum_indep_dominates G hA v · exact mem_biUnion.mpr ⟨v, hv, by simp⟩ · exact mem_biUnion.mpr ⟨x, hx, by simp [hadj.symm]⟩ calc Fintype.card V = (univ : Finset V).card := (card_univ).symm _ ≤ (A.biUnion (fun x => insert x (G.neighborFinset x))).card := card_le_card hcover _ ≤ ∑ x ∈ A, (insert x (G.neighborFinset x)).card := card_biUnion_le _ ≤ ∑ _x ∈ A, B := by apply sum_le_sum intro x _ simpa using hdeg x _ = B * G.indepNum := by simp [G.maximumIndepSet_card_eq_indepNum A hA, mul_comm]
omit [Fintype V] [DecidableEq V] intheorem cliqueFree_neighbor {s : ℕ} (hs : G.CliqueFree (s+1)) (x : V) : (G.induce (G.neighborSet x)).CliqueFree s := by rw [G.cliqueFree_induce_iff] have hc : G.CliqueFreeOn Set.univ (s+1) := (G.cliqueFreeOn_univ).mpr hs simpa using SimpleGraph.CliqueFreeOn.of_succ G hc (a := x) (Set.mem_univ x)
omit [Fintype V] [DecidableEq V] intheorem cliqueFree_induce {s : ℕ} (hs : G.CliqueFree s) (U : Set V) : (G.induce U).CliqueFree s := by rw [G.cliqueFree_induce_iff] intro A _ hA exact hs A hAomit [Fintype V] [DecidableEq V] in
theorem compl_cliqueFree_induce {t : ℕ} (ht : Gᶜ.CliqueFree t) (U : Set V) : (G.induce U)ᶜ.CliqueFree t := by have he : (G.induce U)ᶜ = Gᶜ.induce U := by ext u v; simp [Subtype.val_inj] rw [he] exact cliqueFree_induce Gᶜ ht U
theorem order_avoiding_lt_pow (n : ℕ) {t : ℕ} (ht : 1 ≤ t) : ∀ {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V), G.CliqueFree (n+2) → Gᶜ.CliqueFree t → Fintype.card V < t^(n+1) := by induction n with | zero => intro V _ _ G hs hi have hg : G = ⊥ := G.cliqueFree_two.mp hs have hn := card_le_mul_indepNum G (B := 1) (by intro x; simp [hg]) have hh := indepNum_lt_of_cliqueFree_compl G hi simpa using hn.trans_lt (by simpa using hh) | succ n ih => intro V _ _ G hs hi have hd : ∀ x, G.degree x + 1 ≤ t^(n+1) := by intro x have hc := cliqueFree_neighbor G (s := n+2) (by simpa [Nat.add_assoc] using hs) x have hci := compl_cliqueFree_induce G hi (G.neighborSet x) have hh := ih (G.induce (G.neighborSet x)) hc hci rw [G.card_neighborSet_eq_degree] at hh omega have hn := card_le_mul_indepNum G hd have hi' := indepNum_lt_of_cliqueFree_compl G hi have hp : 0 < t^(n+1) := pow_pos (by omega) _ have hm := Nat.mul_lt_mul_of_pos_left hi' hp calc Fintype.card V ≤ t^(n+1) * G.indepNum := hn _ < t^(n+1) * t := hm _ = t^(n+1+1) := (pow_succ _ _).symm
theorem ramseyProperty_pow (n : ℕ) {t : ℕ} (ht : 1 ≤ t) : RamseyProperty (n+2) t (t^(n+1)) := by intro G by_cases hs : G.CliqueFree (n+2) · right by_contra! hi have hh := order_avoiding_lt_pow n ht G hs hi simp at hh · left simpa only [SimpleGraph.CliqueFree, not_forall, not_not] using hs
theorem ramseyProperty_nonempty {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : {N | RamseyProperty s t N}.Nonempty := by obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le hs exact ⟨t^(n+1), by simpa [Nat.add_comm] using ramseyProperty_pow n ht⟩
theorem ramsey_has_property {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : RamseyProperty s t (ramsey s t) := Nat.sInf_mem (ramseyProperty_nonempty hs ht)
omit [Fintype V] [DecidableEq V] in theorem clique_map_embedding {U : Type*} (f : U ↪ V) {n : ℕ} {A : Finset U} (hA : (G.comap f).IsNClique n A) : G.IsNClique n (A.map f) := by constructor · intro u hu v hv huv obtain ⟨a, ha, rfl⟩ := mem_map.mp hu obtain ⟨b, hb, rfl⟩ := mem_map.mp hv exact hA.1 ha hb (fun h => huv (congrArg f h)) · simpa using hA.2
omit [Fintype V] [DecidableEq V] in theorem compl_comap_embedding {U : Type*} (f : U ↪ V) : (G.comap f)ᶜ = Gᶜ.comap f := by ext u v simp [SimpleGraph.comap_adj, f.injective.eq_iff]
omit [DecidableEq V] intheorem property_for_finite_type {s t N : ℕ} (hN : RamseyProperty s t N) (hcard : N ≤ Fintype.card V) : (∃ A, G.IsNClique s A) ∨ (∃ B, Gᶜ.IsNClique t B) := by obtain ⟨f⟩ := Function.Embedding.nonempty_of_card_le (α := Fin N) (β := V) (by simpa using hcard) obtain ⟨A, hA⟩ | ⟨B, hB⟩ := hN (G.comap f) · exact Or.inl ⟨A.map f, clique_map_embedding G f hA⟩ · rw [compl_comap_embedding G f] at hB exact Or.inr ⟨B.map f, clique_map_embedding Gᶜ f hB⟩omit [DecidableEq V] in
theorem order_lt_ramsey {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) (hGs : G.CliqueFree s) (hGt : Gᶜ.CliqueFree t) : Fintype.card V < ramsey s t := by by_contra! h obtain ⟨A, hA⟩ | ⟨B, hB⟩ := property_for_finite_type G (ramsey_has_property hs ht) h · exact hGs A hA · exact hGt B hB
theorem ramsey_le_of_property {s t N : ℕ} (hN : RamseyProperty s t N) : ramsey s t ≤ N := Nat.sInf_le hN
theorem property_mono {s t N M : ℕ} (hN : RamseyProperty s t N) (hNM : N ≤ M) : RamseyProperty s t M := by intro G exact property_for_finite_type G hN (by simpa using hNM)
theorem ramsey_le_pow {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : ramsey s t ≤ t^(s-1) := by obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le hs have hh := ramsey_le_of_property (ramseyProperty_pow n ht) simpa [Nat.add_comm] using hh
theorem le_ramsey {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : t ≤ ramsey s t := by obtain ⟨A,hA⟩ | ⟨B,hB⟩ := ramsey_has_property hs ht (⊥ : SimpleGraph (Fin (ramsey s t))) · exact False.elim ((SimpleGraph.cliqueFree_bot (by omega : 1 < s)) A hA) · have hb := card_le_card (subset_univ B) simpa [hB.2] using hb
theorem ramsey_two {t : ℕ} (ht : 1 ≤ t) : ramsey 2 t = t := by apply Nat.le_antisymm · simpa using ramsey_le_pow (s := 2) (by omega) ht · exact le_ramsey (by omega) ht
omit [Fintype V] [DecidableEq V] intheorem cliqueFree_common {s : ℕ} (hs : G.CliqueFree (s+2)) {x y : V} (hxy : G.Adj x y) : (G.induce (G.commonNeighbors x y)).CliqueFree s := by rw [G.cliqueFree_induce_iff] have hc : G.CliqueFreeOn Set.univ (s+2) := (G.cliqueFreeOn_univ).mpr hs have hn : G.CliqueFreeOn (G.neighborSet x) (s+1) := by simpa using SimpleGraph.CliqueFreeOn.of_succ G hc (a := x) (Set.mem_univ x) exact SimpleGraph.CliqueFreeOn.of_succ G hn hxy
theorem exists_avoiding_pred {s t : ℕ} (hs : 2 ≤ s) (ht : 2 ≤ t) : ∃ G : SimpleGraph (Fin (ramsey s t - 1)), G.CliqueFree s ∧ Gᶜ.CliqueFree t := by have hr : 2 ≤ ramsey s t := ht.trans (le_ramsey hs (by omega)) have hn : ¬ RamseyProperty s t (ramsey s t - 1) := by intro h have hh := ramsey_le_of_property h omega simp only [RamseyProperty, not_forall, not_or, not_exists] at hn exact hn
end Foundationend SharpLogRamsey
open scoped BigOperators Classicalopen Finsetnamespace SharpLogRamsey.TriangleFreevariable {V : Type*} [Fintype V] [DecidableEq V]variable (G : SimpleGraph V)
noncomputable def independentSets : Finset (Finset V) := univ.filter (fun S => G.IsIndepSet (S : Set V))
@[simp] theorem mem_independentSets (S : Finset V) : S ∈ independentSets G ↔ G.IsIndepSet (S : Set V) := by simp [independentSets]
theorem independentSets_nonempty : (independentSets G).Nonempty := by refine ⟨∅, ?_⟩ simp [SimpleGraph.IsIndepSet]
noncomputable def closed (x : V) : Finset V := insert x (G.neighborFinset x)noncomputable def outside (x : V) (S : Finset V) : Finset V := S \ closed G xnoncomputable def available (x : V) (J : Finset V) : Finset V := (G.neighborFinset x).filter (fun u => ∀ v ∈ J, ¬G.Adj u v)noncomputable def fiber (x : V) (J : Finset V) : Finset (Finset V) := (independentSets G).filter (fun S => outside G x S = J)
def Admissible (x : V) (J : Finset V) : Prop := G.IsIndepSet (J : Set V) ∧ Disjoint J (closed G x)
@[simp] theorem mem_closed (x u : V) : u ∈ closed G x ↔ u = x ∨ G.Adj x u := by simp [closed]@[simp] theorem mem_outside (x u : V) (S : Finset V) : u ∈ outside G x S ↔ u ∈ S ∧ u ≠ x ∧ ¬G.Adj x u := by simp [outside]@[simp] theorem mem_available (x u : V) (J : Finset V) : u ∈ available G x J ↔ G.Adj x u ∧ ∀ v ∈ J, ¬G.Adj u v := by simp [available]
@[simp] theorem center_not_available (x : V) (J : Finset V) : x ∉ available G x J := by simp
theorem admissible_outside (x : V) {S : Finset V} (hS : S ∈ independentSets G) : Admissible G x (outside G x S) := by constructor · exact (mem_independentSets G S |>.mp hS).mono (by intro u hu; exact (mem_outside G x u S |>.mp hu).1) · exact disjoint_left.mpr (fun u hu hc => (Finset.mem_sdiff.mp hu).2 hc)
theorem admissible_not_center {x : V} {J : Finset V} (hJ : Admissible G x J) : x ∉ J := by intro hx exact disjoint_left.mp hJ.2 hx (by simp)
theorem admissible_not_adj {x u : V} {J : Finset V} (hJ : Admissible G x J) (hu : u ∈ J) : ¬G.Adj x u := by intro h exact disjoint_left.mp hJ.2 hu (by simp [h])
theorem available_disjoint {x : V} {J : Finset V} (hJ : Admissible G x J) : Disjoint J (available G x J) := by apply disjoint_left.mpr intro u hJ' hu exact admissible_not_adj G hJ hJ' (mem_available G x u J |>.mp hu).1
theorem independent_insert_center {x : V} {J : Finset V} (hJ : Admissible G x J) : G.IsIndepSet ((insert x J : Finset V) : Set V) := by intro u hu v hv huv simp only [mem_coe, mem_insert] at hu hv rcases hu with rfl | hu · rcases hv with rfl | hv · simp · exact admissible_not_adj G hJ hv · rcases hv with rfl | hv · exact fun h => admissible_not_adj G hJ hu h.symm · exact hJ.1 hu hv huv
theorem independent_extend (htri : G.CliqueFree 3) {x : V} {J K : Finset V} (hJ : Admissible G x J) (hK : K ⊆ available G x J) : G.IsIndepSet ((J ∪ K : Finset V) : Set V) := by intro u hu v hv huv simp only [mem_coe, mem_union] at hu hv rcases hu with hu | hu <;> rcases hv with hv | hv · exact hJ.1 hu hv huv · exact fun h => (mem_available G x v J |>.mp (hK hv)).2 u hu h.symm · exact (mem_available G x u J |>.mp (hK hu)).2 v hv · exact (G.isIndepSet_neighborSet_of_triangleFree htri x) (mem_available G x u J |>.mp (hK hu)).1 (mem_available G x v J |>.mp (hK hv)).1 huv
theorem outside_insert_center {x : V} {J : Finset V} (hJ : Admissible G x J) : outside G x (insert x J) = J := by ext u simp only [mem_outside, mem_insert] constructor · rintro ⟨h, hne, _⟩ exact h.resolve_left hne · intro hu exact ⟨Or.inr hu, fun h => admissible_not_center G hJ (h ▸ hu), admissible_not_adj G hJ hu⟩
theorem outside_extend {x : V} {J K : Finset V} (hJ : Admissible G x J) (hK : K ⊆ available G x J) : outside G x (J ∪ K) = J := by ext u simp only [mem_outside, mem_union] constructor · rintro ⟨hu | hu, _, hna⟩ · exact hu · exact False.elim (hna (mem_available G x u J |>.mp (hK hu)).1) · intro hu exact ⟨Or.inl hu, fun h => admissible_not_center G hJ (h ▸ hu), admissible_not_adj G hJ hu⟩
theorem fiber_eq (htri : G.CliqueFree 3) {x : V} {J : Finset V} (hJ : Admissible G x J) : fiber G x J = insert (insert x J) ((available G x J).powerset.image (fun K => J ∪ K)) := by ext S simp only [fiber, mem_filter, mem_independentSets, mem_insert, mem_image, mem_powerset] constructor · rintro ⟨hS, hout⟩ by_cases hx : x ∈ S · left ext u simp only [mem_insert] constructor · intro hu by_cases hux : u = x · exact Or.inl hux · right rw [← hout, mem_outside] exact ⟨hu, hux, hS hx hu (Ne.symm hux)⟩ · rintro (rfl | hu) · exact hx · rw [← hout, mem_outside] at hu exact hu.1 · right refine ⟨S ∩ G.neighborFinset x, ?_, ?_⟩ · intro u hu simp only [mem_inter, SimpleGraph.mem_neighborFinset] at hu apply (mem_available G x u J).mpr refine ⟨hu.2, ?_⟩ intro v hv hadj have hvS : v ∈ S := by rw [← hout, mem_outside] at hv; exact hv.1 exact hS hu.1 hvS hadj.ne hadj · ext u simp only [mem_union, mem_inter, SimpleGraph.mem_neighborFinset] constructor · rintro (hu | hu) · rw [← hout, mem_outside] at hu; exact hu.1 · exact hu.1 · intro hu by_cases hax : G.Adj x u · exact Or.inr ⟨hu, hax⟩ · left rw [← hout, mem_outside] exact ⟨hu, fun h => hx (h ▸ hu), hax⟩ · rintro (rfl | ⟨K, hK, rfl⟩) · exact ⟨independent_insert_center G hJ, outside_insert_center G hJ⟩ · exact ⟨independent_extend G htri hJ hK, outside_extend G hJ hK⟩
theorem extend_injective {x : V} {J : Finset V} (hJ : Admissible G x J) : Set.InjOn (fun K => J ∪ K) ((available G x J).powerset : Set (Finset V)) := by intro K hK L hL heq have hdK : Disjoint J K := (available_disjoint G hJ).mono_right (mem_powerset.mp hK) have hdL : Disjoint J L := (available_disjoint G hJ).mono_right (mem_powerset.mp hL) simpa [union_sdiff_cancel_left hdK, union_sdiff_cancel_left hdL] using congrArg (fun S => S \ J) heq
theorem center_choice_not_image {x : V} {J : Finset V} (hJ : Admissible G x J) : insert x J ∉ (available G x J).powerset.image (fun K => J ∪ K) := by rintro h obtain ⟨K, hK, heq⟩ := mem_image.mp h have hx : x ∈ J ∪ K := heq ▸ mem_insert_self x J rcases mem_union.mp hx with hx | hx · exact admissible_not_center G hJ hx · exact center_not_available G x J (mem_powerset.mp hK hx)
theorem card_fiber (htri : G.CliqueFree 3) {x : V} {J : Finset V} (hJ : Admissible G x J) : (fiber G x J).card = 1 + 2^(available G x J).card := by rw [fiber_eq G htri hJ, card_insert_of_notMem (center_choice_not_image G hJ), card_image_of_injOn (extend_injective G hJ), card_powerset] omega
theorem sum_fiber (htri : G.CliqueFree 3) {x : V} {J : Finset V} (hJ : Admissible G x J) (f : Finset V → ℝ) : ∑ S ∈ fiber G x J, f S = f (insert x J) + ∑ K ∈ (available G x J).powerset, f (J ∪ K) := by rw [fiber_eq G htri hJ, sum_insert (center_choice_not_image G hJ), sum_image (extend_injective G hJ)]
omit [Fintype V] in
theorem twice_sum_powerset_card (A : Finset V) : 2 * (∑ K ∈ A.powerset, (K.card : ℝ)) = A.card * (2:ℝ)^A.card := by have hc : ∑ K ∈ A.powerset, ((A \ K).card : ℝ) = ∑ K ∈ A.powerset, (K.card : ℝ) := by apply sum_bij (fun K _ => A \ K) · intro K _; exact mem_powerset.mpr sdiff_subset · intro K hK L hL heq have := congrArg (fun X => A \ X) heq simpa [Finset.sdiff_sdiff_eq_self (mem_powerset.mp hK), Finset.sdiff_sdiff_eq_self (mem_powerset.mp hL)] using this · intro K hK exact ⟨A \ K, mem_powerset.mpr sdiff_subset, Finset.sdiff_sdiff_eq_self (mem_powerset.mp hK)⟩ · intro K _; rfl have hsum : ∑ K ∈ A.powerset, (((A \ K).card : ℝ) + K.card) = A.card * (2:ℝ)^A.card := by calc _ = ∑ _K ∈ A.powerset, (A.card : ℝ) := by apply sum_congr rfl intro K hK exact_mod_cast card_sdiff_add_card_eq_card (mem_powerset.mp hK) _ = _ := by simp [card_powerset]; ring rw [sum_add_distrib, hc] at hsum linarith
theorem center_neighbor_inter {x : V} {J : Finset V} (hJ : Admissible G x J) : insert x J ∩ G.neighborFinset x = ∅ := by apply eq_empty_iff_forall_notMem.mpr intro u hu simp only [mem_inter, mem_insert, SimpleGraph.mem_neighborFinset] at hu rcases hu.1 with rfl | huJ · exact G.irrefl hu.2 · exact admissible_not_adj G hJ huJ hu.2
theorem extend_neighbor_inter {x : V} {J K : Finset V} (hJ : Admissible G x J) (hK : K ⊆ available G x J) : (J ∪ K) ∩ G.neighborFinset x = K := by ext u simp only [mem_inter, mem_union, SimpleGraph.mem_neighborFinset] constructor · rintro ⟨hu | hu, hadj⟩ · exact False.elim (admissible_not_adj G hJ hu hadj) · exact hu · intro hu exact ⟨Or.inr hu, (mem_available G x u J |>.mp (hK hu)).1⟩
end SharpLogRamsey.TriangleFreeend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import Mathlib
namespace OAI
sectionnamespace SharpLogRamsey.FiniteStreamTailopen Finset Realopen scoped Classical BigOperatorsnoncomputable sectionvariable {α : Type*} [Fintype α]
def hits {N : ℕ} (S : Finset α) (z : Fin N→α) : ℕ := (univ.filter (fun i=>z i∈S)).card
def probability (S : Finset α) : ℝ := (S.card:ℝ)/(Fintype.card α:ℝ)
lemma moment (S : Finset α) (N : ℕ) : (∑ z : Fin N→α,(2:ℝ)^hits S z)= ((Fintype.card α:ℝ)+(S.card:ℝ))^N := by have hp (z : Fin N→α) : (2:ℝ)^hits S z=∏ i,if z i∈S then (2:ℝ) else 1 := by simp only [prod_ite,hits,prod_const,one_pow,mul_one] have hs : (∑ a : α,if a∈S then (2:ℝ) else 1)=(Fintype.card α:ℝ)+(S.card:ℝ) := by have he (a : α) : (if a∈S then (2:ℝ) else 1)=1+(if a∈S then 1 else 0) := by split_ifs <;> norm_num simp only [he,sum_add_distrib,sum_const,card_univ,nsmul_eq_mul,mul_one, Fintype.sum_ite_mem,sum_const] simp_rw [hp] rw [←Fintype.prod_sum (fun (_ : Fin N) (a : α)=>if a∈S then (2:ℝ) else 1)] simp only [hs,prod_const,card_univ,Fintype.card_fin]
variable [Nonempty α]
lemma card_pos : (0:ℝ)<Fintype.card α := by exact_mod_cast Fintype.card_pos
lemma average_moment (S : Finset α) (N : ℕ) : (∑ z : Fin N→α,(2:ℝ)^hits S z)/(Fintype.card (Fin N→α):ℝ) = (1+probability S)^N := by rw [moment] simp only [Fintype.card_fun,Fintype.card_fin,Nat.cast_pow,←div_pow,probability] congr 1 rw [add_div,div_self (ne_of_gt (card_pos (α:=α)))]
lemma average_moment_le (S : Finset α) (N : ℕ) : (∑ z : Fin N→α,(2:ℝ)^hits S z)/(Fintype.card (Fin N→α):ℝ) ≤ exp (N*probability S) := by rw [average_moment,exp_nat_mul] apply pow_le_pow_left₀ · exact add_nonneg zero_le_one (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) · simpa only [add_comm] using Real.add_one_le_exp (probability S)
lemma single_tail (S : Finset α) (N : ℕ) (t : ℝ) : probability (univ.filter (fun z : Fin N→α=>t≤hits S z)) ≤ exp (N*probability S-t*log 2) := by let B := univ.filter (fun z : Fin N→α=>t≤hits S z) have hsum : (B.card:ℝ)*exp (t*log 2)≤∑ z : Fin N→α,(2:ℝ)^hits S z := by calc _ = ∑ _z∈B,exp (t*log 2) := by simp _ ≤ ∑ z∈B,(2:ℝ)^hits S z := by apply sum_le_sum intro z hz have ht := (mem_filter.mp hz).2 have he : exp ((hits S z:ℝ)*log 2)=(2:ℝ)^hits S z := by rw [exp_nat_mul,exp_log (by norm_num)] rw [←he] apply exp_le_exp.mpr exact mul_le_mul_of_nonneg_right ht (log_nonneg (by norm_num)) _ ≤ _ := sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun _ _ _=>by positivity) have hdiv := div_le_div_of_nonneg_right hsum (Nat.cast_nonneg (Fintype.card (Fin N→α))) have hm := average_moment_le S N have hb : probability B*exp (t*log 2)≤exp (N*probability S) := by unfold probability calc _ = (B.card*exp (t*log 2))/(Fintype.card (Fin N→α):ℝ) := by ring _ ≤ _ := hdiv.trans hm have hh := (le_div_iff₀ (exp_pos (t*log 2))).mpr hb simpa only [exp_sub] using hh
lemma probability_univ : probability (univ : Finset α)=1 := by simp only [probability,card_univ] exact div_self (ne_of_gt (card_pos (α:=α)))
lemma probability_compl (S : Finset α) : probability Sᶜ=1-probability S := by simp only [probability,Finset.card_compl,Nat.cast_sub (card_le_univ S),sub_div, div_self (ne_of_gt (card_pos (α:=α)))]
omit [Nonempty α] [Fintype α] inlemma hits_embedding {N n : ℕ} (S : Finset α) (z : Fin N→α) (e : Fin n↪Fin N) : hits S (z∘e)≤hits S z := by let A := univ.filter (fun i : Fin n=>z (e i)∈S) have he : A.map e⊆univ.filter (fun i : Fin N=>z i∈S) := by intro i hi obtain ⟨j,hj,rfl⟩ := mem_map.mp hi exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hj).2⟩ simpa only [card_map,A,hits,Function.comp_def] using card_le_card he
variable {J : Type*} [Fintype J]
theorem simultaneous_tail (R : J→Finset α) (N : ℕ) (t μ : ℝ) (hμ : ∀ j,(N:ℝ)*probability (R j)≤μ) : probability (univ.filter (fun z : Fin N→α=>∃ j,t≤hits (R j) z)) ≤ (Fintype.card J:ℝ)*exp (μ-t*log 2) := by let B := fun j=>univ.filter (fun z : Fin N→α=>t≤hits (R j) z) have he : (univ.filter (fun z : Fin N→α=>∃ j,t≤hits (R j) z))= univ.biUnion B := by ext z; simp [B] rw [he] have hc : ((univ.biUnion B).card:ℝ)≤∑ j,((B j).card:ℝ) := by exact_mod_cast (card_biUnion_le (s:=univ) (t:=B)) calc _ ≤ (∑ j,((B j).card:ℝ))/(Fintype.card (Fin N→α):ℝ) := div_le_div_of_nonneg_right hc (by positivity) _ = ∑ j,probability (B j) := by rw [sum_div]; rfl _ ≤ ∑ _j : J,exp (μ-t*log 2) := by apply sum_le_sum intro j _ exact (single_tail (R j) N t).trans (exp_le_exp.mpr (sub_le_sub_right (hμ j) _)) _ = _ := by simp
endend SharpLogRamsey.FiniteStreamTail
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217import Mathlibimport OAI.Combinatorics.SharpRamsey.Marking.Popular
namespace OAI
sectionnamespace SharpLogRamsey
section LinearAlgebravariable {K V : Type*} [Field K] [AddCommGroup V] [Module K V]
theorem flag_vectors_independent {m : ℕ} (a : Fin m → V) (b : Fin m → Module.Dual K V) (ha : ∀ i, a i ≠ 0) (hz : ∀ i j, i ≤ j → b j (a i) = 0) (hn : ∀ i j, i < j → b i (a j) ≠ 0) : LinearIndependent K a := by induction m with | zero => exact linearIndependent_empty_type | succ m ih => apply linearIndependent_finSucc'.mpr refine ⟨ih (Fin.init a) (Fin.init b) (fun i => ha i.castSucc) (fun i j h => hz i.castSucc j.castSucc h) (fun i j h => hn i.castSucc j.castSucc h), ?_⟩ cases m with | zero => simpa using ha (Fin.last 0) | succ n => intro hmem let j : Fin (n + 1 + 1) := (Fin.last n).castSucc have hspan : Submodule.span K (Set.range (Fin.init a)) ≤ LinearMap.ker (b j) := by apply Submodule.span_le.mpr rintro _ ⟨i, rfl⟩ exact hz i.castSucc j (by simpa [j] using Fin.le_last i) have hzero : b j (a (Fin.last (n + 1))) = 0 := hspan hmem exact hn j (Fin.last (n + 1)) (by simp [j]) hzero
theorem flag_length_lt_finrank [FiniteDimensional K V] {m : ℕ} (a : Fin (m+1) → V) (b : Fin (m+1) → Module.Dual K V) (ha : ∀ i, a i ≠ 0) (hb : b (Fin.last m) ≠ 0) (hz : ∀ i j, i ≤ j → b j (a i) = 0) (hn : ∀ i j, i < j → b i (a j) ≠ 0) : m + 1 < Module.finrank K V := by let W := LinearMap.ker (b (Fin.last m)) let a' : Fin (m+1) → W := fun i => ⟨a i, hz i (Fin.last m) (Fin.le_last i)⟩ have hli : LinearIndependent K a' := LinearIndependent.of_comp W.subtype (flag_vectors_independent a b ha hz hn) have hle : m + 1 ≤ Module.finrank K W := by simpa using hli.fintype_card_le_finrank have hproper : W ≠ ⊤ := by exact fun h => hb (LinearMap.ker_eq_top.mp h) exact hle.trans_lt (Submodule.finrank_lt hproper)
end LinearAlgebra
section Flagsvariable (K V : Type*) [Field K] [AddCommGroup V] [Module K V]
theorem incident_iff_submodule (a : Projectivization K V) (b : Projectivization K (Module.Dual K V)) : Incident K V a b ↔ a.submodule ≤ LinearMap.ker b.rep := by rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem] rfl
def flagGraph {N : ℕ} (F : Fin N → Flag K V) : SimpleGraph (Fin N) where Adj i j := (i < j ∧ Incident K V (F i).point (F j).dualPoint ∧ ¬ Incident K V (F j).point (F i).dualPoint) ∨ (j < i ∧ Incident K V (F j).point (F i).dualPoint ∧ ¬ Incident K V (F i).point (F j).dualPoint) symm := ⟨fun _ _ h => h.symm⟩ loopless := ⟨fun i => by simp⟩
variable {K V}
theorem flagGraph_adj_of_lt {N : ℕ} (F : Fin N → Flag K V) {i j : Fin N} (hij : i < j) : (flagGraph K V F).Adj i j ↔ Incident K V (F i).point (F j).dualPoint ∧ ¬ Incident K V (F j).point (F i).dualPoint := by simp only [flagGraph, hij, true_and, not_lt_of_ge hij.le, false_and, or_false]
theorem flagGraph_cliqueFree [FiniteDimensional K V] {d N : ℕ} (hdim : Module.finrank K V = d+1) (F : Fin N → Flag K V) : (flagGraph K V F).CliqueFree (d+1) := by intro S hS let e := S.orderEmbOfFin hS.card_eq let a : Fin (d+1) → V := fun i => (F (e i)).point.rep let b : Fin (d+1) → Module.Dual K V := fun i => (F (e i)).dualPoint.rep have hedge (i j : Fin (d+1)) (h : i < j) : Incident K V (F (e i)).point (F (e j)).dualPoint ∧ ¬ Incident K V (F (e j)).point (F (e i)).dualPoint := by apply (flagGraph_adj_of_lt F (e.strictMono h)).mp exact hS.isClique (S.orderEmbOfFin_mem hS.card_eq i) (S.orderEmbOfFin_mem hS.card_eq j) (ne_of_lt (e.strictMono h)) have hz : ∀ i j, i ≤ j → b j (a i) = 0 := by intro i j h rcases lt_or_eq_of_le h with hlt | rfl · exact (hedge i j hlt).1 · exact (F (e i)).incident have hn : ∀ i j, i < j → b i (a j) ≠ 0 := by intro i j h exact (hedge i j h).2 have hlt := flag_length_lt_finrank a b (fun i => (F (e i)).point.rep_nonzero) (F (e (Fin.last d))).dualPoint.rep_nonzero hz hn omega
theorem consistent_iff_no_edges {N : ℕ} (F : Fin N → Flag K V) : Consistent F ↔ ∀ i j, ¬ (flagGraph K V F).Adj i j := by constructor · intro h i j hadj rcases hadj with ⟨hij, hinc, hnot⟩ | ⟨hji, hinc, hnot⟩ · exact hnot (h i j hij hinc) · exact hnot (h j i hji hinc) · intro h i j hij hinc by_contra hnot exact h i j ((flagGraph_adj_of_lt F hij).mpr ⟨hinc, hnot⟩)
def ConsistentOn {N : ℕ} (F : Fin N → Flag K V) (S : Finset (Fin N)) : Prop := ∀ i ∈ S, ∀ j ∈ S, i < j → Incident K V (F i).point (F j).dualPoint → Incident K V (F j).point (F i).dualPoint
theorem consistentOn_iff_compl_isClique {N : ℕ} (F : Fin N → Flag K V) (S : Finset (Fin N)) : ConsistentOn F S ↔ (flagGraph K V F)ᶜ.IsClique S := by constructor · intro h i hi j hj hne rw [SimpleGraph.compl_adj] refine ⟨hne, ?_⟩ rintro (⟨hij, hinc, hnot⟩ | ⟨hji, hinc, hnot⟩) · exact hnot (h i hi j hj hij hinc) · exact hnot (h j hj i hi hji hinc) · intro h i hi j hj hij hinc have hnot := ((flagGraph K V F).compl_adj i j).mp (h hi hj (ne_of_lt hij)) by_contra hrev exact hnot.2 ((flagGraph_adj_of_lt F hij).mpr ⟨hinc, hrev⟩)
noncomputable def projectiveSubmoduleEquiv (W : Submodule K V) : Projectivization K W ≃ {a : Projectivization K V // a.submodule ≤ W} := by let f : Projectivization K W → {a : Projectivization K V // a.submodule ≤ W} := fun a => ⟨Projectivization.map W.subtype W.injective_subtype a, by induction a using Projectivization.ind with | h v hv => rw [Projectivization.map_mk, Projectivization.submodule_mk, Submodule.span_singleton_le_iff_mem] exact v.property⟩ apply Equiv.ofBijective f constructor · intro a b h exact Projectivization.map_injective W.subtype W.injective_subtype (congrArg Subtype.val h) · rintro ⟨a, ha⟩ have hmem : a.rep ∈ W := ha (by rw [Projectivization.submodule_eq] exact Submodule.mem_span_singleton_self _) let v : W := ⟨a.rep, hmem⟩ have hv : v ≠ 0 := fun h => a.rep_nonzero (congrArg Subtype.val h) refine ⟨Projectivization.mk K v hv, ?_⟩ apply Subtype.ext exact a.mk_rep
theorem card_incident_points [Finite K] [FiniteDimensional K V] {d : ℕ} (hdim : Module.finrank K V = d+1) (b : Projectivization K (Module.Dual K V)) : Nat.card {a : Projectivization K V // Incident K V a b} = ∑ i ∈ Finset.range d, Nat.card K ^ i := by let e : {a : Projectivization K V // Incident K V a b} ≃ {a : Projectivization K V // a.submodule ≤ LinearMap.ker b.rep} := Equiv.subtypeEquivRight (fun a => incident_iff_submodule K V a b) rw [Nat.card_congr e, ← Nat.card_congr (projectiveSubmoduleEquiv (LinearMap.ker b.rep))] apply Projectivization.card_of_finrank have h := Module.Dual.finrank_ker_add_one_of_ne_zero b.rep_nonzero omega
theorem card_flags [Finite K] [FiniteDimensional K V] {d : ℕ} (hdim : Module.finrank K V = d+1) : Nat.card (Flag K V) = (∑ i ∈ Finset.range (d+1), Nat.card K ^ i) * (∑ i ∈ Finset.range d, Nat.card K ^ i) := by classical let : Finite V := Finite.of_injective (Module.finBasis K V).equivFun (Module.finBasis K V).equivFun.injective let : Finite (Module.Dual K V) := Finite.of_injective (Module.finBasis K (Module.Dual K V)).equivFun (Module.finBasis K (Module.Dual K V)).equivFun.injective let : Finite (Projectivization K V) := Finite.of_injective Projectivization.rep (fun a b h => by rw [← a.mk_rep, ← b.mk_rep]; congr 1) let : Finite (Projectivization K (Module.Dual K V)) := Finite.of_injective Projectivization.rep (fun a b h => by rw [← a.mk_rep, ← b.mk_rep]; congr 1) let := Fintype.ofFinite (Projectivization K (Module.Dual K V)) let e : Flag K V ≃ Σ b : Projectivization K (Module.Dual K V), {a : Projectivization K V // Incident K V a b} := { toFun := fun f => ⟨f.dualPoint, f.point, f.incident⟩ invFun := fun f => ⟨f.2.1, f.1, f.2.2⟩ left_inv := fun f => by cases f; rfl right_inv := fun f => by cases f; rfl } rw [Nat.card_congr e, Nat.card_sigma] simp_rw [card_incident_points hdim] simp only [Finset.sum_const, Finset.card_univ, smul_eq_mul] rw [← Nat.card_eq_fintype_card] rw [Projectivization.card_of_finrank K (Module.Dual K V) (Subspace.dual_finrank_eq.trans hdim)]
theorem prime_flagGraph_cliqueFree (q d N : ℕ) [Fact q.Prime] (F : Fin N → Flag (ZMod q) (Fin (d+1) → ZMod q)) : (flagGraph (ZMod q) (Fin (d+1) → ZMod q) F).CliqueFree (d+1) := by apply flagGraph_cliqueFree simp
end Flagsend SharpLogRamsey
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273import Mathlibimport OAI.Combinatorics.SharpRamsey.Parameters.FiniteIterationimport OAI.Combinatorics.SharpRamsey.Parameters.NoContextimport OAI.Combinatorics.SharpRamsey.Construction.InitialLaw
namespace OAI
sectionnamespace SharpLogRamsey.Markingopen Finset Real Filter Selection Selection.Windows ActualHighRank SourceScalesopen scoped Classical BigOperators Topologynoncomputable sectionlocal instance witnessFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injectivelocal instance witnessFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injectivelocal instance witnessProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _local instance witnessDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _local instance witnessDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _
theorem eventually_graph_witness (i : ℕ) (η : ℝ) (hη : 0 < η) (hηu : η ≤ 1) : ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) → ∀ N k : ℕ, 0 < k → k ≤ N → (k:ℝ) ≤ (q:ℝ)*σ^(1+η) → ((q:ℝ)*σ^(1+η))/2 ≤ k → (N:ℝ) ≤ (q:ℝ)^(i+3)*σ → ∃ G : SimpleGraph (Fin N),G.CliqueFree (i+4) ∧ G.indepNum < k := by let P:=max 4 (stepPrefactor (i+3)) let T:=⌈8/η⌉₊+1 let Lstar:ℝ:=(4*classCount i)^T let c:ℝ:=(1/2)/(256*classCount i)^T have hP4 : 4 ≤ P:=le_max_left _ _ have hP1 : 1 ≤ P:=by linarith have hPs : stepPrefactor (i+3) ≤ P:=le_max_right _ _ have hK : 0 < classCount i:=classCount_pos i have hLs : 0 < Lstar:=by dsimp [Lstar];positivity have hc : 0 < c:=by dsimp [c];positivity filter_upwards [eventually_iterated_context i η P (InitialExperiment.occupancyConstant i) hη hηu hP1 hPs (InitialExperiment.occupancyConstant_pos i).le, eventually_no_small_context i η c Lstar P hη hc hLs hP1] with σ hiter hnone intro q _ hq he N k hk hkn hku hklo hN by_contra! hbad have h : ∀ z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q), k ≤ (flagGraph (ZMod q) (Fin (i+4)→ZMod q) z).indepNum:=by intro z exact hbad _ (prime_flagGraph_cliqueFree q (i+3) N z) have hlog : log (q:ℝ)=σ:=by rw [←he,log_exp] have hNlog : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ):=by simpa only [hlog] using hN let Ω:=InitialExperiment.goodEvent i q N let p:=InitialExperiment.law i q N hNlog let stream : Ω→Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q):=Subtype.val let F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q):=InitialExperiment.tuple i q N k h have hdom : ∀ g,(p.map stream).mass g ≤ 2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N:= InitialExperiment.law_dom i q N hNlog have hsel : ∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x):=by intro x _ exact Or.inr (InitialExperiment.tuple_occurs i q N k h x) have hcon : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (fun j=>flagPair (F x j))).map toScan):=by intro x _ exact InitialExperiment.tuple_consistent i q N k h x have hocc : ∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), ((univ.filter (fun j : Fin k=>(flagPair (F x j)).swap∈ orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ InitialExperiment.occupancyConstant i*σ:=by intro x _ W simpa only [hlog] using InitialExperiment.tuple_occupancy i q N k h x W let e0:=initial_context p F _ (InitialExperiment.alphabet_cap i q hP4 σ he) obtain ⟨m,hm,⟨e⟩⟩:=hiter q hq he Ω N k p stream F hk hkn hku hklo hdom hsel hN hcon hocc e0 exact hnone q he Ω N k m p stream F hkn hku hdom hsel hN hcon hm ⟨e⟩endend SharpLogRamsey.Marking
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121import Mathlibimport OAI.Combinatorics.SharpRamsey.Construction.InitialTools
namespace OAI
sectionnamespace SharpLogRamsey.InitialExperimentopen Finset Real Filter Selection Marking FiniteStreamTail RectangleStreamEventopen scoped Classical BigOperators Topologynoncomputable sectionlocal instance initLawFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injectivelocal instance initLawFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injectivelocal instance initLawProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _local instance initLawDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _local instance initLawDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _
def occupancyConstant (i : ℕ) : ℝ := (((i+4)^2:ℕ)+5:ℝ)/log 2
lemma occupancyConstant_pos (i : ℕ) : 0 < occupancyConstant i:=by unfold occupancyConstant exact div_pos (by positivity) (log_pos (by norm_num))
variable (i q : ℕ) [Fact q.Prime] (N k : ℕ)
local instance initLawFlagNonempty : Nonempty (Flag (ZMod q) (Fin (i+4)→ZMod q)):= Fintype.card_pos_iff.mp (by have hh:=flags_card_pos (K:=ZMod q) (V:=Fin (i+4)→ZMod q) (d:=i+3) (by omega) (by simp) simpa only [←Nat.card_eq_fintype_card] using hh)
def goodEvent : Finset (Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)):= univ.filter (fun z=>∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), (hits (rectangle W) z:ℝ)<occupancyConstant i*log (q:ℝ))
lemma goodEvent_half (hN : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ)) : (1:ℝ)/2 ≤ probability (goodEvent i q N) := by have hh:=simultaneous_good_probability (d:=i+3) (N:=N) (K:=ZMod q) (V:=Fin (i+4)→ZMod q) (by omega) (by simp) (by simpa only [Nat.card_zmod] using hN) have hq : 2 ≤ (q:ℝ):=by exact_mod_cast (Fact.out : q.Prime).two_le have hq0 : (0:ℝ) < q:=by linarith have hdiv : 1/(q:ℝ) ≤ 1/2:=(div_le_iff₀ hq0).mpr (by linarith) have hin : (1:ℝ)/2 ≤ 1-1/q:=by linarith apply hin.trans simpa only [goodEvent,occupancyConstant,Nat.card_zmod,show i+3+1=i+4 by omega, probability,hits,rectangle,mem_filter,mem_univ,true_and,←Fintype.card_subtype, ←Nat.card_eq_fintype_card] using hh
def law (hN : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ)) : Law (goodEvent i q N):= uniformLaw.onEvent (goodEvent i q N) (by rw [uniformLaw_event]; have:=goodEvent_half i q N hN;linarith)
lemma law_dom (hN : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ)) : ∀ g,((law i q N hN).map (Subtype.val : goodEvent i q N→_)).mass g ≤ 2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N := by intro g have hh:=uniformLaw_conditioned (goodEvent_half i q N hN) g convert hh using 1 <;> simp only [law,Fintype.card_fun,Fintype.card_fin,Nat.cast_pow]
variable (h : ∀ z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q), k ≤ (flagGraph (ZMod q) (Fin (i+4)→ZMod q) z).indepNum)
def chosen (z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) : Fin k↪o Fin N:= Classical.choose (independent_selected z (h z))
lemma chosen_consistent (z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) : Consistent (fun j=>z (chosen i q N k h z j)):=Classical.choose_spec (independent_selected z (h z))
def tuple (z : goodEvent i q N) : Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q):= fun j=>z.val (chosen i q N k h z.val j.rev)
lemma tuple_occurs (z : goodEvent i q N) : Occurs (reverseTuple (tuple i q N k h z)) z.val := by apply (occurs_iff_orderEmbedding _ _).mpr refine ⟨chosen i q N k h z.val,?_⟩ intro j simp only [reverseTuple,tuple,Fin.rev_rev]
lemma tuple_consistent (z : goodEvent i q N) : ScanConsistent ((List.ofFn (fun j=>flagPair (tuple i q N k h z j))).map toScan) := selected_reverse_consistent z.val (chosen i q N k h z.val) (chosen_consistent i q N k h z.val)
lemma tuple_occupancy (z : goodEvent i q N) : ∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), ((univ.filter (fun j : Fin k=>(flagPair (tuple i q N k h z j)).swap∈ orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ occupancyConstant i*log (q:ℝ) := by intro W let e : Fin k↪Fin N:= (Equiv.toEmbedding (Equiv.ofBijective Fin.rev (by constructor · intro a b hab;simpa using congrArg Fin.rev hab · intro a;exact ⟨a.rev,by simp⟩))).trans (chosen i q N k h z.val).toEmbedding have hh:=hits_embedding (rectangle W) z.val e have hz : (hits (rectangle W) z.val:ℝ)<occupancyConstant i*log (q:ℝ):=(mem_filter.mp z.property).2 W apply le_trans _ hz.le convert (Nat.cast_le (α:=ℝ)).mpr hh using 1 congr 1 apply congrArg Finset.card ext j simp only [mem_filter,mem_univ,true_and,rectangle_pair_iff] rfl
lemma alphabet_cap {P : ℝ} (hP : 4 ≤ P) (σ : ℝ) (he : exp σ=(q:ℝ)) : (Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ) ≤ P*(q:ℝ)^(i+3)*exp (((i+2:ℕ):ℝ)*σ) := by have hq : 2 ≤ q:=(Fact.out : q.Prime).two_le have hh : Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)) ≤ 4*q^(i+3)*q^(i+2):=by rw [actualFlag_card (d:=i+3) (by simp),Nat.card_zmod] have h1:=InitialRectangles.sum_powers_le_two hq (show 0 < i+3+1 by omega) have h2:=InitialRectangles.sum_powers_le_two hq (show 0 < i+3 by omega) have hx:=Nat.mul_le_mul h1 h2 simp only [Nat.add_sub_cancel,show i+3-1=i+2 by omega] at hx exact hx.trans_eq (by ring) rw [exp_nat_mul,he] have hh' : (Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ) ≤ 4*(q:ℝ)^(i+3)*(q:ℝ)^(i+2):=by exact_mod_cast hh apply hh'.trans gcongrendend SharpLogRamsey.InitialExperiment
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137import Mathlibimport OAI.Combinatorics.SharpRamsey.Construction.FlagConstruction
namespace OAI
sectionnamespace SharpLogRamsey.InitialRectanglesopen Finset Realopen scoped Classical BigOperatorsnoncomputable sectionvariable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V]
local instance flat_JoinedInitialRectangles_1 : Finite (Module.Dual K V) := Module.finite_of_finite Klocal instance flat_JoinedInitialRectangles_2 : Finite (Projectivization K V) := by let : Finite V := Module.finite_of_finite K exact Finite.of_injective Projectivization.rep (fun a b h => by rw [←a.mk_rep,←b.mk_rep]; congr 1)local instance flat_JoinedInitialRectangles_3 : Finite (Projectivization K (Module.Dual K V)) := Finite.of_injective Projectivization.rep (fun a b h => by rw [←a.mk_rep,←b.mk_rep]; congr 1)local instance flat_JoinedInitialRectangles_4 : Finite (Flag K V) := Finite.of_injective (fun f : Flag K V => (f.point,f.dualPoint)) (by intro a b h cases a; cases b cases h rfl)local instance flat_JoinedInitialRectangles_5 : Finite (Submodule K V) := by let : Finite V := Module.finite_of_finite K exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective
def IsRectangle (W : Submodule K V) (f : Flag K V) : Prop := f.point.submodule≤W ∧ f.dualPoint.submodule≤W.dualAnnihilator
omit [FiniteDimensional K V] inlemma card_points (W : Submodule K V) : Nat.card {a : Projectivization K V // a.submodule≤W} = ∑ i∈range (Module.finrank K W),(Nat.card K)^i := by rw [←Nat.card_congr (projectiveSubmoduleEquiv W)] exact Projectivization.card_of_finrank K W rfl
lemma card_rectangle_le (W : Submodule K V) : Nat.card {f : Flag K V // IsRectangle W f} ≤ (∑ i∈range (Module.finrank K W),(Nat.card K)^i)* (∑ i∈range (Module.finrank K W.dualAnnihilator),(Nat.card K)^i) := by let f : {f : Flag K V // IsRectangle W f} → {a : Projectivization K V // a.submodule≤W} × {b : Projectivization K (Module.Dual K V) // b.submodule≤W.dualAnnihilator} := fun z => (⟨z.1.point,z.2.1⟩,⟨z.1.dualPoint,z.2.2⟩) have hi : Function.Injective f := by intro a b h apply Subtype.ext have hp := congrArg (fun z => z.1.val) h have hd := congrArg (fun z => z.2.val) h cases a with | mk a ha => cases b with | mk b hb => cases a; cases b simp only [f] at hp hd cases hp; cases hd; rfl exact (Nat.card_le_card_of_injective f hi).trans_eq (by rw [Nat.card_prod,card_points,card_points])
lemma card_subspaces_le : Nat.card (Submodule K V)≤(Nat.card K)^(Module.finrank K V)^2 := by let : Finite V := Module.finite_of_finite K let : Finite (V→ₗ[K]V) := Finite.of_injective DFunLike.coe DFunLike.coe_injective have hs : Function.Surjective (LinearMap.range : (V→ₗ[K]V)→Submodule K V) := by intro W obtain ⟨Q,hQ⟩ := W.exists_isCompl exact ⟨W.projection Q hQ,W.range_projection hQ⟩ apply (Nat.card_le_card_of_surjective _ hs).trans_eq let : Fintype K := Fintype.ofFinite K let : Fintype (V→ₗ[K]V) := Fintype.ofFinite _ simpa only [Nat.card_eq_fintype_card,Module.finrank_linearMap,pow_two] using (Module.card_eq_pow_finrank (K:=K) (V:=V→ₗ[K]V))
omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] inlemma sum_powers_le_two {q n : ℕ} (hq : 2≤q) (hn : 0<n) : ∑ i∈range n,q^i≤2*q^(n-1) := by obtain ⟨m,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hn) clear hn induction m with | zero => simp | succ m ih => rw [sum_range_succ] simp only [Nat.succ_eq_add_one,Nat.add_sub_cancel] at * have hm : 2*q^m≤q^(m+1) := by rw [pow_succ] simpa only [mul_comm] using Nat.mul_le_mul_left (q^m) hq omega
lemma card_rectangle_bound {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) (W : Submodule K V) : Nat.card {f : Flag K V // IsRectangle W f} ≤ 4*(Nat.card K)^(d-1) := by have hq : 2≤Nat.card K := Finite.one_lt_card (α:=K) have hs := Subspace.finrank_add_finrank_dualAnnihilator_eq W rw [hdim] at hs let r := Module.finrank K W let s := Module.finrank K W.dualAnnihilator by_cases hr : r=0 · apply (card_rectangle_le W).trans change (∑ i∈range r,(Nat.card K)^i)*_≤_ simp [hr] by_cases ht : s=0 · apply (card_rectangle_le W).trans change _*(∑ i∈range s,(Nat.card K)^i)≤_ simp [ht] have he : (r-1)+(s-1)=d-1 := by dsimp [r,s] at *; omega calc _ ≤ (∑ i∈range r,(Nat.card K)^i)*(∑ i∈range s,(Nat.card K)^i) := card_rectangle_le W _ ≤ (2*(Nat.card K)^(r-1))*(2*(Nat.card K)^(s-1)) := Nat.mul_le_mul (sum_powers_le_two hq (Nat.pos_of_ne_zero hr)) (sum_powers_le_two hq (Nat.pos_of_ne_zero ht)) _ = _ := by rw [show (2*(Nat.card K)^(r-1))*(2*(Nat.card K)^(s-1))= 4*((Nat.card K)^(r-1)*(Nat.card K)^(s-1)) by ring,←pow_add,he]
lemma card_flags_lower {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) : (Nat.card K)^(2*d-1)≤Nat.card (Flag K V) := by rw [card_flags hdim] have h1 : (Nat.card K)^d≤∑ i∈range (d+1),(Nat.card K)^i := single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega)) have h2 : (Nat.card K)^(d-1)≤∑ i∈range d,(Nat.card K)^i := single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega)) have he : 2*d-1=d+(d-1) := by omega rw [he,pow_add] exact Nat.mul_le_mul h1 h2
lemma finite_flags : Finite (Flag K V) := inferInstance
lemma finite_subspaces : Finite (Submodule K V) := inferInstance
endend SharpLogRamsey.InitialRectangles
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import Mathlibimport OAI.Combinatorics.SharpRamsey.Marking.TrackedGeometryimport OAI.Combinatorics.SharpRamsey.Construction.RectangleStreamEvent
namespace OAI
sectionnamespace SharpLogRamseyopen Finset Real Selection Markingopen scoped Classical BigOperatorsnoncomputable section
namespace Selectionvariable {α : Type} [Fintype α] [Nonempty α]def uniformLaw : Law α where mass _:=1/(Fintype.card α:ℝ) nonneg _:=by positivity total:=by simp [Fintype.card_ne_zero]
lemma uniformLaw_event (E : Finset α) : uniformLaw.event E=FiniteStreamTail.probability E:=by simp only [Law.event,uniformLaw,sum_const,nsmul_eq_mul,FiniteStreamTail.probability] ring
lemma uniformLaw_conditioned {E : Finset α} (hE : (1:ℝ)/2 ≤ FiniteStreamTail.probability E) : ∀ a,((uniformLaw.onEvent E (by rw [uniformLaw_event];linarith)).map (Subtype.val : E→α)).mass a ≤ 2/(Fintype.card α:ℝ) := by intro a have hh:=uniformLaw.onEvent_map_le_two E (by rwa [uniformLaw_event]) id a rw [Law.map_id] at hh convert hh using 1 <;> simp [uniformLaw] ringend Selection
variable {K V : Type} [Field K] [AddCommGroup V] [Module K V] [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))]
lemma rectangle_pair_iff [Finite K] [FiniteDimensional K V] (W : Submodule K V) (f : Flag K V) : (flagPair f).swap∈orthogonalRectangle Projectivization.rep Projectivization.rep W ↔ f∈RectangleStreamEvent.rectangle W := by simp only [orthogonalRectangle,mem_filter,mem_univ,true_and,RectangleStreamEvent.rectangle, InitialRectangles.IsRectangle,Projectivization.submodule_eq,Submodule.span_singleton_le_iff_mem] rfl
def initial_context {Ω : Type} [Fintype Ω] {k : ℕ} (p : Law Ω) (F : Ω→Fin k→Flag K V) (B : ℝ) (hB : (Fintype.card (Flag K V):ℝ) ≤ B) : ContextOutput p (fun x j=>flagPair (F x j)) k B 0 1 where X:={x // p.mass x≠0} Γ:=Unit finiteX:=inferInstance finiteΓ:=inferInstance μ:=p.nullFree source:=Subtype.val msg:=fun _=>() chosen:=fun _=>OrderEmbedding.ofStrictMono id (fun _ _ h=>h) domains:=fun _ _=>univ.map ⟨flagPair,flagPair_injective⟩ supported:=fun x=>x.property hit:=fun x j=>mem_map.mpr ⟨F x.val j,mem_univ _,rfl⟩ size:=by intro _ _;simpa only [card_map,card_univ] using hB dominated:=by intro x have hh:=p.nullFree_map id rw [Law.map_id] at hh have he : p.nullFree.map (Subtype.val : {x // p.mass x≠0}→Ω)=p:=by convert hh using 1 congr! rw [he,one_mul] cost:=by have hh:=entropy_le_log_card (p.nullFree.map (fun _=>())) univ (by simp) simpa using hh
omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] inlemma independent_selected {N k : ℕ} (z : Fin N→Flag K V) (h : k ≤ (flagGraph K V z).indepNum) : ∃ e : Fin k↪o Fin N,Consistent (fun j=>z (e j)) := by obtain ⟨S,hS⟩:=(flagGraph K V z).exists_isNIndepSet_indepNum obtain ⟨T,hTS,hTk⟩:=exists_subset_card_eq (s:=S) (n:=k) (by rwa [hS.card_eq]) let e:=T.orderEmbOfFin hTk refine ⟨e,?_⟩ have hc : ConsistentOn z T:=(consistentOn_iff_compl_isClique _ _).mpr (by rw [SimpleGraph.isClique_compl] exact hS.isIndepSet.mono (by exact_mod_cast hTS)) intro a b hab hi exact hc (e a) (T.orderEmbOfFin_mem hTk a) (e b) (T.orderEmbOfFin_mem hTk b) (e.strictMono hab) hi
omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] inlemma selected_reverse_consistent {N k : ℕ} (z : Fin N→Flag K V) (e : Fin k↪o Fin N) (hc : Consistent (fun j=>z (e j))) : ScanConsistent ((List.ofFn (fun j=>flagPair (z (e j.rev)))).map toScan) := by have hh:=backwardScan_consistent (fun j=>z (e j)) hc simpa only [backwardScan,List.map_ofFn,Function.comp_def,flagPair,toScan] using hhendend SharpLogRamsey
end
end OAI1234567891011121314151617181920212223242526272829303132333435import Mathlibimport OAI.Combinatorics.SharpRamsey.Construction.GraphWitnessimport OAI.Combinatorics.SharpRamsey.Construction.SourceSizesimport OAI.Combinatorics.SharpRamsey.Bounds.Lower
namespace OAI
sectionnamespace SharpLogRamsey.LowerTransferopen Real Filteropen scoped Topologynoncomputable section
theorem actual_prime_construction (i : ℕ) : PrimeConstruction (i+3) := by intro η hη hηu have hσ:=Marking.eventually_graph_witness i η hη (by linarith : η ≤ 1) have ht : Tendsto (fun q : ℕ=>log (q:ℝ)) atTop atTop:= tendsto_log_atTop.comp tendsto_natCast_atTop_atTop filter_upwards [ht.eventually hσ,InitialExperiment.eventually_source_sizes i η hη.le] with q hgraph hsize intro hq have : Fact q.Prime:=⟨hq⟩ have hq0 : (0:ℝ) < q:=by exact_mod_cast hq.pos exact hgraph q hsize.1 (exp_log hq0) _ _ hsize.2.2.1 hsize.2.2.2.1 hsize.2.2.2.2.1 hsize.2.2.2.2.2.1 hsize.2.2.2.2.2.2
theorem prime_construction (d : ℕ) (hd : 5 ≤ d) : PrimeConstruction d := by have he : d-3+3=d:=by omega simpa only [he] using actual_prime_construction (d-3)endend SharpLogRamsey.LowerTransfer
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157import Mathlibimport OAI.Combinatorics.SharpRamsey.Construction.InitialRectanglesimport OAI.Combinatorics.SharpRamsey.Construction.FiniteStreamTail
namespace OAI
sectionnamespace SharpLogRamsey.RectangleStreamEventopen Finset Real InitialRectangles FiniteStreamTailopen scoped Classical BigOperatorsnoncomputable sectionvariable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V]local instance flat_JoinedRectangleStreamEvent_1 : Fintype (Flag K V) := @Fintype.ofFinite _ (finite_flags (K:=K) (V:=V))local instance flat_JoinedRectangleStreamEvent_2 : Fintype (Submodule K V) := @Fintype.ofFinite _ (finite_subspaces (K:=K) (V:=V))
def rectangle (W : Submodule K V) : Finset (Flag K V) := univ.filter (IsRectangle W)
lemma rectangle_card {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) (W : Submodule K V) : (rectangle W).card≤4*(Nat.card K)^(d-1) := by convert card_rectangle_bound hd hdim W using 1 rw [Nat.card_eq_fintype_card,Fintype.card_subtype] rfl
lemma flags_card_pos {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) : 0<Fintype.card (Flag K V) := by have h := card_flags_lower hd hdim rw [Nat.card_eq_fintype_card (α:=Flag K V)] at h exact lt_of_lt_of_le (pow_pos (Nat.card_pos (α:=K)) _) h
lemma rectangle_probability {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) (W : Submodule K V) : probability (rectangle W)≤4/(Nat.card K:ℝ)^d := by have hp : 0<(Nat.card K:ℝ) := by exact_mod_cast (show 0<Nat.card K from Nat.card_pos) have hf : 0<(Fintype.card (Flag K V):ℝ) := by exact_mod_cast flags_card_pos hd hdim have hc : ((rectangle W).card:ℝ)≤4*(Nat.card K:ℝ)^(d-1) := by exact_mod_cast rectangle_card hd hdim W have hb : (Nat.card K:ℝ)^(2*d-1)≤Fintype.card (Flag K V) := by exact_mod_cast (show (Nat.card K)^(2*d-1)≤Fintype.card (Flag K V) by simpa only [Nat.card_eq_fintype_card] using card_flags_lower hd hdim) unfold probability calc _ ≤ (4*(Nat.card K:ℝ)^(d-1))/(Nat.card K:ℝ)^(2*d-1) := div_le_div₀ (by positivity) hc (by positivity) hb _ = _ := by have he : 2*d-1=d+(d-1) := by omega rw [he,pow_add] field_simp
lemma rectangle_mean {d N : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) (hN : (N:ℝ)≤(Nat.card K:ℝ)^d*log (Nat.card K)) (W : Submodule K V) : (N:ℝ)*probability (rectangle W)≤4*log (Nat.card K) := by have hp : 0<(Nat.card K:ℝ) := by exact_mod_cast (show 0<Nat.card K from Nat.card_pos) calc _ ≤ N*(4/(Nat.card K:ℝ)^d) := mul_le_mul_of_nonneg_left (rectangle_probability hd hdim W) (Nat.cast_nonneg _) _ ≤ ((Nat.card K:ℝ)^d*log (Nat.card K))*(4/(Nat.card K:ℝ)^d) := mul_le_mul_of_nonneg_right hN (by positivity) _ = _ := by field_simp
omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] inlemma union_exponent (q : ℝ) (hq : 0<q) (n : ℕ) : q^n*exp (4*log q-(((n:ℝ)+5)/log 2*log q)*log 2)=1/q := by have hl : log (2:ℝ)≠0 := ne_of_gt (log_pos (by norm_num)) have he : 4*log q-(((n:ℝ)+5)/log 2*log q)*log 2= -(n:ℝ)*log q-log q := by field_simp; ring rw [he] have hpow : q^n=exp ((n:ℝ)*log q) := by rw [exp_nat_mul,exp_log hq] rw [hpow,←exp_add] rw [show (n:ℝ)*log q+(-(n:ℝ)*log q-log q)= -log q by ring, exp_neg,exp_log hq,one_div]
theorem simultaneous_rectangle_tail {d N : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) (hN : (N:ℝ)≤(Nat.card K:ℝ)^d*log (Nat.card K)) : probability (univ.filter (fun z : Fin N→Flag K V=>∃ W : Submodule K V, (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z)) ≤ 1/(Nat.card K:ℝ) := by have hf := flags_card_pos hd hdim let : Nonempty (Flag K V) := Fintype.card_pos_iff.mp hf let t : ℝ := (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K) have hs := simultaneous_tail (rectangle (K:=K) (V:=V)) N t (4*log (Nat.card K)) (rectangle_mean hd hdim hN) have hc : (Fintype.card (Submodule K V):ℝ)≤(Nat.card K:ℝ)^((d+1)^2) := by have h := card_subspaces_le (K:=K) (V:=V) rw [hdim,Nat.card_eq_fintype_card] at h exact_mod_cast h calc _ ≤ (Fintype.card (Submodule K V):ℝ)*exp (4*log (Nat.card K)-t*log 2) := hs _ ≤ (Nat.card K:ℝ)^((d+1)^2)*exp (4*log (Nat.card K)-t*log 2) := mul_le_mul_of_nonneg_right hc (le_of_lt (exp_pos _)) _ = _ := union_exponent _ (by exact_mod_cast (show 0<Nat.card K from Nat.card_pos)) _
theorem source_length_tail {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) : probability (univ.filter (fun z : Fin ⌊(Nat.card K:ℝ)^d*log (Nat.card K)⌋₊→Flag K V=> ∃ W : Submodule K V, (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z)) ≤ 1/(Nat.card K:ℝ) := by apply simultaneous_rectangle_tail hd hdim apply Nat.floor_le apply mul_nonneg (by positivity) apply log_nonneg exact_mod_cast (Nat.le_of_lt (Finite.one_lt_card (α:=K)))
omit [Finite K] in
lemma dual_rectangle (U : Submodule K (Module.Dual K V)) (f : Flag K V) : IsRectangle U.dualCoannihilator f ↔ f.dualPoint.submodule≤U ∧ f.point.submodule≤U.dualCoannihilator := by simp only [IsRectangle,Subspace.dualCoannihilator_dualAnnihilator_eq,and_comm]
lemma inherited_occupancy {N n : ℕ} (z : Fin N→Flag K V) (e : Fin n↪Fin N) (M : ℝ) (h : ∀ W : Submodule K V,(hits (rectangle W) z:ℝ)<M) : ∀ W : Submodule K V,(hits (rectangle W) (z∘e):ℝ)<M := by intro W exact lt_of_le_of_lt (by exact_mod_cast hits_embedding (rectangle W) z e) (h W)
theorem simultaneous_good_probability {d N : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) (hN : (N:ℝ)≤(Nat.card K:ℝ)^d*log (Nat.card K)) : 1-1/(Nat.card K:ℝ) ≤ probability (univ.filter (fun z : Fin N→Flag K V=>∀ W : Submodule K V, (hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K))) := by let : Nonempty (Flag K V) := Fintype.card_pos_iff.mp (flags_card_pos hd hdim) let B := univ.filter (fun z : Fin N→Flag K V=>∃ W : Submodule K V, (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z) have he : Bᶜ=univ.filter (fun z : Fin N→Flag K V=>∀ W : Submodule K V, (hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)) := by ext z simp only [B,mem_compl,mem_filter,mem_univ,true_and,not_exists,not_le] rw [←he] have hc : probability Bᶜ=1-probability B := by convert probability_compl B using 1 congr 1 ext z simp rw [hc] exact sub_le_sub_left (simultaneous_rectangle_tail hd hdim hN) 1
theorem source_good_probability {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) : (1:ℝ)/2 ≤ probability (univ.filter (fun z : Fin ⌊(Nat.card K:ℝ)^d*log (Nat.card K)⌋₊→Flag K V=> ∀ W : Submodule K V, (hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K))) := by have hq : 2≤(Nat.card K:ℝ) := by exact_mod_cast (Finite.one_lt_card (α:=K)) have hp : 0<(Nat.card K:ℝ) := by linarith have hh : 1/(Nat.card K:ℝ)≤1/2 := (div_le_iff₀ hp).mpr (by linarith) apply (show (1:ℝ)/2≤1-1/(Nat.card K:ℝ) by linarith).trans apply simultaneous_good_probability hd hdim exact Nat.floor_le (mul_nonneg (by positivity) (log_nonneg (by linarith)))
endend SharpLogRamsey.RectangleStreamEvent
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import Mathlib
namespace OAI
sectionnamespace SharpLogRamsey.InitialExperimentopen Real Filteropen scoped Topologynoncomputable section
lemma eventually_source_sizes (i : ℕ) (η : ℝ) (hη : 0 ≤ η) : ∀ᶠ q : ℕ in atTop, 3 ≤ q ∧ 1 ≤ log (q:ℝ) ∧ 0 < ⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊ ∧ ⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊ ≤ ⌊(q:ℝ)^(i+3)*log (q:ℝ)⌋₊ ∧ (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ) ≤ (q:ℝ)*(log (q:ℝ))^(1+η) ∧ ((q:ℝ)*(log (q:ℝ))^(1+η))/2 ≤ (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ) ∧ (⌊(q:ℝ)^(i+3)*log (q:ℝ)⌋₊:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ) := by have hsmall := (isLittleO_log_rpow_rpow_atTop η (by norm_num : (0:ℝ)<1)).bound (by norm_num : (0:ℝ)<1) filter_upwards [tendsto_natCast_atTop_atTop.eventually hsmall, (tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually_ge_atTop 1, eventually_ge_atTop (3:ℕ)] with q hsmall hl hq change 1 ≤ log (q:ℝ) at hl have hq1 : (1:ℝ) ≤ q:=by exact_mod_cast (show 1 ≤ q by omega) have hq2 : (2:ℝ) ≤ q:=by exact_mod_cast (show 2 ≤ q by omega) have hq0 : (0:ℝ) < q:=by linarith have hl0 : 0 < log (q:ℝ):=by linarith simp only [Real.norm_eq_abs,abs_of_pos (rpow_pos_of_pos hl0 _), rpow_one,abs_of_pos hq0,one_mul] at hsmall have hpow : 1 ≤ (log (q:ℝ))^(1+η):=one_le_rpow hl (by linarith) have hQ : 2 ≤ (q:ℝ)*(log (q:ℝ))^(1+η):=by nlinarith only [hpow,hq2] have hf : (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ)+1 > (q:ℝ)*(log (q:ℝ))^(1+η):=Nat.lt_floor_add_one _ have hlower : ((q:ℝ)*(log (q:ℝ))^(1+η))/2 ≤ (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ):=by linarith refine ⟨hq,hl,?_,?_,Nat.floor_le (by positivity),hlower,Nat.floor_le (by positivity)⟩ · exact (Nat.one_le_floor_iff _).mpr (by linarith) · apply Nat.floor_mono calc _ = (q:ℝ)*log (q:ℝ)*(log (q:ℝ))^η:=by rw [rpow_add hl0,rpow_one];ring _ ≤ (q:ℝ)*log (q:ℝ)*(q:ℝ):=mul_le_mul_of_nonneg_left hsmall (by positivity) _ = (q:ℝ)^2*log (q:ℝ):=by ring _ ≤ _:=mul_le_mul_of_nonneg_right (pow_le_pow_right₀ hq1 (by omega : 2 ≤ i+3)) hl0.leendend SharpLogRamsey.InitialExperiment
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.WitnessList
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen scoped BigOperatorsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators ENNReal NNRealnamespace SharpRamseyFive.ResidualCertificatevariable {V : Type*} [Fintype V] [DecidableEq V]section SharedHitGeometryopen scoped Classicalvariable {D B : Type*} [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B]omit [Fintype D] [Fintype B] inlemma anchorEvents_realized (hit : B → D → Prop) (C : Finset (B × D)) (A : Finset D) (r : A → B) (h : ∀ d : A, hit (r d) d.val) : Realized hit (anchorEvents C A r) := by intro p hp obtain ⟨d, _, rfl⟩ := Finset.mem_image.mp hp exact h d
omit [Fintype V] [Fintype D] in
theorem anchor_step_witnesses (s : V → Finset D) (hit : B → D → Prop) (E : Finset V) (C : Finset (B × D)) (v : V) (a : ℕ) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) (ha : a ≤ (touchedToEncoded s hit E v).card) : ∃ (A : Finset D) (r : A → B), A.card = a ∧ A ⊆ s v ∧ A ⊆ encodedDirections s E ∧ (∀ d : A, hit (r d) d.val) ∧ Disjoint C (anchorEvents C A r) ∧ Realized hit (C ∪ anchorEvents C A r) ∧ DictionaryInvariant s (insert v E) (C ∪ anchorEvents C A r) ∧ (C ∪ anchorEvents C A r).card ≤ C.card + a := by classical obtain ⟨A, hA, hAc⟩ := Finset.exists_subset_card_eq ha have hh (d : A) : ∃ r, hit r d.val := (Finset.mem_filter.mp (hA d.property)).2 choose r hr using hh have hAs : A ⊆ s v := fun d hd => (Finset.mem_inter.mp (Finset.mem_filter.mp (hA hd)).1).1 have hAE : A ⊆ encodedDirections s E := fun d hd => (Finset.mem_inter.mp (Finset.mem_filter.mp (hA hd)).1).2 refine ⟨A, r, hAc, hAs, hAE, hr, anchorEvents_fresh C A r, realized_union hit hreal (anchorEvents_realized hit C A r hr), ?_, ?_⟩ · unfold DictionaryInvariant rw [paidDirections_union] apply Finset.union_subset · exact hC.trans (encodedDirections_mono s (Finset.subset_insert _ _)) · exact (anchorEvents_directions C A r).trans (hAE.trans (encodedDirections_mono s (Finset.subset_insert _ _))) · exact (Finset.card_union_le _ _).trans (Nat.add_le_add_left ((anchorEvents_card C A r).trans_eq hAc) _)
noncomputable def pairEvents (T : Finset B) (d : T → D) : Finset (B × D) := T.attach.image (fun r => (r.val, d r))
omit [Fintype D] [Fintype B] inlemma pairEvents_card (T : Finset B) (d : T → D) : (pairEvents T d).card = T.card := by rw [pairEvents, Finset.card_image_of_injective] · exact Finset.card_attach · intro r r' he exact Subtype.ext (congrArg Prod.fst he)
omit [Fintype D] [Fintype B] inlemma pairEvents_realized (hit : B → D → Prop) (T : Finset B) (d : T → D) (h : ∀ r : T, hit r.val (d r)) : Realized hit (pairEvents T d) := by intro p hp obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp exact h r
omit [Fintype V] [Fintype D] in
theorem pair_step_witnesses (s : V → Finset D) (hit : B → D → Prop) (E : Finset V) (C : Finset (B × D)) (v u : V) (K : ℕ) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) (hp : K ≤ (sharedBatches (outsideDirections s E) hit v u).card) : ∃ (T : Finset B) (d : T → D), T.card = K ∧ (∀ r : T, d r ∈ s v ∩ s u ∧ d r ∉ encodedDirections s E ∧ hit r.val (d r)) ∧ Disjoint C (pairEvents T d) ∧ Realized hit (C ∪ pairEvents T d) ∧ DictionaryInvariant s (insert v (insert u E)) (C ∪ pairEvents T d) ∧ (C ∪ pairEvents T d).card = C.card + K := by classical obtain ⟨T, hT, hTc⟩ := Finset.exists_subset_card_eq hp have hh (r : T) : ∃ d, d ∈ s v ∩ s u ∧ d ∉ encodedDirections s E ∧ hit r.val d := by obtain ⟨d, hd, hr⟩ := (Finset.mem_filter.mp (hT r.property)).2 obtain ⟨hdv, hdu⟩ := Finset.mem_inter.mp hd exact ⟨d, Finset.mem_inter.mpr ⟨(Finset.mem_sdiff.mp hdv).1, (Finset.mem_sdiff.mp hdu).1⟩, (Finset.mem_sdiff.mp hdv).2, hr⟩ choose d hd using hh have hfresh : Disjoint C (pairEvents T d) := by apply Finset.disjoint_left.mpr intro p hp he obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp he exact (hd r).2.1 (hC (Finset.mem_image_of_mem Prod.snd hp)) refine ⟨T, d, hTc, hd, hfresh, realized_union hit hreal (pairEvents_realized hit T d (fun r => (hd r).2.2)), ?_, ?_⟩ · unfold DictionaryInvariant rw [paidDirections_union] apply Finset.union_subset · exact hC.trans (encodedDirections_mono s ((Finset.subset_insert _ _).trans (Finset.subset_insert _ _))) · intro z hz obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, (Finset.mem_inter.mp (hd r).1).1⟩ · rw [Finset.card_union_of_disjoint hfresh, pairEvents_card, hTc]
inductive PaidStep (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) : (Finset V × Finset (B × D)) → (Finset V × Finset (B × D)) → Prop | anchor (E : Finset V) (C : Finset (B × D)) (v : V) (hv : v ∉ E) (A : Finset D) (hA : A.card = a) (hAs : A ⊆ s v) (hAE : A ⊆ encodedDirections s E) (r : A → B) (hr : ∀ d : A, hit (r d) d.val) : PaidStep s hit a K (E, C) (insert v E, C ∪ anchorEvents C A r) | pair (E : Finset V) (C : Finset (B × D)) (v u : V) (hv : v ∉ E) (hu : u ∉ E) (hne : v ≠ u) (T : Finset B) (hT : T.card = K) (d : T → D) (hd : ∀ r : T, d r ∈ s v ∩ s u ∧ d r ∉ encodedDirections s E ∧ hit r.val (d r)) : PaidStep s hit a K (E, C) (insert v (insert u E), C ∪ pairEvents T d)
omit [Fintype V] inomit [Fintype D] [Fintype B] inlemma paidStep_realized (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) {Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z') (hreal : Realized hit Z.2) : Realized hit Z'.2 := by cases h with | anchor E C v hv A hA hAs hAE r hr => exact realized_union hit hreal (anchorEvents_realized hit C A r hr) | pair E C v u hv hu hne T hT d hd => exact realized_union hit hreal (pairEvents_realized hit T d (fun r => (hd r).2.2))omit [Fintype V] [Fintype D] [Fintype B] in
lemma paidStep_dictionary (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) {Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z') (hC : DictionaryInvariant s Z.1 Z.2) : DictionaryInvariant s Z'.1 Z'.2 := by cases h with | anchor E C v hv A hA hAs hAE r hr => unfold DictionaryInvariant rw [paidDirections_union] exact Finset.union_subset (hC.trans (encodedDirections_mono s (Finset.subset_insert _ _))) ((anchorEvents_directions C A r).trans (hAE.trans (encodedDirections_mono s (Finset.subset_insert _ _)))) | pair E C v u hv hu hne T hT d hd => unfold DictionaryInvariant rw [paidDirections_union] refine Finset.union_subset (hC.trans (encodedDirections_mono s ((Finset.subset_insert _ _).trans (Finset.subset_insert _ _)))) ?_ intro z hz obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, (Finset.mem_inter.mp (hd r).1).1⟩
omit [Fintype V] inomit [Fintype D] [Fintype B] inlemma paidStep_cost (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) (haK : a ≤ K) {Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z') : Z'.2.card + K * Z.1.card ≤ Z.2.card + K * Z'.1.card := by cases h with | anchor E C v hv A hA hAs hAE r hr => simp only [Finset.card_insert_of_notMem hv, Nat.mul_add, Nat.mul_one] have hc := (Finset.card_union_le C (anchorEvents C A r)).trans (Nat.add_le_add_left ((anchorEvents_card C A r).trans_eq hA) C.card) omega | pair E C v u hv hu hne T hT d hd => have hv' : v ∉ insert u E := by simp [hne, hv] simp only [Finset.card_insert_of_notMem hv', Finset.card_insert_of_notMem hu, Nat.mul_add, Nat.mul_one] have hc := Finset.card_union_le C (pairEvents T d) rw [pairEvents_card, hT] at hc omega
omit [Fintype V] [Fintype D] in
lemma encodingStep_lift (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) {E F : Finset V} (h : EncodingStep s hit a K E F) (C : Finset (B × D)) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) : ∃ C', PaidStep s hit a K (E, C) (F, C') ∧ DictionaryInvariant s F C' ∧ Realized hit C' := by cases h with | anchor v hv ha => obtain ⟨A, r, hAc, hAs, hAE, hr, _, hh, hdict, _⟩ := anchor_step_witnesses s hit E C v a hC hreal ha exact ⟨_, .anchor E C v hv A hAc hAs hAE r hr, hdict, hh⟩ | pair v u hv hu hne hp => obtain ⟨T, d, hTc, hd, _, hh, hdict, _⟩ := pair_step_witnesses s hit E C v u K hC hreal hp exact ⟨_, .pair E C v u hv hu hne T hTc d hd, hdict, hh⟩omit [Fintype V] [Fintype D] in
lemma encoding_path_lift (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) {E F : Finset V} (h : Relation.ReflTransGen (EncodingStep s hit a K) E F) (C : Finset (B × D)) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) : ∃ C', Relation.ReflTransGen (PaidStep s hit a K) (E, C) (F, C') ∧ DictionaryInvariant s F C' ∧ Realized hit C' := by induction h with | refl => exact ⟨C, .refl, hC, hreal⟩ | @tail F G h hFG ih => obtain ⟨C', hpath, hc', hr'⟩ := ih obtain ⟨C'', hstep, hc'', hr''⟩ := encodingStep_lift s hit a K hFG C' hc' hr' exact ⟨C'', hpath.tail hstep, hc'', hr''⟩
omit [Fintype V] inomit [Fintype D] [Fintype B] in
lemma paid_path_cost (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) (haK : a ≤ K) {Z Z' : Finset V × Finset (B × D)} (h : Relation.ReflTransGen (PaidStep s hit a K) Z Z') : Z'.2.card + K * Z.1.card ≤ Z.2.card + K * Z'.1.card := by induction h with | refl => omega | @tail F G h hFG ih => have hc := paidStep_cost s hit a K haK hFG omega
omit [Fintype D] in
theorem terminal_paid_certificate (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) (haK : a ≤ K) (E : Finset V) : ∃ F C, Relation.ReflTransGen (PaidStep s hit a K) (E, ∅) (F, C) ∧ DictionaryInvariant s F C ∧ Realized hit C ∧ C.card ≤ K * Fintype.card V ∧ (paidDirections C).card ≤ K * Fintype.card V ∧ (∀ v ∉ F, (touchedToEncoded s hit F v).card < a) ∧ ∀ v ∉ F, ∀ u ∉ F, v ≠ u → (sharedBatches (outsideDirections s F) hit v u).card < K := by classical obtain ⟨F, hF, ha, hp⟩ := exists_terminal_encoding s hit a K E have hc : DictionaryInvariant s E (∅ : Finset (B × D)) := by simp [DictionaryInvariant, paidDirections] have hr : Realized hit (∅ : Finset (B × D)) := by simp [Realized] obtain ⟨C, hpath, hC, hreal⟩ := encoding_path_lift s hit a K hF ∅ hc hr have hcost := paid_path_cost s hit a K haK hpath simp only [Finset.card_empty, zero_add] at hcost have hbound : C.card ≤ K * Fintype.card V := by have hcard := Nat.mul_le_mul_left K (Finset.card_le_univ F) omega exact ⟨F, C, hpath, hC, hreal, hbound, Finset.card_image_le.trans hbound, ha, hp⟩
end SharedHitGeometry
end SharpRamseyFive.ResidualCertificate
namespace SharpRamseyFive.CertificateCoveropen SharpRamseyFive.StaticCertificatesopen SharpRamseyFive.CertificateEnumerationopen SharpRamseyFive.WeightedProgramsopen SharpRamseyFive.ResidualCertificateopen scoped BigOperators
variable {V H D B : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B]variable (lines : H → Finset D)
def Agrees (f : V → H) (E : Finset V) (s : State V H D B) : Prop := ∀ v ∈ E, s.1 v = f v
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B] inlemma agrees_update (f : V → H) (E : Finset V) (s : State V H D B) (hs : Agrees f E s) (v : V) (C : Finset (B × D)) : Agrees f (insert v E) (Function.update s.1 v (f v), C) := by intro u hu rcases Finset.mem_insert.mp hu with rfl | hu · simp · by_cases he : u = v · subst u; simp · simpa [Function.update_of_ne he] using hs u hu
noncomputable def anchorName (C : Finset (B × D)) (S : Finset D) (d : D) (hd : d ∈ S) (r : B) : AnchorChoice C S := if he : d ∈ dictionary C then .inl ⟨d, Finset.mem_inter.mpr ⟨hd, he⟩⟩ else .inr (r, ⟨d, Finset.mem_sdiff.mpr ⟨hd, he⟩⟩)
omit [Fintype D] [Fintype B] [DecidableEq B] inlemma anchorName_direction (C : Finset (B × D)) (S : Finset D) (d : D) (hd : d ∈ S) (r : B) : (anchorName C S d hd r).direction = d := by unfold anchorName split_ifs <;> rfl
omit [Fintype D] [Fintype B] [DecidableEq B] inlemma anchorName_realized (hit : B → D → Prop) (C : Finset (B × D)) (S : Finset D) (d : D) (hd : d ∈ S) (r : B) (hr : hit r d) : Realized hit (anchorName C S d hd r).requirements := by unfold anchorName split_ifs <;> simp_all [AnchorChoice.requirements, Realized]
omit [Fintype D] [Fintype B] [DecidableEq B] inlemma anchor_req_card {C : Finset (B × D)} {S : Finset D} (a : AnchorChoice C S) : a.requirements.card ≤ 1 := by cases a <;> simp [AnchorChoice.requirements]
omit [Fintype D] [Fintype B] [DecidableEq B] inlemma anchor_req_directions {C : Finset (B × D)} {S : Finset D} (a : AnchorChoice C S) : paidDirections a.requirements ⊆ {a.direction} := by cases a <;> simp [AnchorChoice.requirements, AnchorChoice.direction, paidDirections]omit [Fintype D] [Fintype B] [DecidableEq B] in
lemma anchor_req_disjoint {C : Finset (B × D)} {S T : Finset D} (a : AnchorChoice C S) (b : AnchorChoice C T) (hne : a.direction ≠ b.direction) : Disjoint a.requirements b.requirements := by apply Finset.disjoint_left.mpr intro p ha hb have ha' := anchor_req_directions a (Finset.mem_image_of_mem Prod.snd ha) have hb' := anchor_req_directions b (Finset.mem_image_of_mem Prod.snd hb) exact hne ((Finset.mem_singleton.mp ha').symm.trans (Finset.mem_singleton.mp hb'))
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inomit [Fintype D] inlemma rawCost_eq_weight (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) (henabled : ∀ c : OneChoice lines s, a = .inr (.inl c) → low = true) : rawCost lines rate denom K low s a = weight (fun p : B × D => rate p.2) (newEvents lines K s a) / denom ^ degree lines K s a := by rcases a with a | a · simp [rawCost, newEvents, degree, weight] rcases a with a | a · rw [henabled a rfl] simp [rawCost, newEvents, degree, oneCost, AnchorChoice.weight] rcases a with a | a · simp only [rawCost, newEvents, degree, twoCost, pow_one] rw [weight_union_fresh _ _ _ (anchor_req_disjoint _ _ a.2.2.2.2.2.property.1), AnchorChoice.weight, AnchorChoice.weight] · rfl
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inomit [Fintype D] inlemma newEvents_card (K : ℕ) (hK : 2 ≤ K) (s : State V H D B) (a : Action lines K s) : (newEvents lines K s a).card ≤ K * degree lines K s a := by rcases a with a | a · simp [newEvents, degree] rcases a with a | a · simpa [newEvents, degree] using (anchor_req_card a.2.2.1).trans (by omega : 1 ≤ K) rcases a with a | a · change (a.2.2.2.1.requirements ∪ a.2.2.2.2.1.requirements).card ≤ K * 1 have hc := Finset.card_union_le a.2.2.2.1.requirements a.2.2.2.2.1.requirements have h1 := anchor_req_card a.2.2.2.1 have h2 := anchor_req_card a.2.2.2.2.1 omega · simp only [newEvents, degree, witnessRequirements_card] have ht := (Finset.mem_powersetCard.mp a.2.2.2.2.1.property).2 omega
def Enabled (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : Prop := ∀ c : OneChoice lines s, a = .inr (.inl c) → low = true
omit [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma step_weight (rate : D → ℝ≥0) (denom : ℝ) (hdenom : denom ≠ 0) (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) (he : Enabled lines K low s a) (hs : s.2.card ≤ K * Fintype.card V) : weight (fun p : B × D => rate p.2) (advance lines K s a).2 = weight (fun p : B × D => rate p.2) s.2 * programCost lines rate denom K low s a * denom ^ degree lines K s a := by rw [programCost, ite_eq_left hs, rawCost_eq_weight lines rate denom K low s a he] rw [advance, weight_union_fresh _ _ _ (newEvents_fresh lines K s a)] field_simp
def Coherent (f : V → H) (hit : B → D → Prop) (K : ℕ) (E : Finset V) (s : State V H D B) : Prop := Agrees f E s ∧ DictionaryInvariant (fun v => lines (f v)) E s.2 ∧ Realized hit s.2 ∧ s.2.card ≤ K * E.cardomit [Fintype V] [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma coherent_step (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (E F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (a : Action lines K s) (hEF : E ⊆ F) (hag : Agrees f F (advance lines K s a)) (hdict : paidDirections (newEvents lines K s a) ⊆ encodedDirections (fun v => lines (f v)) F) (hreal : Realized hit (newEvents lines K s a)) (hcard : F.card = E.card + degree lines K s a) : Coherent lines f hit K F (advance lines K s a) := by refine ⟨hag, ?_, realized_union hit hs.2.2.1 hreal, ?_⟩ · change paidDirections (s.2 ∪ newEvents lines K s a) ⊆ _ rw [paidDirections_union] exact Finset.union_subset (hs.2.1.trans (encodedDirections_mono _ hEF)) hdict · change (s.2 ∪ newEvents lines K s a).card ≤ _ apply (Finset.card_union_le _ _).trans calc _ ≤ K * E.card + K * degree lines K s a := Nat.add_le_add hs.2.2.2 (newEvents_card lines K hK s a) _ = _ := by rw [hcard, Nat.mul_add]
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inomit [Fintype D] [DecidableEq B] inlemma touched_anchor (f : V → H) (hit : B → D → Prop) (E : Finset V) (s : State V H D B) (hs : Agrees f E s) (v : V) (d : D) (hd : d ∈ touchedToEncoded (fun v => lines (f v)) hit E v) : ∃ u ∈ E, ∃ x : AnchorChoice s.2 (lines (s.1 u)), x.direction = d ∧ d ∈ lines (f v) ∧ Realized hit x.requirements := by classical obtain ⟨hgeom, r, hr⟩ := Finset.mem_filter.mp hd obtain ⟨hv, henc⟩ := Finset.mem_inter.mp hgeom obtain ⟨u, hu, hdu⟩ := Finset.mem_biUnion.mp henc have hdu' : d ∈ lines (s.1 u) := by rw [hs u hu]; exact hdu exact ⟨u, hu, anchorName s.2 _ d hdu' r, anchorName_direction _ _ _ _ _, hv, anchorName_realized hit _ _ _ _ _ hr⟩
omit [Fintype V] [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma make_one (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (v : V) (hv : v ∉ E) (ha : 1 ≤ (touchedToEncoded (fun v => lines (f v)) hit E v).card) : ∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧ (insert v E).card = E.card + degree lines K s a ∧ Enabled lines K true s a ∧ actionCharge lines K s a = 0 := by classical obtain ⟨d, hd⟩ := Finset.card_pos.mp (by omega : 0 < (touchedToEncoded (fun v => lines (f v)) hit E v).card) obtain ⟨u, hu, x, hxd, hdv, hxreal⟩ := touched_anchor lines f hit E s hs.1 v d hd let c : OneChoice lines s := ⟨v, u, x, f v, hxd ▸ hdv⟩ let a : Action lines K s := .inr (.inl c) have hc : (insert v E).card = E.card + degree lines K s a := by simp [a, degree, Finset.card_insert_of_notMem hv] refine ⟨a, ?_, hc, fun _ _ => rfl, rfl⟩ apply coherent_step lines f hit K hK E (insert v E) s hs a (Finset.subset_insert _ _) _ _ hxreal hc · exact agrees_update f E s hs.1 v _ · apply (anchor_req_directions x).trans intro z hz have hz' : z = x.direction := Finset.mem_singleton.mp hz apply Finset.mem_biUnion.mpr exact ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hxd ▸ hdv)⟩omit [Fintype V] [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma make_two (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (v : V) (hv : v ∉ E) (ha : 2 ≤ (touchedToEncoded (fun v => lines (f v)) hit E v).card) : ∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧ (insert v E).card = E.card + degree lines K s a ∧ Enabled lines K low s a ∧ actionCharge lines K s a = 1 := by classical obtain ⟨d, hd, e, he, hde⟩ := Finset.one_lt_card.mp (by omega : 1 < (touchedToEncoded (fun v => lines (f v)) hit E v).card) obtain ⟨u, hu, x, hxd, hdv, hxreal⟩ := touched_anchor lines f hit E s hs.1 v d hd obtain ⟨w, hw, y, hye, hev, hyreal⟩ := touched_anchor lines f hit E s hs.1 v e he let c : TwoChoice lines s := ⟨v, u, w, x, y, f v, by simpa only [hxd, hye] using And.intro hde (And.intro hdv hev)⟩ let a : Action lines K s := .inr (.inr (.inl c)) have hc : (insert v E).card = E.card + degree lines K s a := by simp [a, degree, Finset.card_insert_of_notMem hv] refine ⟨a, ?_, hc, ?_, rfl⟩ · apply coherent_step lines f hit K hK E (insert v E) s hs a (Finset.subset_insert _ _) _ _ (realized_union hit hxreal hyreal) hc · exact agrees_update f E s hs.1 v _ · change paidDirections (x.requirements ∪ y.requirements) ⊆ _ rw [paidDirections_union] apply Finset.union_subset · apply (anchor_req_directions x).trans intro z hz have hz' := Finset.mem_singleton.mp hz exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hxd ▸ hdv)⟩ · apply (anchor_req_directions y).trans intro z hz have hz' := Finset.mem_singleton.mp hz exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hye ▸ hev)⟩ · intro c' he simp [a] at heend SharpRamseyFive.CertificateCoverend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.TruncatedTupleIntegrableimport OAI.Combinatorics.SharpRamsey.Entropy.MakePair
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen scoped BigOperatorsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators ENNReal NNRealnamespace SharpRamseyFive.CertificateCoveropen SharpRamseyFive.StaticCertificatesopen SharpRamseyFive.CertificateEnumerationopen SharpRamseyFive.WeightedProgramsopen SharpRamseyFive.ResidualCertificateopen scoped BigOperatorsvariable {V H D B : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B]variable (lines : H → Finset D)omit [Fintype H] [DecidableEq H] [Fintype D] inlemma complete_program_weight (rate : D → ℝ≥0) (denom : ℝ) (hd : denom ≠ 0) (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) (c : completePrograms lines K low E s) : weight (fun p : B × D => rate p.2) (finish lines K s c.val.2).2 = (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.val.2 := by rw [trace_weight lines rate denom hd K low s c.val.2 c.property.1, c.property.2.2] ringomit [Fintype D] in
lemma complete_program_sum (rate : D → ℝ≥0) (denom b mass : ℝ) (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) (K N₁ N₂ : ℕ) (low : Bool) (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) (E : Finset V) (s : State V H D B) : (∑ c : completePrograms lines K low E s, weight (fun p : B × D => rate p.2) (finish lines K s c.val.2).2) ≤ (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * ∑ n : Fin (Fintype.card V - E.card + 1), branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by classical simp_rw [complete_program_weight lines rate denom hd.ne' K low E s] rw [← Finset.mul_sum] apply mul_le_mul_of_nonneg_left _ (mul_nonneg (weight_nonneg _ _) (pow_nonneg hd.le _)) change (∑ c : {c : AllPrograms lines K E s // CompleteProgram lines K low E s c}, dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.val.2) ≤ _ have hsub := Finset.sum_subtype (p := CompleteProgram lines K low E s) (F := completePrograms_fintype lines K low E s) (Finset.univ.filter (CompleteProgram lines K low E s)) (fun _ => by simp) (fun c : AllPrograms lines K E s => dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.2) rw [← hsub, Finset.sum_filter] change (∑ c : AllPrograms lines K E s, if CompleteProgram lines K low E s c then dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.2 else 0) ≤ _ rw [Fintype.sum_sigma] apply Finset.sum_le_sum intro n _ apply le_trans _ (program_enumeration lines rate denom b mass hd.le hb hm hmass K N₁ N₂ low hN₁ hN₂ n.val s) apply Finset.sum_le_sum intro w _ by_cases hc : CompleteProgram lines K low E s ⟨n, w⟩ · simp only [ite_eq_left hc, ite_eq_left hc.2.1] exact le_rfl · simp only [ite_eq_right hc] split_ifs · exact dWeight_nonneg (Action lines K) (advance lines K) _ (programCost_nonneg lines rate denom hd.le K low) s w · exact le_rfl
def badEvent (K J : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) (f : V → H) : Set ((B × D) → ℕ) := {ω | Function.Injective f ∧ Coherent lines f (fun r d => ω (r, d) ≠ 0) K E s ∧ (∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches (fun v => lines (f v)) (fun r d => ω (r, d) ≠ 0) v).card) ∧ (low = false → ∀ d, (Finset.univ.filter (fun r => ω (r, d) ≠ 0)).card ≤ J)}omit [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma bad_event_cover (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (E : Finset V) (s : State V H D B) (f : V → H) (ω : (B × D) → ℕ) (hω : ω ∈ badEvent lines K J low E s f) : ∃ c : completePrograms lines K low E s, (finish lines K s c.val.2).1 = f ∧ ω ∈ positiveEvent (finish lines K s c.val.2).2 := by classical have hex : ∃ n, ∃ w : Word lines K n s, Segment lines f (fun r d => ω (r, d) ≠ 0) K low E Finset.univ s w ∧ 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by cases low with | false => exact bad_program_high lines f hω.1 (fun r d => ω (r, d) ≠ 0) K J h hK hh hsize E s hω.2.1 hω.2.2.1 (hω.2.2.2 rfl) herr | true => apply bad_program_low lines f hω.1 (fun r d => ω (r, d) ≠ 0) K h hK hh _ E s hω.2.1 hω.2.2.1 herr simpa using hsize obtain ⟨n, w, hw, hq, hn⟩ := hex have hc : CompleteProgram lines K low E s ⟨⟨n, by omega⟩, w⟩ := by refine ⟨hw.2.2, hq, ?_⟩ change degreeSum lines K s w = Fintype.card V - E.card have he := hw.2.1 simp only [Finset.card_univ] at he omega refine ⟨⟨⟨⟨n, by omega⟩, w⟩, hc⟩, ?_, ?_⟩ · funext v exact hw.1.1 v (Finset.mem_univ _) · intro p hp exact hw.1.2.2.1 p hp
theorem bad_completion_bound (rate : D → ℝ≥0) (denom b mass : ℝ) (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) (E : Finset V) (s : State V H D B) : (∑ f : V → H, (poissonLaw (fun p : B × D => rate p.2)).real (badEvent lines K J low E s f)) ≤ (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * ∑ n : Fin (Fintype.card V - E.card + 1), branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by classical apply le_trans _ (complete_program_sum lines rate denom b mass hd hb hm hmass K N₁ N₂ low hN₁ hN₂ E s) apply decoded_static_union_bound rate (fun c : completePrograms lines K low E s => (finish lines K s c.val.2).2) (fun c => (finish lines K s c.val.2).1) (badEvent lines K J low E s) · intro f exact (Set.to_countable _).measurableSet · intro f ω hω exact bad_event_cover lines K J h hK hh low hsize herr E s f ω hω
def selectedBadEvent (K J : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) (f : V → H) : Set ((B × D) → ℕ) := by classical exact {ω | Function.Injective f ∧ ∃ hit : B → D → Prop, (∀ r d, hit r d → ω (r, d) ≠ 0) ∧ Coherent lines f hit K E s ∧ (∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches (fun v => lines (f v)) hit v).card) ∧ (low = false → ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J)}omit [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma selected_bad_event_cover (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (E : Finset V) (s : State V H D B) (f : V → H) (ω : (B × D) → ℕ) (hω : ω ∈ selectedBadEvent lines K J low E s f) : ∃ c : completePrograms lines K low E s, (finish lines K s c.val.2).1 = f ∧ ω ∈ positiveEvent (finish lines K s c.val.2).2 := by classical obtain ⟨hfi, hit, hpos, hco, hbad, htr⟩ := hω have hex : ∃ n, ∃ w : Word lines K n s, Segment lines f hit K low E Finset.univ s w ∧ 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by cases low with | false => exact bad_program_high lines f hfi hit K J h hK hh hsize E s hco hbad (htr rfl) herr | true => apply bad_program_low lines f hfi hit K h hK hh _ E s hco hbad herr simpa using hsize obtain ⟨n, w, hw, hq, hn⟩ := hex have hc : CompleteProgram lines K low E s ⟨⟨n, by omega⟩, w⟩ := by refine ⟨hw.2.2, hq, ?_⟩ change degreeSum lines K s w = Fintype.card V - E.card have he := hw.2.1 simp only [Finset.card_univ] at he omega refine ⟨⟨⟨⟨n, by omega⟩, w⟩, hc⟩, ?_, ?_⟩ · funext v exact hw.1.1 v (Finset.mem_univ _) · intro p hp exact hpos p.1 p.2 (hw.1.2.2.1 p hp)
theorem selected_bad_completion_bound (rate : D → ℝ≥0) (denom b mass : ℝ) (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) (E : Finset V) (s : State V H D B) : (∑ f : V → H, (poissonLaw (fun p : B × D => rate p.2)).real (selectedBadEvent lines K J low E s f)) ≤ (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * ∑ n : Fin (Fintype.card V - E.card + 1), branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by classical apply le_trans _ (complete_program_sum lines rate denom b mass hd hb hm hmass K N₁ N₂ low hN₁ hN₂ E s) apply decoded_static_union_bound rate (fun c : completePrograms lines K low E s => (finish lines K s c.val.2).2) (fun c => (finish lines K s c.val.2).1) (selectedBadEvent lines K J low E s) · intro f exact (Set.to_countable _).measurableSet · intro f ω hω exact selected_bad_event_cover lines K J h hK hh low hsize herr E s f ω hω
end SharpRamseyFive.CertificateCover
namespace SharpRamseyFive.SelectionBridgeopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignationsopen SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedProgramsopen Classicalvariable {D V H C : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype C] [DecidableEq C]omit [DecidableEq D] in
lemma restriction_preserving (rate : D → ℝ≥0) (lab : D → Option C) (R : ℕ) : MeasurePreserving (fun ω : Fin R × D → ℕ => fun i : Block lab R none => ω i) (batchMeasure (fun i : Fin R × D => rate i.2)) (batchMeasure (fun i : Block lab R none => rate i.1.2)) := by exact (measurePreserving_eval (fun c : Option C => batchMeasure (fun i : Block lab R c => rate i.1.2)) none).comp (measurePreserving_partition (fun i : Fin R × D => rate i.2) (fun i => lab i.2))omit [DecidableEq D] in
lemma integral_restriction (rate : D → ℝ≥0) (lab : D → Option C) (R : ℕ) (F : (Block lab R none → ℕ) → ℝ) : (∫ z, F z ∂batchMeasure (fun i : Block lab R none => rate i.1.2)) = ∫ ω, F (fun i => ω i) ∂batchMeasure (fun i : Fin R × D => rate i.2) := by have h := restriction_preserving rate lab R rw [← h.map_eq] exact integral_map h.measurable.aemeasurable (measurable_of_countable F).aestronglyMeasurableomit [Fintype D] [DecidableEq V] in
lemma label_none_external (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) {v : V} {d : D} (hd : d ∈ s v) (he : componentLabel weight s t d = none) : External weight s t d := by by_contra hn have hi := componentLabel_internal weight s t (Finset.mem_filter.mpr ⟨hd,hn⟩) rw [he] at hi cases hi
noncomputable def selectedHit (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) {R : ℕ} (ω : Fin R × D → ℕ) (r : Fin R) (d : D) : Prop := componentLabel weight s t d = none ∧ ω (r,d) ≠ 0
lemma touched_equals_shared (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (R : ℕ) (ω : Fin R × D → ℕ) (v : V) : TupleComponents.hitBatches (touched (componentLabel weight s t) R ((strongGraph weight s t).connectedComponentMk v) (s v) (fun i => ω i)) = ResidualCertificate.touchedBatches s (selectedHit weight s t ω) v := by ext r simp only [TupleComponents.hitBatches, touched, Finset.mem_filter, Finset.mem_univ, true_and, decide_eq_true_eq, ResidualCertificate.touchedBatches, ResidualCertificate.sharedBatches, Finset.mem_inter] constructor · rintro ⟨d,hd,hpos⟩ obtain ⟨u,hu,hdiff⟩ := (external_iff_other weight s t hd).mp (label_none_external weight s t hd d.property) refine ⟨u, ?_, d, ⟨hd,hu⟩, d.property,hpos⟩ intro he subst u exact hdiff rfl · rintro ⟨u,_,d,⟨hd,_⟩,he,hpos⟩ exact ⟨⟨d,he⟩,hd,hpos⟩
omit [DecidableEq V] inlemma selected_trunc (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (R J : ℕ) (ω : Fin R × D → ℕ) (htr : blockTrunc (componentLabel weight s t) R J none (fun i => ω i) ≠ 0) : ∀ d, (Finset.univ.filter (fun r => selectedHit weight s t ω r d)).card ≤ J := by intro d by_cases hd : componentLabel weight s t d = none · have hp : lineTrunc R J (fun r => ω (r,d)) ≠ 0 := Finset.prod_ne_zero_iff.mp htr ⟨d,hd⟩ (Finset.mem_univ _) have hh : (Finset.univ.filter (fun r => ω (r,d) ≠ 0)).card < J := by by_contra hn exact hp (ite_eq_right hn) simpa only [selectedHit, hd, true_and] using hh.le · simp only [selectedHit, hd, false_and, Finset.filter_false, Finset.card_empty] exact Nat.zero_le _
noncomputable def vertexBadMass (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (R J : ℕ) (A : Finset V) : ℝ := badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => rate i.1.2)) (blockTrunc (componentLabel weight s t) R J none) (fun v z => BAD (touched (componentLabel weight s t) R ((strongGraph weight s t).connectedComponentMk v) (s v) z)) A
omit [Fintype D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inlemma empty_coherent (lines : H → Finset D) (f g : V → H) (R K : ℕ) (E : Finset V) (hit : Fin R → D → Prop) (he : ∀ v ∈ E, g v = f v) : Coherent lines f hit K E (g,∅) := by refine ⟨he, ?_, ?_, ?_⟩ · simp [ResidualCertificate.DictionaryInvariant, ResidualCertificate.paidDirections] · intro p hp exact False.elim (Finset.notMem_empty p hp) · simpomit [Fintype H] [DecidableEq H] in
lemma bad_mass_le_selected_event (weight rate : D → ℝ≥0) (lines : H → Finset D) (f g : V → H) (hf : Function.Injective f) (R J K : ℕ) (t : ℝ) (low : Bool) (A : Finset V) (he : ∀ v ∈ Finset.univ \ A, g v = f v) : vertexBadMass weight rate (lines ∘ f) t R J A ≤ (StaticCertificates.poissonLaw (fun i : Fin R × D => rate i.2)).real (selectedBadEvent lines K J low (Finset.univ \ A) (g,∅) f) := by let lab := componentLabel weight (lines ∘ f) t let bad := fun v z => BAD (touched lab R ((strongGraph weight (lines ∘ f) t).connectedComponentMk v) (lines (f v)) z) let T := blockTrunc lab R J none let E : Set ((Fin R × D) → ℕ) := selectedBadEvent lines K J low (Finset.univ \ A) (g,∅) f have hE : MeasurableSet E := (Set.to_countable _).measurableSet change (∫ z, T z * ∏ v ∈ A, badIndicator bad v z ∂batchMeasure (fun i : Block lab R none => rate i.1.2)) ≤ _ rw [integral_restriction rate lab R] have hi : Integrable (fun ω : Fin R × D → ℕ => T (fun i => ω i) * ∏ v ∈ A, badIndicator bad v (fun i => ω i)) (batchMeasure (fun i : Fin R × D => rate i.2)) := by apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable 1 apply Filter.Eventually.of_forall intro ω rw [Real.norm_eq_abs, abs_of_nonneg (badTerm_range T (blockTrunc_range lab R J none) bad A (fun i => ω i)).1] exact (badTerm_range T (blockTrunc_range lab R J none) bad A (fun i => ω i)).2 change _ ≤ (batchMeasure (fun i : Fin R × D => rate i.2)).real E rw [← integral_indicator_one hE] apply integral_mono hi ((integrable_const (1 : ℝ)).indicator hE) intro ω dsimp only by_cases hz : T (fun i => ω i) * ∏ v ∈ A, badIndicator bad v (fun i => ω i) = 0 · rw [hz] exact Set.indicator_nonneg (fun _ _ => zero_le_one) ω · have ht : T (fun i => ω i) ≠ 0 := (mul_ne_zero_iff.mp hz).1 have hb : ∀ v ∈ A, bad v (fun i => ω i) := by intro v hv have hn := Finset.prod_ne_zero_iff.mp (mul_ne_zero_iff.mp hz).2 v hv by_contra hn' exact hn (ite_eq_right hn') have hmem : ω ∈ E := by refine ⟨hf, selectedHit weight (lines ∘ f) t ω, ?_, ?_, ?_, ?_⟩ · intro r d hd exact hd.2 · exact empty_coherent lines f g R K (Finset.univ \ A) _ he · intro v hv have hvA : v ∈ A := by simpa using hv have hvb := hb v hvA change R / 2 ≤ (TupleComponents.hitBatches (touched lab R ((strongGraph weight (lines ∘ f) t).connectedComponentMk v) (lines (f v)) (fun i => ω i))).card at hvb change R / 2 ≤ (TupleComponents.hitBatches (touched (componentLabel weight (lines ∘ f) t) R ((strongGraph weight (lines ∘ f) t).connectedComponentMk v) ((lines ∘ f) v) (fun i => ω i))).card at hvb rw [touched_equals_shared weight (lines ∘ f) t R ω v] at hvb simpa only [Fintype.card_fin, Function.comp_def] using hvb · intro _ exact selected_trunc weight (lines ∘ f) t R J ω ht rw [Set.indicator_of_mem hmem] exact (badTerm_range T (blockTrunc_range lab R J none) bad A (fun i => ω i)).2omit [Fintype D] [Fintype V] [DecidableEq V] in
lemma vertex_injective (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : Function.Injective (vertex weight s t) := by intro c d he have h := congrArg (strongGraph weight s t).connectedComponentMk he simpa only [vertex_color] using h
lemma component_bad_mass_eq_vertex (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (R J : ℕ) (U : Finset (Components weight s t)) : badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => rate i.1.2)) (blockTrunc (componentLabel weight s t) R J none) (isBad weight s t R) U = vertexBadMass weight rate s t R J (U.image (vertex weight s t)) := by unfold badMass vertexBadMass congr 1 funext z congr 1 rw [Finset.prod_image (fun _ _ _ _ he => vertex_injective weight s t he)] apply Finset.prod_congr rfl intro c hc simp only [badIndicator, isBad, vertex_color] split_ifs with h <;> simp only [h, ite_true, ite_false]
theorem bad_residual_sum_le (weight rate : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) (R : ℕ) (denom b mass : ℝ) (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) (A : Finset V) (g : V → H) : (∑ f : V → H, if Function.Injective f ∧ (∀ v ∉ A, g v = f v) then vertexBadMass weight rate (lines ∘ f) t R J A else 0) ≤ denom ^ A.card * ∑ n : Fin (A.card + 1), branchingBound (V := V) (B := Fin R) lines rate denom b mass K N₁ N₂ low ^ n.val := by have hbnd := selected_bad_completion_bound (V := V) (B := Fin R) lines rate denom b mass hd hb hm hmass K J h N₁ N₂ hK hh low (by simpa only [Fintype.card_fin] using hsize) herr hN₁ hN₂ (Finset.univ \ A) (g,∅) have heq : Fintype.card V - (Finset.univ \ A).card = A.card := by rw [Finset.card_sdiff_of_subset (Finset.subset_univ A)] simp only [Finset.card_univ] have := Finset.card_le_card (Finset.subset_univ A) simp only [Finset.card_univ] at this omega rw [Fin.sum_univ_eq_sum_range] at hbnd ⊢ simp only [heq, StaticCertificates.weight, Finset.prod_empty, one_mul] at hbnd apply le_trans _ hbnd apply Finset.sum_le_sum intro f hf split_ifs with hfi · apply bad_mass_le_selected_event weight rate lines f g hfi.1 R J K t low A intro v hv exact hfi.2 v (Finset.mem_sdiff.mp hv).2 · exact ENNReal.toReal_nonneg
end SharpRamseyFive.SelectionBridge
namespace SharpRamseyFive.SelectionBridgeopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignationsopen SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedProgramsopen Classicalvariable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
def labelled (f : V → H) (v : V) : H × V := (f v, v)
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inlemma labelled_injective (f : V → H) : Function.Injective (labelled f) := by intro u v h exact congrArg Prod.snd h
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inlemma labelled_map_injective : Function.Injective (labelled : (V → H) → (V → H × V)) := by intro f g h funext v exact congrArg Prod.fst (congrFun h v)
end SharpRamseyFive.SelectionBridgeend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.ExternalMass
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealnamespace SharpRamseyFive.TupleComponentsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScoreopen Classicalvariable {D V C : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]variable (label : D → Option C) (R : ℕ)variable (color : V → C) (s : V → Finset D) (b : ℝ) (own : V → Fin R → Bool)omit [Fintype D] [DecidableEq V] inlemma componentLabel_witness (weight : D → ℝ≥0) (t : ℝ) (d : D) (c : (strongGraph weight s t).ConnectedComponent) (hc : componentLabel weight s t d = some c) : ∃ v, d ∈ s v ∧ (strongGraph weight s t).connectedComponentMk v = c := by unfold componentLabel at hc split_ifs at hc with h h' exact ⟨h.choose, h.choose_spec, Option.some.inj hc⟩omit [DecidableEq V] in
lemma simple_inside_univ (weight : D → ℝ≥0) (t : ℝ) (v : V) (hsingle : ∀ u, (strongGraph weight s t).connectedComponentMk u = (strongGraph weight s t).connectedComponentMk v → u = v) : inside (componentLabel weight s t) ((strongGraph weight s t).connectedComponentMk v) (s v) = Finset.univ := by apply Finset.eq_univ_of_forall intro d obtain ⟨u, hu, hc⟩ := componentLabel_witness s weight t d.val _ d.property have he := hsingle u hc simpa [inside, he] using hu
omit [DecidableEq D] [Fintype C] inlemma blockTrunc_eq_indicator (J : ℕ) (c : C) (x : Block label R (some c) → ℕ) : blockTrunc label R J (some c) x = (overloaded Finset.univ J)ᶜ.indicator (fun _ => (1 : ℝ)) (unblock label R c x) := by by_cases he : unblock label R c x ∈ overloaded Finset.univ J · simp only [Set.indicator_of_notMem (show unblock label R c x ∉ (overloaded Finset.univ J)ᶜ by simpa using he)] obtain ⟨d, _, hd⟩ := he apply Finset.prod_eq_zero (Finset.mem_univ d) change lineTrunc R J (fun r => x ⟨(r,d), d.property⟩) = 0 have hn : ¬ (Finset.univ.filter (fun r => x ⟨(r,d), d.property⟩ ≠ 0)).card < J := by exact not_lt.mpr hd simp only [lineTrunc, ite_eq_right hn] · rw [Set.indicator_of_mem (show unblock label R c x ∈ (overloaded Finset.univ J)ᶜ by simpa using he)] apply Finset.prod_eq_one intro d _ change lineTrunc R J (fun r => x ⟨(r,d), d.property⟩) = 1 have hd : (Finset.univ.filter (fun r => x ⟨(r,d), d.property⟩ ≠ 0)).card < J := by by_contra hn exact he ⟨d, Finset.mem_univ _, not_lt.mp hn⟩ simp only [lineTrunc, ite_eq_left hd]
omit [DecidableEq V] inomit [Fintype C] inlemma componentFactor_eq_single (J : ℕ) (c : C) (v : {v : V // color v = c}) (hsingle : ∀ u, color u = c → u = v.val) (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : componentFactor label R color s b own J c z x = (overloaded (inside label c (s v)) J)ᶜ.indicator (maskedTerm (inside label c (s v)) b (own v) (touched label R c (s v) z)) (unblock label R c x) := by have hp : (∏ u : {v : V // color v = c}, scoreTerm (s u) b (own u) (fill label R c z x)) = scoreTerm (s v) b (own v) (fill label R c z x) := by apply Finset.prod_eq_single v · intro u _ huv exfalso exact huv (Subtype.ext (hsingle u u.property)) · simp rw [componentFactor, hp, scoreTerm_eq_masked label R c (s v) b (own v) hcompat, blockTrunc_eq_indicator label R J c, hin] by_cases he : unblock label R c x ∈ (overloaded Finset.univ J)ᶜ <;> simp [he]omit [DecidableEq V] inomit [Fintype C] in
lemma simple_component_integral (rate : D → ℝ≥0) (J : ℕ) (c : C) (v : {v : V // color v = c}) (hsingle : ∀ u, color u = c → u = v.val) (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) : (∫ x, componentFactor label R color s b own J c z x ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) = ∫ w, (overloaded (inside label c (s v)) J)ᶜ.indicator (maskedTerm (inside label c (s v)) b (own v) (touched label R c (s v) z)) w ∂scheduleMeasure (fun d : IntDir label c => rate d) R := by simp_rw [componentFactor_eq_single label R color s b own J c v hsingle hcompat hin] exact (measurePreserving_unblock label R rate c).integral_comp (unblockEquiv label R c).measurableEmbedding _omit [DecidableEq V] inomit [Fintype C] in
lemma simple_component_attenuation (rate : D → ℝ≥0) (J : ℕ) (c : C) (v : {v : V // color v = c}) (hsingle : ∀ u, color u = c → u = v.val) (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) {L base delta alpha : ℝ} (hL : 10000 ≤ L) (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * (base + delta - alpha)) (hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} (hN : N ≤ (untouchedBatches (touched label R c (s v) z)).card) (hK : K ≤ N) : |∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K + ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J) := by rw [simple_component_integral label R color s _ own rate J c v hsingle hcompat hin z] exact simple_singleton_truncated _ _ J (own v) (touched label R c (s v) z) hL hmass hint hbase ha hd hN hKomit [Fintype C] in
lemma nonsimple_component_attenuation (rate : D → ℝ≥0) (J : ℕ) (c : C) (v : {v : V // color v = c}) (z : Block label R none → ℕ) (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) {L lam base : ℝ} (hL : 10000 ≤ L) (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * lam) (hlam : (37 / 50 : ℝ) ≤ lam) (hbase : (37 / 50 : ℝ) ≤ base) : (∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) ≤ Real.exp (-(7 / 10 : ℝ) * (L * R)) := by apply (component_integral_abs_le label R color s own rate J c v z hcompat (show 0 ≤ L by linarith) (by norm_num : (0 : ℝ) ≤ 37 / 50) hmass hlam hbase).trans have he : (2 : ℝ) ≤ Real.exp ((1 / 25 : ℝ) * L) := by have := Real.add_one_le_exp ((1 / 25 : ℝ) * L) linarith have hmul := mul_le_mul_of_nonneg_right he (Real.exp_pos (-L * (37 / 50 : ℝ))).le rw [← Real.exp_add] at hmul have hpow := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ 2 * Real.exp (-L * (37 / 50 : ℝ))) hmul R rw [← Real.exp_nat_mul] at hpow convert hpow using 1 ; congr 1 ; ring
end SharpRamseyFive.TupleComponents
namespace SharpRamseyFive.TupleMultiplicityopen scoped BigOperatorsopen Classicalvariable {V H : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
abbrev RepresentativeMap (V : Type*) := {r : V → V // ∀ v, r (r v) = r v}abbrev Representatives (r : RepresentativeMap V) := {v : V // r.val v = v}
noncomputable def chosen (f : V → H) (v : V) : V := Classical.choose (show ∃ w, f w = f v from ⟨v, rfl⟩)
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inlemma chosen_spec (f : V → H) (v : V) : f (chosen f v) = f v := Classical.choose_spec (show ∃ w, f w = f v from ⟨v, rfl⟩)
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inlemma chosen_eq (f : V → H) {v w : V} (h : f v = f w) : chosen f v = chosen f w := by unfold chosen congr 1 funext x rw [h]omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
lemma chosen_idempotent (f : V → H) : ∀ v, chosen f (chosen f v) = chosen f v := by intro v exact chosen_eq f (chosen_spec f v)
noncomputable def representatives (f : V → H) : RepresentativeMap V := ⟨chosen f, chosen_idempotent f⟩
noncomputable def assignment (f : V → H) : Representatives (representatives f) ↪ H where toFun v := f v inj' := by intro v w h apply Subtype.ext have := chosen_eq f h change chosen f v.val = chosen f w.val at this simpa only [show chosen f v.val = v.val from v.property, show chosen f w.val = w.val from w.property] using this
noncomputable def decode (r : RepresentativeMap V) (h : Representatives r ↪ H) : V → H := fun v => h ⟨r.val v, r.property v⟩omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
lemma decode_assignment (f : V → H) : decode (representatives f) (assignment f) = f := by funext v exact chosen_spec f v
noncomputable def encode (f : V → H) : (r : RepresentativeMap V) × (Representatives r ↪ H) := ⟨representatives f, assignment f⟩omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
lemma encode_injective : Function.Injective (encode (V := V) (H := H)) := by intro f g h have := congrArg (fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) => decode z.1 z.2) h simpa only [encode, decode_assignment] using this
lemma representativeMap_card_le : Fintype.card (RepresentativeMap V) ≤ Fintype.card V ^ Fintype.card V := by calc _ ≤ Fintype.card (V → V) := Fintype.card_subtype_le _ _ = _ := by simp
lemma representatives_card_le (r : RepresentativeMap V) : Fintype.card (Representatives r) ≤ Fintype.card V := Fintype.card_subtype_le _
theorem sum_tuples_le_representative_assignments (F : (V → H) → ℝ) (hF : ∀ f, 0 ≤ F f) : (∑ f : V → H, F f) ≤ ∑ r : RepresentativeMap V, ∑ h : Representatives r ↪ H, F (decode r h) := by rw [← Fintype.sum_sigma (fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) => F (decode z.1 z.2))] let e := encode (V := V) (H := H) let G := fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) => F (decode z.1 z.2) have he : (∑ f : V → H, F f) = ∑ z ∈ Finset.univ.image e, G z := by rw [Finset.sum_image (fun _ _ _ _ h => encode_injective h)] apply Finset.sum_congr rfl intro f _ simp only [G, encode, decode_assignment] rw [he] exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun z _ _ => hF _)
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
lemma range_decode (r : RepresentativeMap V) (h : Representatives r ↪ H) : Set.range (decode r h) = Set.range h := by ext a constructor · rintro ⟨v,rfl⟩ exact ⟨⟨r.val v,r.property v⟩,rfl⟩ · rintro ⟨v,rfl⟩ refine ⟨v, ?_⟩ apply congrArg h exact Subtype.ext v.property
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inlemma fiber_decode (r : RepresentativeMap V) (h : Representatives r ↪ H) (v : V) (w : Representatives r) : decode r h v = h w ↔ r.val v = w.val := by constructor · intro he exact congrArg Subtype.val (h.injective he) · intro he exact congrArg h (Subtype.ext he)end SharpRamseyFive.TupleMultiplicity
namespace SharpRamseyFive.TupleComponentsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScoreopen Classicalvariable {D V C : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]omit [DecidableEq V] in
lemma mass_inside_eq (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (v : V) : mass (fun d : IntDir (componentLabel weight s t) ((strongGraph weight s t).connectedComponentMk v) => rate d) (inside (componentLabel weight s t) _ (s v)) = mass rate (internalPart weight s t v) := by unfold mass apply Finset.sum_bij (fun d _ => d.val) · intro d hd exact (internalPart_iff_label weight s t v d.val).mpr ⟨(Finset.mem_filter.mp hd).2, d.property⟩ · intro a _ b _ hab exact Subtype.ext hab · intro d hd obtain ⟨hm, hl⟩ := (internalPart_iff_label weight s t v d).mp hd exact ⟨⟨d,hl⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _,hm⟩,rfl⟩ · intro d _ rfl
omit [Fintype D] [DecidableEq D] inlemma mass_scaled (L : ℝ≥0) (weight : D → ℝ≥0) (S : Finset D) : mass (fun d => L * weight d) S = (L : ℝ) * mass weight S := by simp only [mass, NNReal.coe_mul, Finset.mul_sum]
lemma source_inside_mass_lower (weight : D → ℝ≥0) (s : V → Finset D) {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) (hs : ∀ v, (3 / 4 : ℝ) ≤ mass weight (s v)) (v : V) : (37 / 50 : ℝ) ≤ mass (fun d : IntDir (componentLabel weight s (1 / (100 * p))) ((strongGraph weight s (1 / (100 * p))).connectedComponentMk v) => weight d) (inside (componentLabel weight s (1 / (100 * p))) _ (s v)) := by rw [mass_inside_eq] exact source_internal_mass_lower weight s hp hc hs v
omit [Fintype D] [Fintype V] in
lemma repeats_same_component (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) {v w : V} (he : s v = s w) (hm : t < mass weight (s v)) : (strongGraph weight s t).connectedComponentMk v = (strongGraph weight s t).connectedComponentMk w := by by_cases hvw : v = w · exact congrArg _ hvw · apply SimpleGraph.ConnectedComponent.connectedComponentMk_eq_of_adj exact ⟨hvw, by simpa only [← he, Finset.inter_self] using hm⟩
variable (label : D → Option C) (R : ℕ) (color : V → C) (s : V → Finset D) (own : V → Fin R → Bool)
def hitBatches {R : ℕ} (mask : Fin R → Bool) : Finset (Fin R) := Finset.univ.filter (fun r => mask r = true)
def BAD {R : ℕ} (mask : Fin R → Bool) : Prop := R / 2 ≤ (hitBatches mask).card
lemma batches_partition {R : ℕ} (mask : Fin R → Bool) : (hitBatches mask).card + (untouchedBatches mask).card = R := by have h := Finset.card_filter_add_card_filter_not (s := Finset.univ) (fun r : Fin R => mask r = true) simpa only [hitBatches, untouchedBatches, Bool.not_eq_true, Finset.card_univ, Fintype.card_fin] using h
lemma untouched_of_not_bad {R : ℕ} (mask : Fin R → Bool) (h : ¬ BAD mask) : R / 2 ≤ (untouchedBatches mask).card := by have hp := batches_partition mask simp only [BAD, not_le] at h omega
omit [Fintype C] in
theorem simple_component_designations_raw (rate : D → ℝ≥0) (J : ℕ) (c : C) (v : {v : V // color v = c}) (hsingle : ∀ u, color u = c → u = v.val) (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) {L base delta alpha : ℝ} (hL : 10000 ≤ L) (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * (base + delta - alpha)) (hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {K : ℕ} (hK : K ≤ R / 2) : |∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ (R / 2) + alpha ^ K + ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J + if BAD (touched label R c (s v) z) then 1 else 0) := by by_cases hg : ¬ BAD (touched label R c (s v) z) · simp only [ite_eq_right hg, add_zero] exact simple_component_attenuation label R color s own rate J c v hsingle hcompat hin z hL hmass hint hbase ha hd (untouched_of_not_bad _ hg) hK · simp only [not_not] at hg simp only [ite_eq_left hg] have hn := nonsimple_component_attenuation label R color s own rate J c v z hcompat hL hmass hint hbase have hat : Real.exp (-(7 / 10 : ℝ) * (L * R)) ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := by apply Real.exp_le_exp.mpr have hLR : 0 ≤ L * (R : ℝ) := mul_nonneg (by linarith) (by positivity) nlinarith calc _ ≤ ∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := abs_integral_le_integral_abs _ ≤ _ := hn _ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := hat _ ≤ _ := by apply le_mul_of_one_le_right (Real.exp_pos _).le have he : 0 ≤ ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J := by positivity have haK : 0 ≤ alpha ^ K := pow_nonneg ha K have hdN : 0 ≤ |delta| ^ (R / 2) := by positivity linarithomit [Fintype C] in
theorem simple_component_designations (rate : D → ℝ≥0) (J : ℕ) (c : C) (v : {v : V // color v = c}) (hsingle : ∀ u, color u = c → u = v.val) (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) {L base delta alpha : ℝ} (hL : 10000 ≤ L) (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * (base + delta - alpha)) (hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {K : ℕ} (hK : K ≤ R / 2) : |∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ (R / 2) + alpha ^ K + (if R < J then 0 else ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J) + if BAD (touched label R c (s v) z) then 1 else 0) := by by_cases hRJ : R < J · simp only [ite_eq_left hRJ, add_zero] by_cases hg : ¬ BAD (touched label R c (s v) z) · simp only [ite_eq_right hg, add_zero] rw [simple_component_integral label R color s _ own rate J c v hsingle hcompat hin z] simp_rw [overloaded_eq_empty _ hRJ, Set.compl_empty, Set.indicator_univ] exact simple_singleton_attenuation _ _ (own v) (touched label R c (s v) z) hL hmass hint hbase ha hd (untouched_of_not_bad _ hg) hK · simp only [not_not] at hg simp only [ite_eq_left hg] have hn := nonsimple_component_attenuation label R color s own rate J c v z hcompat hL hmass hint hbase have hat : Real.exp (-(7 / 10 : ℝ) * (L * R)) ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := by apply Real.exp_le_exp.mpr have hLR : 0 ≤ L * (R : ℝ) := mul_nonneg (by linarith) (by positivity) nlinarith calc _ ≤ ∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := abs_integral_le_integral_abs _ ≤ _ := hn _ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := hat _ ≤ _ := by apply le_mul_of_one_le_right (Real.exp_pos _).le have haK : 0 ≤ alpha ^ K := pow_nonneg ha K have hdN : 0 ≤ |delta| ^ (R / 2) := by positivity linarith · simpa only [ite_eq_right hRJ] using simple_component_designations_raw label R color s own rate J c v hsingle hcompat hin z hL hmass hint hbase ha hd hK
end SharpRamseyFive.TupleComponents
namespace SharpRamseyFive.HighMomentopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen Classicalvariable {D H : Type} [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H]variable (R : ℕ) (s : H → Finset D) (b : ℝ) (own : H → Fin R → Bool)
noncomputable def allTrunc (J : ℕ) (ω : Fin R × D → ℕ) : ℝ := ∏ d : D, lineTrunc R J (fun r => ω (r,d))
omit [DecidableEq D] inlemma allTrunc_range (J : ℕ) (ω : Fin R × D → ℕ) : allTrunc R J ω ∈ Set.Icc (0 : ℝ) 1 := by constructor · exact Finset.prod_nonneg (fun _ _ => (lineTrunc_range R J _).1) · exact Finset.prod_le_one₀ (fun _ _ => (lineTrunc_range R J _).1) (fun _ _ => (lineTrunc_range R J _).2)
omit [Fintype H] [DecidableEq H] inomit [Fintype D] [DecidableEq D] inlemma scoreTerm_abs_le (hb : b ∈ Set.Icc (0 : ℝ) 1) (h : H) (ω : Fin R × D → ℕ) : |scoreTerm (s h) b (own h) (fun r d => ω (r,d))| ≤ 1 := by simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm] using abs_maskedTerm_le_one (s h) hb (own h) (fun _ => false) (fun r d => ω (r,d))omit [Fintype H] [DecidableEq H] inomit [DecidableEq D] in
lemma truncated_tuple_abs_le (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) {V : Type} [Fintype V] (f : V → H) (ω : Fin R × D → ℕ) : |allTrunc R J ω * ∏ v, scoreTerm (s (f v)) b (own (f v)) (fun r d => ω (r,d))| ≤ 1 := by rw [abs_mul, abs_of_nonneg (allTrunc_range R J ω).1, Finset.abs_prod] exact (mul_le_of_le_one_left (by positivity) (allTrunc_range R J ω).2).trans (Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => scoreTerm_abs_le R s b own hb _ ω))
end SharpRamseyFive.HighMomentend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.ForcedHits
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealnamespace SharpRamseyFive.PoissonScorevariable {ι : Type*} [Fintype ι] [DecidableEq ι]variable {κ : Type*}variable {κ : Type*} [Fintype κ] [DecidableEq κ]section ComponentGeometryvariable {H : Type*} [Fintype H] [DecidableEq H]omit [Fintype ι] inlemma external_mass_le (rate : ι → ℝ≥0) (s : H → Finset ι) {t : ℝ} (ht : 0 ≤ t) (h : H) : mass rate (externalPart rate s t h) ≤ (Fintype.card H - 1 : ℕ) * t := by classical let K := otherComponents rate s t h have hK : K ⊆ Finset.univ.erase h := by intro k hk simp only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] at hk simp only [Finset.mem_erase, Finset.mem_univ, and_true] intro he subst k exact hk rfl have hc : K.card ≤ Fintype.card H - 1 := by simpa only [Finset.card_erase_of_mem (Finset.mem_univ h), Finset.card_univ] using Finset.card_le_card hK calc _ ≤ ∑ k ∈ K, mass rate (s h ∩ s k) := external_mass_le_sum rate s t h _ ≤ K.card * t := by simpa only [nsmul_eq_mul] using Finset.sum_le_card_nsmul K (fun k => mass rate (s h ∩ s k)) t (by intro k hk apply cross_component_overlap rate s t simpa only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] using hk) _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hc) ht
omit [Fintype ι] in
lemma internal_mass_lower (rate : ι → ℝ≥0) (s : H → Finset ι) {t c : ℝ} (ht : 0 ≤ t) (hs : ∀ h, c ≤ mass rate (s h)) (h : H) : c - (Fintype.card H - 1 : ℕ) * t ≤ mass rate (internalPart rate s t h) := by have := external_mass_le rate s ht h have := internal_external_mass rate s t h have := hs h linarith
omit [Fintype ι] [Fintype H] [DecidableEq H] inlemma internal_parts_disjoint (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) {h k : H} (hc : (strongGraph rate s t).connectedComponentMk h ≠ (strongGraph rate s t).connectedComponentMk k) : Disjoint (internalPart rate s t h) (internalPart rate s t k) := by classical apply Finset.disjoint_left.mpr intro i hi hk simp only [internalPart, Finset.mem_filter] at hi hk exact hi.2 ⟨h, k, hi.1, hk.1, hc⟩
noncomputable def componentLabel (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (i : ι) : Option (strongGraph rate s t).ConnectedComponent := by classical exact if hi : ∃ h, i ∈ s h then if External rate s t i then none else some ((strongGraph rate s t).connectedComponentMk hi.choose) else none
omit [Fintype ι] [DecidableEq H] inlemma componentLabel_external (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) {i : ι} (hi : External rate s t i) : componentLabel rate s t i = none := by classical simp only [componentLabel, hi, ↓reduceIte] split_ifs <;> rfl
omit [Fintype ι] [DecidableEq H] inlemma componentLabel_internal (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) {h : H} {i : ι} (hi : i ∈ internalPart rate s t h) : componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by classical simp only [internalPart, Finset.mem_filter] at hi have hex : ∃ k, i ∈ s k := ⟨h, hi.1⟩ have he := hex.choose_spec have hc : (strongGraph rate s t).connectedComponentMk hex.choose = (strongGraph rate s t).connectedComponentMk h := by by_contra hn exact hi.2 ⟨hex.choose, h, he, hi.1, hn⟩ simp only [componentLabel, dite_eq_left hex, ite_eq_right hi.2, hc]omit [Fintype ι] [DecidableEq H] in
lemma internalPart_iff_label (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (h : H) (i : ι) : i ∈ internalPart rate s t h ↔ i ∈ s h ∧ componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by classical constructor · intro hi exact ⟨(Finset.mem_filter.mp hi).1, componentLabel_internal rate s t hi⟩ · rintro ⟨hi, he⟩ apply Finset.mem_filter.mpr refine ⟨hi, ?_⟩ intro hn rw [componentLabel_external rate s t hn] at he cases he
omit [Fintype ι] [DecidableEq H] in
lemma direction_internal_or_external (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) {h : H} {i : ι} (hi : i ∈ s h) : componentLabel rate s t i = none ∨ componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by classical by_cases he : External rate s t i · exact Or.inl (componentLabel_external rate s t he) · exact Or.inr (componentLabel_internal rate s t (Finset.mem_filter.mpr ⟨hi, he⟩))omit [Fintype ι] in
lemma source_internal_mass_lower (rate : ι → ℝ≥0) (s : H → Finset ι) {p : ℕ} (hp : 0 < p) (hc : Fintype.card H ≤ p) (hs : ∀ h, (3 / 4 : ℝ) ≤ mass rate (s h)) (h : H) : (37 / 50 : ℝ) ≤ mass rate (internalPart rate s (1 / (100 * p)) h) := by have ht : (0 : ℝ) ≤ 1 / (100 * p : ℝ) := by positivity have hl := internal_mass_lower rate s ht hs h have hh : (0 : ℝ) < p := by exact_mod_cast hp have hcard : ((Fintype.card H - 1 : ℕ) : ℝ) ≤ (p : ℝ) := by exact_mod_cast ((Nat.sub_le (Fintype.card H) 1).trans hc) have hm : ((Fintype.card H - 1 : ℕ) : ℝ) * (1 / (100 * p)) ≤ (1 / 100 : ℝ) := by calc _ ≤ (p : ℝ) * (1 / (100 * p)) := mul_le_mul_of_nonneg_right hcard ht _ = _ := by field_simp linarith
end ComponentGeometry
end SharpRamseyFive.PoissonScore
namespace SharpRamseyFive.TupleComponentsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScoreopen Classicalvariable {D V C : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]variable (label : D → Option C) (R : ℕ)
abbrev Block (c : Option C) := {i : Fin R × D // label i.2 = c}noncomputable def fill (c : C) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) (r : Fin R) (d : D) : ℕ := if he : label d = none then z ⟨(r,d), he⟩ else if hi : label d = some c then x ⟨(r,d), hi⟩ else 0
omit [Fintype D] [DecidableEq D] [Fintype C] inlemma fill_restrict (c : C) (ω : Fin R × D → ℕ) {d : D} (hd : label d = none ∨ label d = some c) (r : Fin R) : fill label R c (fun i => ω i) (fun i => ω i) r d = ω (r,d) := by rcases hd with hd | hd <;> simp [fill, hd]
noncomputable def lineTrunc (J : ℕ) (ω : Fin R → ℕ) : ℝ := if (Finset.univ.filter (fun r => ω r ≠ 0)).card < J then 1 else 0
noncomputable def blockTrunc (J : ℕ) (c : Option C) (ω : Block label R c → ℕ) : ℝ := ∏ d : {d : D // label d = c}, lineTrunc R J (fun r => ω ⟨(r,d), d.property⟩)
lemma lineTrunc_range (J : ℕ) (ω : Fin R → ℕ) : lineTrunc R J ω ∈ Set.Icc (0 : ℝ) 1 := by unfold lineTrunc; split_ifs <;> norm_num
omit [DecidableEq D] [Fintype C] inlemma blockTrunc_range (J : ℕ) (c : Option C) (ω : Block label R c → ℕ) : blockTrunc label R J c ω ∈ Set.Icc (0 : ℝ) 1 := by constructor · exact Finset.prod_nonneg (fun _ _ => (lineTrunc_range R J _).1) · exact Finset.prod_le_one₀ (fun _ _ => (lineTrunc_range R J _).1) (fun _ _ => (lineTrunc_range R J _).2)
lemma prod_fibers {A K : Type} [Fintype A] [Fintype K] [DecidableEq K] (col : A → K) (f : A → ℝ) : (∏ c : K, ∏ a : {a : A // col a = c}, f a) = ∏ a, f a := by classical calc _ = ∏ c : K, ∏ a ∈ Finset.univ.filter (fun a => col a = c), f a := by apply Finset.prod_congr rfl intro c _ symm exact Finset.prod_subtype _ (by simp) f _ = _ := by simpa using Finset.prod_fiberwise Finset.univ col f
omit [DecidableEq D] inlemma trunc_split (J : ℕ) (ω : Fin R × D → ℕ) : (∏ d : D, lineTrunc R J (fun r => ω (r,d))) = blockTrunc label R J none (fun i => ω i) * ∏ c : C, blockTrunc label R J (some c) (fun i => ω i) := by rw [← Fintype.prod_option (fun c => blockTrunc label R J c (fun i => ω i))] exact (prod_fibers label (fun d => lineTrunc R J (fun r => ω (r,d)))).symm
omit [Fintype D] [DecidableEq D] inlemma emptyIndicator_congr (s : Finset D) (ω ν : D → ℕ) (he : ∀ d ∈ s, ω d = ν d) : emptyIndicator s ω = emptyIndicator s ν := by have h : ω ∈ emptyEvent s ↔ ν ∈ emptyEvent s := by simp only [emptyEvent, Set.mem_pi, Set.mem_singleton_iff, Finset.mem_coe] exact forall₂_congr (fun d hd => by rw [he d hd]) by_cases hω : ω ∈ emptyEvent s · simp [emptyIndicator, hω, h.mp hω] · simp [emptyIndicator, hω, (not_congr h).mp hω]omit [Fintype D] [DecidableEq D] in
lemma scoreTerm_congr (s : Finset D) (b : ℝ) (own : Fin R → Bool) (ω ν : Fin R → D → ℕ) (he : ∀ r d, d ∈ s → ω r d = ν r d) : scoreTerm s b own ω = scoreTerm s b own ν := by unfold scoreTerm apply Finset.prod_congr rfl intro r _ simp only [centeredFactor, emptyIndicator_congr s (ω r) (ν r) (he r)]
variable (color : V → C) (s : V → Finset D) (b : ℝ) (own : V → Fin R → Bool)
noncomputable def componentFactor (J : ℕ) (c : C) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : ℝ := blockTrunc label R J (some c) x * ∏ v : {v : V // color v = c}, scoreTerm (s v) b (own v) (fill label R c z x)
omit [DecidableEq V] inomit [Fintype C] inomit [DecidableEq D] inlemma componentFactor_bound (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) (c : C) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : |componentFactor label R color s b own J c z x| ≤ 1 := by rw [componentFactor, abs_mul, Finset.abs_prod] have htrunc : |blockTrunc label R J (some c) x| ≤ 1 := by rw [abs_of_nonneg (blockTrunc_range label R J (some c) x).1] exact (blockTrunc_range label R J (some c) x).2 refine (mul_le_of_le_one_left (Finset.prod_nonneg (fun _ _ => abs_nonneg _)) htrunc).trans ?_ apply Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) intro vertex _ simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm] using abs_maskedTerm_le_one (s vertex) hb (own vertex) (fun _ => false) (fill label R c z x)
omit [DecidableEq V] inomit [DecidableEq D] inlemma tuple_pointwise_split (J : ℕ) (hcompat : ∀ v d, d ∈ s v → label d = none ∨ label d = some (color v)) (ω : Fin R × D → ℕ) : (∏ d : D, lineTrunc R J (fun r => ω (r,d))) * (∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d))) = blockTrunc label R J none (fun i => ω i) * ∏ c : C, componentFactor label R color s b own J c (fun i => ω i) (fun i => ω i) := by have he (c : C) (v : {v : V // color v = c}) : scoreTerm (s v) b (own v) (fill label R c (fun i => ω i) (fun i => ω i)) = scoreTerm (s v) b (own v) (fun r d => ω (r,d)) := by apply scoreTerm_congr R intro r d hd apply fill_restrict label R c ω _ r simpa only [v.property] using hcompat v d hd simp_rw [componentFactor, he] rw [Finset.prod_mul_distrib, prod_fibers color (fun v => scoreTerm (s v) b (own v) (fun r d => ω (r,d)))] rw [trunc_split label R J ω] ring
omit [DecidableEq V] inomit [DecidableEq D] in
theorem tuple_integral_split (rate : D → ℝ≥0) (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) (hcompat : ∀ v d, d ∈ s v → label d = none ∨ label d = some (color v)) : (∫ ω, (∏ d : D, lineTrunc R J (fun r => ω (r,d))) * (∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d))) ∂batchMeasure (fun i : Fin R × D => rate i.2)) = ∫ z, blockTrunc label R J none z * ∏ c : C, ∫ x, componentFactor label R color s b own J c z x ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) ∂batchMeasure (fun i : Block label R none => rate i.1.2) := by have he := integral_external_components (fun i : Fin R × D => rate i.2) (fun i => label i.2) (blockTrunc label R J none) (componentFactor label R color s b own J) (fun z => by rw [abs_of_nonneg (blockTrunc_range label R J none z).1]; exact (blockTrunc_range label R J none z).2) (componentFactor_bound label R color s b own J hb) rw [← he] apply integral_congr_ae exact Filter.Eventually.of_forall (tuple_pointwise_split label R color s b own J hcompat)
noncomputable def strongSplit (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) : ℝ := by classical let G := strongGraph weight s t let label := componentLabel weight s t exact ∫ z, blockTrunc label R J none z * ∏ c : G.ConnectedComponent, ∫ x, componentFactor label R G.connectedComponentMk s b own J c z x ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) ∂batchMeasure (fun i : Block label R none => rate i.1.2)
lemma strong_tuple_integral_split (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) : (∫ ω, (∏ d : D, lineTrunc R J (fun r => ω (r,d))) * (∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d))) ∂batchMeasure (fun i : Fin R × D => rate i.2)) = strongSplit R s b own weight rate t J := by classical unfold strongSplit apply tuple_integral_split _ R _ s b own rate J hb intro v d hd exact direction_internal_or_external weight s t hd
abbrev IntDir (c : C) := {d : D // label d = some c}
noncomputable def inside (c : C) (S : Finset D) : Finset (IntDir label c) := Finset.univ.filter (fun d => d.val ∈ S)
noncomputable def touched (_c : C) (S : Finset D) (z : Block label R none → ℕ) (r : Fin R) : Bool := decide (∃ d : {d : D // label d = none}, d.val ∈ S ∧ z ⟨(r,d), d.property⟩ ≠ 0)
noncomputable def unblock (c : C) (x : Block label R (some c) → ℕ) : Fin R → IntDir label c → ℕ := fun r d => x ⟨(r,d), d.property⟩
omit [Fintype C] inlemma fill_empty_iff (c : C) (S : Finset D) (hc : ∀ d ∈ S, label d = none ∨ label d = some c) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) (r : Fin R) : fill label R c z x r ∈ emptyEvent S ↔ touched label R c S z r = false ∧ unblock label R c x r ∈ emptyEvent (inside label c S) := by simp only [emptyEvent, Set.mem_pi, Set.mem_singleton_iff, Finset.mem_coe] constructor · intro h constructor · simp only [touched, decide_eq_false_iff_not, not_exists, not_and] intro d hd have := h d hd simpa [fill, d.property] using this · intro d hd have := h d (Finset.mem_filter.mp hd).2 simpa [fill, d.property, unblock] using this · rintro ⟨he, hi⟩ d hd rcases hc d hd with hd0 | hdc · have hz : z ⟨(r,d), hd0⟩ = 0 := by have he' : ¬ ∃ d : {d : D // label d = none}, d.val ∈ S ∧ z ⟨(r,d), d.property⟩ ≠ 0 := by simpa only [touched, decide_eq_false_iff_not] using he by_contra hn exact he' ⟨⟨d,hd0⟩, hd, hn⟩ simpa [fill, hd0] using hz · have hz := hi ⟨d,hdc⟩ (by simp [inside, hd]) simpa [fill, hdc, unblock] using hzomit [Fintype C] in
lemma scoreTerm_eq_masked (c : C) (S : Finset D) (B : ℝ) (o : Fin R → Bool) (hc : ∀ d ∈ S, label d = none ∨ label d = some c) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : scoreTerm S B o (fill label R c z x) = maskedTerm (inside label c S) B o (touched label R c S z) (unblock label R c x) := by apply Finset.prod_congr rfl intro r _ have hh := fill_empty_iff label R c S hc z x r cases ho : o r <;> simp only [maskedFactor, Bool.false_eq_true, ↓reduceIte] by_cases he : touched label R c S z r = true · have hn : fill label R c z x r ∉ emptyEvent S := by simpa [he] using hh simp [he, centeredFactor, emptyIndicator, hn] · have ht : touched label R c S z r = false := Bool.eq_false_of_not_eq_true he simp only [ht, true_and] at hh by_cases hi : unblock label R c x r ∈ emptyEvent (inside label c S) · simp [ht, centeredFactor, emptyIndicator, hi, hh.mpr hi] · simp [ht, centeredFactor, emptyIndicator, hi, (not_congr hh).mpr hi]
noncomputable def blockCoords (c : C) : (Fin R × IntDir label c) ≃ Block label R (some c) where toFun i := ⟨(i.1,i.2), i.2.property⟩ invFun i := (i.1.1, ⟨i.1.2, i.property⟩) left_inv _ := rfl right_inv _ := rfl
noncomputable def unblockEquiv (c : C) : (Block label R (some c) → ℕ) ≃ᵐ (Fin R → IntDir label c → ℕ) := (MeasurableEquiv.piCongrLeft (fun _ : Block label R (some c) => ℕ) (blockCoords label R c)).symm.trans (MeasurableEquiv.curry (Fin R) (IntDir label c) ℕ)
omit [Fintype D] [DecidableEq D] [Fintype C] [DecidableEq C] in@[simp] lemma unblockEquiv_apply (c : C) (x : Block label R (some c) → ℕ) : unblockEquiv label R c x = unblock label R c x := rfl
omit [Fintype C] inomit [DecidableEq D] inlemma measurePreserving_unblock (rate : D → ℝ≥0) (c : C) : MeasurePreserving (unblockEquiv label R c) (batchMeasure (fun i : Block label R (some c) => rate i.1.2)) (scheduleMeasure (fun d : IntDir label c => rate d) R) := by exact (measurePreserving_uncurry_schedule (fun d : IntDir label c => rate d) R).symm.comp (measurePreserving_piCongrLeft (fun i : Block label R (some c) => poissonMeasure (rate i.1.2)) (blockCoords label R c)).symm
omit [DecidableEq D] [Fintype C] inlemma integrable_block_bounded (rate : D → ℝ≥0) (c : Option C) (f : (Block label R c → ℕ) → ℝ) (h : ∀ x, |f x| ≤ 1) : Integrable f (batchMeasure (fun i : Block label R c => rate i.1.2)) := by apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable 1 exact Filter.Eventually.of_forall (fun x => by simpa only [Real.norm_eq_abs] using h x)omit [Fintype C] inomit [DecidableEq D] in
lemma componentFactor_abs_le_term (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) (c : C) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) (v : {v : V // color v = c}) : |componentFactor label R color s b own J c z x| ≤ |scoreTerm (s v) b (own v) (fill label R c z x)| := by have hterm (u : V) : |scoreTerm (s u) b (own u) (fill label R c z x)| ≤ 1 := by simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm] using abs_maskedTerm_le_one (s u) hb (own u) (fun _ => false) (fill label R c z x) rw [componentFactor, abs_mul, Finset.abs_prod] have hp : (∏ u : {v : V // color v = c}, |scoreTerm (s u) b (own u) (fill label R c z x)|) ≤ |scoreTerm (s v) b (own v) (fill label R c z x)| := by rw [← Finset.prod_erase_mul _ _ (Finset.mem_univ v)] have he : (∏ u ∈ Finset.univ.erase v, |scoreTerm (s u) b (own u) (fill label R c z x)|) ≤ 1 := Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun u _ => hterm u) simpa using mul_le_mul_of_nonneg_right he (abs_nonneg (scoreTerm (s v) b (own v) (fill label R c z x))) calc _ ≤ ∏ u : {v : V // color v = c}, |scoreTerm (s u) b (own u) (fill label R c z x)| := by apply mul_le_of_le_one_left (Finset.prod_nonneg (fun _ _ => abs_nonneg _)) rw [abs_of_nonneg (blockTrunc_range label R J (some c) x).1] exact (blockTrunc_range label R J (some c) x).2 _ ≤ _ := hp
omit [Fintype C] in
lemma component_integral_abs_le (rate : D → ℝ≥0) (J : ℕ) (c : C) (v : {v : V // color v = c}) (z : Block label R none → ℕ) (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) {L lam base a : ℝ} (hL : 0 ≤ L) (ha : 0 ≤ a) (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * lam) (hlam : a ≤ lam) (hbase : a ≤ base) : (∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) ≤ (2 * Real.exp (-L * a)) ^ R := by have hb : Real.exp (-L * base) ∈ Set.Icc (0 : ℝ) 1 := ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ let f := fun w => |maskedTerm (inside label c (s v)) (Real.exp (-L * base)) (own v) (touched label R c (s v) z) w| have he (x : Block label R (some c) → ℕ) : |scoreTerm (s v) (Real.exp (-L * base)) (own v) (fill label R c z x)| = f (unblockEquiv label R c x) := by rw [scoreTerm_eq_masked label R c (s v) _ _ hcompat] rfl calc _ ≤ ∫ x, f (unblockEquiv label R c x) ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := by apply integral_mono · apply integrable_block_bounded label R rate (some c) intro x rw [abs_abs] exact componentFactor_bound label R color s _ own J hb c z x · apply integrable_block_bounded label R rate (some c) intro x dsimp only [f] rw [abs_abs] exact abs_maskedTerm_le_one _ hb _ _ _ · intro x dsimp only rw [← he x] exact componentFactor_abs_le_term label R color s _ own J hb c z x v _ = ∫ w, f w ∂scheduleMeasure (fun d : IntDir label c => rate d) R := (measurePreserving_unblock label R rate c).integral_comp (unblockEquiv label R c).measurableEmbedding f _ ≤ _ := integral_abs_maskedTerm_exp_le _ _ _ _ hL hmass hlam hbase
end SharpRamseyFive.TupleComponentsend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.IntegralTypicalScoreSq
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealnamespace SharpRamseyFive.PoissonScorevariable {ι : Type*} [Fintype ι] [DecidableEq ι]variable {κ : Type*}omit [Fintype ι] [DecidableEq ι] inlemma forcedHits_le_one {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) : forcedHits i T ω ≤ 1 := Finset.prod_le_one₀ (fun _ _ => hitIndicator_nonneg _ _) (fun _ _ => hitIndicator_le_one _ _)
omit [Fintype ι] [DecidableEq ι] inlemma abs_maskedTerm_mul_forcedHits {R : ℕ} (s : Finset ι) (i : ι) (T : Finset (Fin R)) (b : ℝ) (own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) : |maskedTerm s b own touched ω| * forcedHits i T ω = ∏ r, (|maskedFactor s b (own r) (touched r) (ω r)| * if r ∈ T then hitIndicator i (ω r) else 1) := by simp only [maskedTerm, Finset.abs_prod, Finset.prod_mul_distrib, Finset.prod_ite_mem, Finset.univ_inter, forcedHits]omit [DecidableEq ι] in
lemma integral_abs_maskedTerm_forcedHits_le (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (i : ι) (hi : i ∈ s) (T : Finset (Fin R)) (own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : (∫ ω, |maskedTerm s (Real.exp (-L * base)) own touched ω| * forcedHits i T ω ∂scheduleMeasure rate R) ≤ (2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ T.card := by simp_rw [abs_maskedTerm_mul_forcedHits] unfold scheduleMeasure rw [integral_fintype_prod_eq_prod (f := fun r ω => |maskedFactor s (Real.exp (-L * base)) (own r) (touched r) ω| * if r ∈ T then hitIndicator i ω else 1)] calc _ ≤ ∏ r, (2 * Real.exp (-L * c)) * (if r ∈ T then (rate i : ℝ) else 1) := by apply Finset.prod_le_prod₀ · intro r _ apply integral_nonneg intro ω apply mul_nonneg (abs_nonneg _) split · exact hitIndicator_nonneg _ _ · norm_num · intro r _ by_cases hr : r ∈ T · simp only [hr, ↓reduceIte] have h := integral_abs_maskedFactor_hit_le rate s i hi (own r) (touched r) hL hbase have he := Real.exp_pos (-L * c) have hi0 : 0 ≤ (rate i : ℝ) := (rate i).coe_nonneg nlinarith · simp only [hr, ↓reduceIte, mul_one] exact integral_abs_maskedFactor_exp_le rate s _ _ hL hmass hlam hbase _ = _ := by rw [Finset.prod_mul_distrib]; simp [Finset.prod_ite_mem]
def hitBatches {R : ℕ} (i : ι) (ω : Fin R → ι → ℕ) : Finset (Fin R) := Finset.univ.filter (fun r => ω r i ≠ 0)
def overloaded {R : ℕ} (s : Finset ι) (J : ℕ) : Set (Fin R → ι → ℕ) := {ω | ∃ i ∈ s, J ≤ (hitBatches i ω).card}
omit [Fintype ι] [DecidableEq ι] in
lemma overloaded_eq_empty {R J : ℕ} (s : Finset ι) (h : R < J) : (overloaded s J : Set (Fin R → ι → ℕ)) = ∅ := by apply Set.eq_empty_iff_forall_notMem.mpr intro ω he obtain ⟨i, hi, hJ⟩ := he have hc : (hitBatches i ω).card ≤ R := by simpa only [hitBatches, Finset.card_univ, Fintype.card_fin] using Finset.card_le_card (Finset.filter_subset (fun r : Fin R => ω r i ≠ 0) Finset.univ) omegaomit [Fintype ι] [DecidableEq ι] in
lemma forcedHits_eq_one_of_subset {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) (h : T ⊆ hitBatches i ω) : forcedHits i T ω = 1 := by apply Finset.prod_eq_one intro r hr rw [hitIndicator_eq] have hz : ω r i ≠ 0 := (Finset.mem_filter.mp (h hr)).2 simp [hz]omit [Fintype ι] [DecidableEq ι] in
lemma overload_indicator_le_certificates {R : ℕ} (s : Finset ι) (J : ℕ) (ω : Fin R → ι → ℕ) : (overloaded s J).indicator (fun _ => (1 : ℝ)) ω ≤ ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i T ω := by have hnonneg : ∀ i, 0 ≤ ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i T ω := by intro i exact Finset.sum_nonneg (fun T _ => forcedHits_nonneg i T ω) by_cases h : ω ∈ overloaded s J · rw [Set.indicator_of_mem h] obtain ⟨i, hi, hcard⟩ := h obtain ⟨T, hT, hTc⟩ := Finset.exists_subset_card_eq hcard have hTm : T ∈ (Finset.univ : Finset (Fin R)).powersetCard J := by simp only [Finset.mem_powersetCard] exact ⟨Finset.subset_univ _, hTc⟩ calc 1 = forcedHits i T ω := (forcedHits_eq_one_of_subset i T ω hT).symm _ ≤ ∑ U ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i U ω := Finset.single_le_sum (fun U _ => forcedHits_nonneg i U ω) hTm _ ≤ _ := Finset.single_le_sum (fun i _ => hnonneg i) hi · rw [Set.indicator_of_notMem h] exact Finset.sum_nonneg (fun i _ => hnonneg i)omit [DecidableEq ι] in
lemma integrable_abs_maskedTerm_forcedHits (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Fin R → Bool) (i : ι) (T : Finset (Fin R)) : Integrable (fun ω => |maskedTerm s b own touched ω| * forcedHits i T ω) (scheduleMeasure rate R) := by apply integrable_schedule_of_abs_le rate _ 1 intro ω rw [abs_mul, abs_abs, abs_of_nonneg (forcedHits_nonneg i T ω)] exact (mul_le_of_le_one_left (forcedHits_nonneg i T ω) (abs_maskedTerm_le_one s hb own touched ω)).trans (forcedHits_le_one i T ω)
omit [DecidableEq ι] in
lemma truncation_error_raw (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (J : ℕ) (own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L) (hc : 0 ≤ c) (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : (∫ ω, (overloaded s J).indicator (fun ω => |maskedTerm s (Real.exp (-L * base)) own touched ω|) ω ∂scheduleMeasure rate R) ≤ (2 * Real.exp (-L * c)) ^ R * ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := by have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 := ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ let f := fun ω => |maskedTerm s (Real.exp (-L * base)) own touched ω| have hf (i : ι) (T : Finset (Fin R)) := integrable_abs_maskedTerm_forcedHits rate s hb own touched i T have hpoint (ω) : (overloaded s J).indicator f ω ≤ ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, f ω * forcedHits i T ω := by have hh := mul_le_mul_of_nonneg_left (overload_indicator_le_certificates s J ω) (abs_nonneg (maskedTerm s (Real.exp (-L * base)) own touched ω)) by_cases he : ω ∈ overloaded s J · simpa [he, f, Finset.mul_sum] using hh · simpa [he, f, Finset.mul_sum] using hh calc _ ≤ ∫ ω, ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, f ω * forcedHits i T ω ∂scheduleMeasure rate R := by apply integral_mono · apply integrable_schedule_of_abs_le rate _ 1 intro ω by_cases h : ω ∈ overloaded s J · simpa [h] using abs_maskedTerm_le_one s hb own touched ω · simp [h] · exact integrable_finsetSum _ (fun i _ => integrable_finsetSum _ (fun T _ => hf i T)) · exact hpoint _ = ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, ∫ ω, f ω * forcedHits i T ω ∂scheduleMeasure rate R := by rw [integral_finsetSum _ (fun i _ => integrable_finsetSum _ (fun T _ => hf i T))] apply Finset.sum_congr rfl intro i hi rw [integral_finsetSum _ (fun T _ => hf i T)] _ ≤ ∑ i ∈ s, (2 * Real.exp (-L * c)) ^ R * ((R : ℝ) * (rate i : ℝ)) ^ J := by apply Finset.sum_le_sum intro i hi calc _ ≤ ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, (2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J := by apply Finset.sum_le_sum intro T hT have hTJ := (Finset.mem_powersetCard.mp hT).2 simpa only [hTJ] using integral_abs_maskedTerm_forcedHits_le rate s i hi T own touched hL hmass hlam hbase _ = (R.choose J : ℝ) * ((2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J) := by simp _ ≤ _ := by have hchoose : (R.choose J : ℝ) ≤ (R : ℝ) ^ J := by exact_mod_cast Nat.choose_le_pow R J calc _ ≤ (R : ℝ) ^ J * ((2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J) := mul_le_mul_of_nonneg_right hchoose (by positivity) _ = _ := by rw [mul_pow]; ring _ = _ := (Finset.mul_sum _ _ _).symmomit [DecidableEq ι] in
lemma truncation_error (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (J : ℕ) (own touched : Fin R → Bool) {L lam base : ℝ} (hL : 10000 ≤ L) (hmass : mass rate s = L * lam) (hlam : (37 / 50 : ℝ) ≤ lam) (hbase : (37 / 50 : ℝ) ≤ base) : (∫ ω, (overloaded s J).indicator (fun ω => |maskedTerm s (Real.exp (-L * base)) own touched ω|) ω ∂scheduleMeasure rate R) ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := by have hraw := truncation_error_raw rate s J own touched (show 0 ≤ L by linarith) (show (0 : ℝ) ≤ 37 / 50 by norm_num) hmass hlam hbase apply hraw.trans apply mul_le_mul_of_nonneg_right _ (Finset.sum_nonneg (fun _ _ => by positivity)) calc (2 * Real.exp (-L * (37 / 50 : ℝ))) ^ R ≤ (2 * L * Real.exp (-L * (37 / 50 : ℝ))) ^ R := by apply pow_le_pow_left₀ (by positivity) have := Real.exp_pos (-L * (37 / 50 : ℝ)) nlinarith _ ≤ _ := by simpa only [neg_mul, mul_comm L (37 / 50 : ℝ)] using two_mul_score_attenuation hL Romit [DecidableEq ι] in
lemma abs_integral_compl_indicator_le (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Fin R → Bool) (E : Set (Fin R → ι → ℕ)) : |∫ ω, Eᶜ.indicator (maskedTerm s b own touched) ω ∂scheduleMeasure rate R| ≤ |∫ ω, maskedTerm s b own touched ω ∂scheduleMeasure rate R| + ∫ ω, E.indicator (fun ω => |maskedTerm s b own touched ω|) ω ∂scheduleMeasure rate R := by have hf := integrable_schedule_of_abs_le rate _ 1 (abs_maskedTerm_le_one s hb own touched) have hEf : Integrable (E.indicator (maskedTerm s b own touched)) (scheduleMeasure rate R) := by apply integrable_schedule_of_abs_le rate _ 1 intro ω by_cases h : ω ∈ E · simpa [h] using abs_maskedTerm_le_one s hb own touched ω · simp [h] have heq : Eᶜ.indicator (maskedTerm s b own touched) = fun ω => maskedTerm s b own touched ω - E.indicator (maskedTerm s b own touched) ω := by funext ω by_cases h : ω ∈ E <;> simp [h] rw [heq, integral_sub hf hEf] apply (abs_sub _ _).trans apply add_le_add le_rfl have habs : (fun ω => |E.indicator (maskedTerm s b own touched) ω|) = (E.indicator (fun ω => |maskedTerm s b own touched ω|)) := by funext ω by_cases h : ω ∈ E <;> simp [h] rw [← habs] exact abs_integral_le_integral_abs
omit [DecidableEq ι] in
lemma simple_singleton_truncated (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (J : ℕ) (own touched : Fin R → Bool) {L base delta alpha : ℝ} (hL : 10000 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) (hinternal : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} (hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) : |∫ ω, (overloaded s J)ᶜ.indicator (maskedTerm s (Real.exp (-L * base)) own touched) ω ∂scheduleMeasure rate R| ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K + ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J) := by have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 := ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ calc _ ≤ _ := abs_integral_compl_indicator_le rate s hb own touched (overloaded s J) _ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K) + Real.exp (-(17 / 25 : ℝ) * (L * R)) * ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := add_le_add (simple_singleton_attenuation rate s own touched hL hmass hinternal hbase ha hd hN hK) (truncation_error rate s J own touched hL hmass hinternal hbase) _ = _ := by ring
omit [DecidableEq ι] inlemma measurePreserving_uncurry_schedule (rate : ι → ℝ≥0) (R : ℕ) : MeasurePreserving (MeasurableEquiv.curry (Fin R) ι ℕ).symm (scheduleMeasure rate R) (batchMeasure (fun p : Fin R × ι => rate p.2)) := by refine ⟨(MeasurableEquiv.curry (Fin R) ι ℕ).symm.measurable, ?_⟩ simpa only [Measure.infinitePi_eq_pi, scheduleMeasure, batchMeasure] using Measure.infinitePi_map_curry_symm (fun (_ : Fin R) i => poissonMeasure (rate i))
variable {κ : Type*} [Fintype κ] [DecidableEq κ]
noncomputable def partitionEquiv (label : ι → κ) : (ι → ℕ) ≃ᵐ (∀ c : κ, {i : ι // label i = c} → ℕ) := (MeasurableEquiv.piCongrLeft (fun _ : ι => ℕ) (Equiv.sigmaFiberEquiv label)).symm.trans (MeasurableEquiv.piCurry (fun (c : κ) (_ : {i : ι // label i = c}) => ℕ))
omit [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] in@[simp] lemma partitionEquiv_apply (label : ι → κ) (ω : ι → ℕ) (c : κ) (i : {i : ι // label i = c}) : partitionEquiv label ω c i = ω i := rfl
omit [DecidableEq ι] inlemma measurePreserving_partition (rate : ι → ℝ≥0) (label : ι → κ) : MeasurePreserving (partitionEquiv label) (batchMeasure rate) (Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))) := by have hc : MeasurePreserving (MeasurableEquiv.piCurry (fun (c : κ) (_ : {i : ι // label i = c}) => ℕ)) (Measure.pi (fun p : (c : κ) × {i : ι // label i = c} => poissonMeasure (rate p.2))) (Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))) := by refine ⟨(MeasurableEquiv.piCurry _).measurable, ?_⟩ simpa only [Measure.infinitePi_eq_pi, batchMeasure] using Measure.infinitePi_map_piCurry (fun (c : κ) (i : {i : ι // label i = c}) => poissonMeasure (rate i)) exact hc.comp ((measurePreserving_piCongrLeft (fun i => poissonMeasure (rate i)) (Equiv.sigmaFiberEquiv label)).symm)
omit [DecidableEq ι] in
lemma integral_partition_prod (rate : ι → ℝ≥0) (label : ι → κ) (f : ∀ c : κ, ({i : ι // label i = c} → ℕ) → ℝ) : (∫ ω, ∏ c, f c (fun i => ω i) ∂batchMeasure rate) = ∏ c, ∫ ω, f c ω ∂batchMeasure (fun i : {i : ι // label i = c} => rate i) := by calc _ = ∫ ω, ∏ c, f c (ω c) ∂Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i)) := (measurePreserving_partition rate label).integral_comp (partitionEquiv label).measurableEmbedding _ _ = _ := integral_fintype_prod_eq_prod _
noncomputable def externalEquiv (label : ι → Option κ) : (ι → ℕ) ≃ᵐ ((∀ c : κ, {i : ι // label i = some c} → ℕ) × ({i : ι // label i = none} → ℕ)) := (partitionEquiv label).trans (MeasurableEquiv.piOptionEquivProd (fun c : Option κ => {i : ι // label i = c} → ℕ))omit [DecidableEq ι] in
lemma measurePreserving_external (rate : ι → ℝ≥0) (label : ι → Option κ) : MeasurePreserving (externalEquiv label) (batchMeasure rate) ((Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = some c} => rate i))).prod (batchMeasure (fun i : {i : ι // label i = none} => rate i))) := by have h : MeasurePreserving (MeasurableEquiv.piOptionEquivProd (fun c : Option κ => {i : ι // label i = c} → ℕ)).symm ((Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = some c} => rate i))).prod (batchMeasure (fun i : {i : ι // label i = none} => rate i))) (Measure.pi (fun c : Option κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))) := ⟨(MeasurableEquiv.piOptionEquivProd _).symm.measurable, Measure.pi_map_piOptionEquivProd (fun c : Option κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))⟩ exact h.symm.comp (measurePreserving_partition rate label)
omit [DecidableEq ι] in
lemma integral_external_components (rate : ι → ℝ≥0) (label : ι → Option κ) (weight : ({i : ι // label i = none} → ℕ) → ℝ) (f : ∀ c : κ, ({i : ι // label i = none} → ℕ) → ({i : ι // label i = some c} → ℕ) → ℝ) (hw : ∀ z, |weight z| ≤ 1) (hf : ∀ c z x, |f c z x| ≤ 1) : (∫ ω, weight (fun i => ω i) * ∏ c, f c (fun i => ω i) (fun i => ω i) ∂batchMeasure rate) = ∫ z, weight z * ∏ c, ∫ x, f c z x ∂batchMeasure (fun i : {i : ι // label i = some c} => rate i) ∂batchMeasure (fun i : {i : ι // label i = none} => rate i) := by let μ := Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = some c} => rate i)) let ν := batchMeasure (fun i : {i : ι // label i = none} => rate i) let F : (∀ c : κ, {i : ι // label i = some c} → ℕ) × ({i : ι // label i = none} → ℕ) → ℝ := fun p => weight p.2 * ∏ c, f c p.2 (p.1 c) have hF : Integrable F (μ.prod ν) := by apply Integrable.of_bound (measurable_of_countable F).aestronglyMeasurable 1 apply Filter.Eventually.of_forall intro p simp only [F, Real.norm_eq_abs, abs_mul, Finset.abs_prod] exact (mul_le_of_le_one_left (by positivity) (hw _)).trans (Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => hf _ _ _)) calc _ = ∫ p, F p ∂μ.prod ν := (measurePreserving_external rate label).integral_comp (externalEquiv label).measurableEmbedding F _ = ∫ z, ∫ x, weight z * ∏ c, f c z (x c) ∂μ ∂ν := integral_prod_symm F hF _ = _ := by apply integral_congr_ae apply Filter.Eventually.of_forall intro z dsimp only rw [integral_const_mul] congr 1 exact integral_fintype_prod_eq_prod _
section ComponentGeometry
variable {H : Type*} [Fintype H] [DecidableEq H]
noncomputable def strongGraph (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) : SimpleGraph H where Adj h k := h ≠ k ∧ t < mass rate (s h ∩ s k) symm := ⟨by intro h k hk exact ⟨hk.1.symm, by simpa only [Finset.inter_comm] using hk.2⟩⟩ loopless := ⟨by intro h hh; exact hh.1 rfl⟩
omit [Fintype ι] [Fintype H] [DecidableEq H] inlemma cross_component_overlap (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) {h k : H} (hd : (strongGraph rate s t).connectedComponentMk h ≠ (strongGraph rate s t).connectedComponentMk k) : mass rate (s h ∩ s k) ≤ t := by by_contra hn have hk : h ≠ k := by intro e; exact hd (congrArg _ e) exact hd (SimpleGraph.ConnectedComponent.connectedComponentMk_eq_of_adj (G := strongGraph rate s t) ⟨hk, lt_of_not_ge hn⟩)
def External (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (i : ι) : Prop := ∃ h k : H, i ∈ s h ∧ i ∈ s k ∧ (strongGraph rate s t).connectedComponentMk h ≠ (strongGraph rate s t).connectedComponentMk k
omit [Fintype ι] [Fintype H] [DecidableEq H] inlemma external_iff_other (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) {h : H} {i : ι} (hi : i ∈ s h) : External rate s t i ↔ ∃ k : H, i ∈ s k ∧ (strongGraph rate s t).connectedComponentMk h ≠ (strongGraph rate s t).connectedComponentMk k := by classical constructor · rintro ⟨u, v, hu, hv, huv⟩ by_cases e : (strongGraph rate s t).connectedComponentMk h = (strongGraph rate s t).connectedComponentMk u · exact ⟨v, hv, by simpa only [e] using huv⟩ · exact ⟨u, hu, e⟩ · rintro ⟨k, hk, hd⟩ exact ⟨h, k, hi, hk, hd⟩
noncomputable def externalPart (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (h : H) : Finset ι := by classical exact (s h).filter (External rate s t)
noncomputable def internalPart (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (h : H) : Finset ι := by classical exact (s h).filter (fun i => ¬ External rate s t i)
omit [Fintype ι] [Fintype H] [DecidableEq H] inlemma internal_external_mass (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (h : H) : mass rate (externalPart rate s t h) + mass rate (internalPart rate s t h) = mass rate (s h) := by classical exact Finset.sum_filter_add_sum_filter_not _ _ _
noncomputable def otherComponents (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (h : H) : Finset H := by classical exact Finset.univ.filter (fun k => (strongGraph rate s t).connectedComponentMk h ≠ (strongGraph rate s t).connectedComponentMk k)
omit [Fintype ι] [DecidableEq H] in
lemma external_mass_le_sum (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (h : H) : mass rate (externalPart rate s t h) ≤ ∑ k ∈ otherComponents rate s t h, mass rate (s h ∩ s k) := by classical let K := otherComponents rate s t h have hp (i : ι) (hi : i ∈ s h) : (if External rate s t i then (rate i : ℝ) else 0) ≤ ∑ k ∈ K, if i ∈ s k then (rate i : ℝ) else 0 := by split_ifs with he · obtain ⟨k, hk, hd⟩ := (external_iff_other rate s t hi).mp he have hkK : k ∈ K := by simpa only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] using hd simpa only [ite_eq_left hk] using (Finset.single_le_sum (f := fun j : H => if i ∈ s j then (rate i : ℝ) else 0) (fun j (_ : j ∈ K) => by split_ifs <;> positivity) hkK : (if i ∈ s k then (rate i : ℝ) else 0) ≤ ∑ j ∈ K, if i ∈ s j then (rate i : ℝ) else 0) · exact Finset.sum_nonneg (by intro k hk; split_ifs <;> positivity) calc _ = ∑ i ∈ s h, if External rate s t i then (rate i : ℝ) else 0 := by simp only [externalPart, mass, Finset.sum_filter] _ ≤ ∑ i ∈ s h, ∑ k ∈ K, if i ∈ s k then (rate i : ℝ) else 0 := Finset.sum_le_sum hp _ = ∑ k ∈ K, mass rate (s h ∩ s k) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro k hk rw [mass, ← Finset.filter_mem_eq_inter, Finset.sum_filter] _ = _ := rfl
end ComponentGeometryend SharpRamseyFive.PoissonScoreend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423import Mathlib
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNReal
namespace SharpRamseyFive.PoissonScore
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
noncomputable def batchMeasure (rate : ι → ℝ≥0) : Measure (ι → ℕ) := Measure.pi (fun i => poissonMeasure (rate i))
instance flat_HighMomentRecovered_1 (rate : ι → ℝ≥0) : IsProbabilityMeasure (batchMeasure rate) := by unfold batchMeasure infer_instance
def emptyEvent (s : Finset ι) : Set (ι → ℕ) := (s : Set ι).pi (fun _ => {0})
noncomputable def emptyIndicator (s : Finset ι) (ω : ι → ℕ) : ℝ := (emptyEvent s).indicator (fun _ => 1) ω
noncomputable def mass (rate : ι → ℝ≥0) (s : Finset ι) : ℝ := ∑ i ∈ s, (rate i : ℝ)
omit [Fintype ι] [DecidableEq ι] inlemma measurableSet_emptyEvent (s : Finset ι) : MeasurableSet (emptyEvent s) := by exact MeasurableSet.pi (s.finite_toSet.countable) (fun _ _ => measurableSet_singleton 0)
omit [DecidableEq ι] inlemma measure_emptyEvent (rate : ι → ℝ≥0) (s : Finset ι) : batchMeasure rate (emptyEvent s) = ENNReal.ofReal (Real.exp (-mass rate s)) := by rw [batchMeasure, emptyEvent, Measure.pi_pi_finset] simp_rw [poissonMeasure_singleton, pow_zero, Nat.factorial_zero, Nat.cast_one, mul_one, div_one] rw [← ENNReal.ofReal_prod_of_nonneg (fun _ _ => (Real.exp_pos _).le), ← Real.exp_sum, Finset.sum_neg_distrib] rflomit [DecidableEq ι] in
lemma integral_emptyIndicator (rate : ι → ℝ≥0) (s : Finset ι) : ∫ ω, emptyIndicator s ω ∂batchMeasure rate = Real.exp (-mass rate s) := by simp only [emptyIndicator] rw [integral_indicator_const _ (measurableSet_emptyEvent s), Measure.real, measure_emptyEvent, ENNReal.toReal_ofReal (Real.exp_pos _).le] simpomit [DecidableEq ι] in
lemma integrable_emptyIndicator (rate : ι → ℝ≥0) (s : Finset ι) : Integrable (emptyIndicator s) (batchMeasure rate) := (integrable_const (1 : ℝ)).indicator (measurableSet_emptyEvent s)
omit [Fintype ι] inlemma emptyIndicator_mul (s t : Finset ι) (ω : ι → ℕ) : emptyIndicator s ω * emptyIndicator t ω = emptyIndicator (s ∪ t) ω := by have hu : emptyEvent (s ∪ t) = emptyEvent s ∩ emptyEvent t := by ext x simp [emptyEvent, Set.mem_pi, or_imp, forall_and] rw [emptyIndicator, emptyIndicator, emptyIndicator, hu] by_cases hs : ω ∈ emptyEvent s <;> by_cases ht : ω ∈ emptyEvent t <;> simp [hs, ht]
omit [Fintype ι] inlemma mass_union_inter (rate : ι → ℝ≥0) (s t : Finset ι) : mass rate (s ∪ t) + mass rate (s ∩ t) = mass rate s + mass rate t := by exact Finset.sum_union_inter
noncomputable def centeredFactor (s : Finset ι) (b : ℝ) (ω : ι → ℕ) : ℝ := emptyIndicator s ω - bomit [DecidableEq ι] in
lemma integrable_centeredFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) : Integrable (centeredFactor s b) (batchMeasure rate) := (integrable_emptyIndicator rate s).sub (integrable_const b)omit [DecidableEq ι] in
lemma integral_centeredFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) : ∫ ω, centeredFactor s b ω ∂batchMeasure rate = Real.exp (-mass rate s) - b := by simp only [centeredFactor] rw [integral_sub (integrable_emptyIndicator rate s) (integrable_const b), integral_emptyIndicator] simp
lemma integral_centeredFactor_mul (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : (∫ ω, centeredFactor s b ω * centeredFactor t b ω ∂batchMeasure rate) = (Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b) + Real.exp (-(mass rate s + mass rate t)) * (Real.exp (mass rate (s ∩ t)) - 1) := by have he : (fun ω => centeredFactor s b ω * centeredFactor t b ω) = fun ω => emptyIndicator (s ∪ t) ω - b * emptyIndicator s ω - b * emptyIndicator t ω + b ^ 2 := by funext ω rw [centeredFactor, centeredFactor] have := emptyIndicator_mul s t ω nlinarith [this] rw [he] have hs := integrable_emptyIndicator rate s have ht := integrable_emptyIndicator rate t have hu := integrable_emptyIndicator rate (s ∪ t) have h1 := integral_sub hu (hs.const_mul b) have h2 := integral_sub (hu.sub (hs.const_mul b)) (ht.const_mul b) have h3 := integral_add ((hu.sub (hs.const_mul b)).sub (ht.const_mul b)) (integrable_const (b ^ 2)) simp only [Pi.sub_apply] at h1 h2 h3 rw [h3, h2, h1] simp only [integral_const_mul, integral_emptyIndicator, integral_const, probReal_univ, one_smul] have hmass := mass_union_inter rate s t have hu : Real.exp (-mass rate (s ∪ t)) = Real.exp (-(mass rate s + mass rate t)) * Real.exp (mass rate (s ∩ t)) := by rw [← Real.exp_add] congr 1 linarith have hp : Real.exp (-mass rate s) * Real.exp (-mass rate t) = Real.exp (-(mass rate s + mass rate t)) := by rw [← Real.exp_add] congr 1 ring rw [hu] nlinarith [hp]
omit [Fintype ι] [DecidableEq ι] inlemma emptyIndicator_nonneg (s : Finset ι) (ω : ι → ℕ) : 0 ≤ emptyIndicator s ω := by unfold emptyIndicator apply Set.indicator_nonneg intro _ _ norm_num
omit [Fintype ι] [DecidableEq ι] inlemma abs_centeredFactor_le_one (s : Finset ι) (b : ℝ) (hb : b ∈ Set.Icc 0 1) (ω : ι → ℕ) : |centeredFactor s b ω| ≤ 1 := by unfold centeredFactor emptyIndicator by_cases h : ω ∈ emptyEvent s <;> simp [h, abs_le] <;> constructor <;> linarith [hb.1, hb.2]
omit [Fintype ι] [DecidableEq ι] inlemma centeredFactor_of_hit (s : Finset ι) (b : ℝ) (ω : ι → ℕ) {i : ι} (hi : i ∈ s) (hhit : ω i ≠ 0) : centeredFactor s b ω = -b := by have h : ω ∉ emptyEvent s := by intro he exact hhit (he i hi) simp [centeredFactor, emptyIndicator, h]omit [DecidableEq ι] in
lemma integral_abs_centeredFactor_le (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) : (∫ ω, |centeredFactor s b ω| ∂batchMeasure rate) ≤ Real.exp (-mass rate s) + |b| := by calc _ ≤ ∫ ω, emptyIndicator s ω + |b| ∂batchMeasure rate := by apply integral_mono (integrable_centeredFactor rate s b).abs ((integrable_emptyIndicator rate s).add (integrable_const |b|)) intro ω dsimp [centeredFactor] exact (abs_sub _ _).trans (by rw [abs_of_nonneg (emptyIndicator_nonneg s ω)]) _ = _ := by rw [integral_add (integrable_emptyIndicator rate s) (integrable_const |b|), integral_emptyIndicator] simp
lemma abs_exp_neg_sub_exp_neg_le {a b c : ℝ} (ha : c ≤ a) (hb : c ≤ b) : |Real.exp (-a) - Real.exp (-b)| ≤ Real.exp (-c) * |a - b| := by have ordered : ∀ {a b : ℝ}, c ≤ a → a ≤ b → Real.exp (-a) - Real.exp (-b) ≤ Real.exp (-c) * (b - a) := by intro a b hca hab have he := Real.add_one_le_exp (a - b) have hm := mul_le_mul_of_nonneg_left he (Real.exp_pos (-a)).le have hprod : Real.exp (-a) * Real.exp (a - b) = Real.exp (-b) := by rw [← Real.exp_add] congr 1 ring rw [hprod] at hm have hec : Real.exp (-a) ≤ Real.exp (-c) := Real.exp_le_exp.mpr (neg_le_neg hca) have hd := mul_le_mul_of_nonneg_right hec (sub_nonneg.mpr hab) nlinarith rcases le_total a b with hab | hba · rw [abs_of_nonneg (sub_nonneg.mpr (Real.exp_le_exp.mpr (neg_le_neg hab))), abs_of_nonpos (sub_nonpos.mpr hab)] simpa only [neg_sub] using ordered ha hab · rw [abs_of_nonpos (sub_nonpos.mpr (Real.exp_le_exp.mpr (neg_le_neg hba))), abs_of_nonneg (sub_nonneg.mpr hba)] simpa only [neg_sub] using ordered hb hba
omit [DecidableEq ι] in
lemma abs_integral_centeredFactor_le (rate : ι → ℝ≥0) (s : Finset ι) {L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : |∫ ω, centeredFactor s (Real.exp (-L * base)) ω ∂batchMeasure rate| ≤ L * Real.exp (-L * c) * |lam - base| := by rw [integral_centeredFactor, hmass] have he := abs_exp_neg_sub_exp_neg_le (mul_le_mul_of_nonneg_left hlam hL) (mul_le_mul_of_nonneg_left hbase hL) simpa only [neg_mul, mul_neg, ← mul_sub, abs_mul, abs_of_nonneg hL, mul_comm, mul_left_comm, mul_assoc] using he
omit [DecidableEq ι] in
lemma integral_abs_centeredFactor_exp_le (rate : ι → ℝ≥0) (s : Finset ι) {L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : (∫ ω, |centeredFactor s (Real.exp (-L * base)) ω| ∂batchMeasure rate) ≤ 2 * Real.exp (-L * c) := by have h1 := integral_abs_centeredFactor_le rate s (Real.exp (-L * base)) rw [hmass, abs_of_pos (Real.exp_pos _)] at h1 have h2 : Real.exp (-(L * lam)) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by nlinarith) have h3 : Real.exp (-L * base) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by nlinarith) linarith
lemma integrable_centeredFactor_mul (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : Integrable (fun ω => centeredFactor s b ω * centeredFactor t b ω) (batchMeasure rate) := by have he : (fun ω => centeredFactor s b ω * centeredFactor t b ω) = fun ω => emptyIndicator (s ∪ t) ω - b * emptyIndicator s ω - b * emptyIndicator t ω + b ^ 2 := by funext ω rw [centeredFactor, centeredFactor] nlinarith [emptyIndicator_mul s t ω] rw [he] exact (((integrable_emptyIndicator rate (s ∪ t)).sub ((integrable_emptyIndicator rate s).const_mul b)).sub ((integrable_emptyIndicator rate t).const_mul b)).add (integrable_const (b^2))
omit [Fintype ι] [DecidableEq ι] inlemma mass_nonneg (rate : ι → ℝ≥0) (s : Finset ι) : 0 ≤ mass rate s := by exact Finset.sum_nonneg (fun i _ => (rate i).coe_nonneg)
omit [Fintype ι] [DecidableEq ι] inlemma mass_mono (rate : ι → ℝ≥0) {s t : Finset ι} (hst : s ⊆ t) : mass rate s ≤ mass rate t := by exact Finset.sum_le_sum_of_subset_of_nonneg hst (fun i _ _ => (rate i).coe_nonneg)
lemma one_sub_exp_neg_le (a : ℝ) : 1 - Real.exp (-a) ≤ a := by have := Real.add_one_le_exp (-a) linarith
omit [Fintype ι] in
lemma covariance_le (rate : ι → ℝ≥0) (s t : Finset ι) : Real.exp (-(mass rate s + mass rate t)) * (Real.exp (mass rate (s ∩ t)) - 1) ≤ mass rate (s ∩ t) * Real.exp (-mass rate (s ∪ t)) := by have hu := mass_union_inter rate s t have he : Real.exp (-(mass rate s + mass rate t)) = Real.exp (-mass rate (s ∪ t)) * Real.exp (-mass rate (s ∩ t)) := by rw [← Real.exp_add] congr 1 linarith rw [he] have hh : Real.exp (-mass rate (s ∩ t)) * Real.exp (mass rate (s ∩ t)) = 1 := by rw [← Real.exp_add] simp have hb := mul_le_mul_of_nonneg_left (one_sub_exp_neg_le (mass rate (s ∩ t))) (Real.exp_pos (-mass rate (s ∪ t))).le calc _ = Real.exp (-mass rate (s ∪ t)) * (1 - Real.exp (-mass rate (s ∩ t))) := by rw [mul_assoc, mul_sub, hh, mul_one] _ ≤ _ := by simpa only [mul_comm] using hbomit [Fintype ι] in
lemma covariance_nonneg (rate : ι → ℝ≥0) (s t : Finset ι) : 0 ≤ Real.exp (-(mass rate s + mass rate t)) * (Real.exp (mass rate (s ∩ t)) - 1) := by apply mul_nonneg (Real.exp_pos _).le exact sub_nonneg.mpr (Real.one_le_exp_iff.mpr (mass_nonneg rate _))
lemma abs_integral_centeredFactor_mul_le_mass (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : |∫ ω, centeredFactor s b ω * centeredFactor t b ω ∂batchMeasure rate| ≤ |Real.exp (-mass rate s) - b| * |Real.exp (-mass rate t) - b| + mass rate (s ∩ t) * Real.exp (-mass rate (s ∪ t)) := by rw [integral_centeredFactor_mul] calc _ ≤ |(Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b)| + |Real.exp (-(mass rate s + mass rate t)) * (Real.exp (mass rate (s ∩ t)) - 1)| := abs_add_le _ _ _ ≤ _ := by rw [abs_mul, abs_of_nonneg (covariance_nonneg rate s t)] exact add_le_add le_rfl (covariance_le rate s t)
lemma abs_integral_centeredFactor_mul_exp_le (rate : ι → ℝ≥0) (s t : Finset ι) {L lam₁ lam₂ base c θ : ℝ} (hL : 1 ≤ L) (hc : 0 ≤ c) (hs : mass rate s = L * lam₁) (ht : mass rate t = L * lam₂) (hi : mass rate (s ∩ t) = L * θ) (h₁ : c ≤ lam₁) (h₂ : c ≤ lam₂) (hbase : c ≤ base) : |∫ ω, centeredFactor s (Real.exp (-L * base)) ω * centeredFactor t (Real.exp (-L * base)) ω ∂batchMeasure rate| ≤ L ^ 2 * Real.exp (-L * c) * (|lam₁ - base| * |lam₂ - base| + θ) := by have hL0 : 0 ≤ L := le_trans (by norm_num) hL have hi0 := mass_nonneg rate (s ∩ t) have hθ : 0 ≤ θ := by rw [hi] at hi0; nlinarith have hu : L * c ≤ mass rate (s ∪ t) := by calc _ ≤ L * lam₁ := mul_le_mul_of_nonneg_left h₁ hL0 _ = mass rate s := hs.symm _ ≤ mass rate (s ∪ t) := mass_mono rate Finset.subset_union_left have huse : Real.exp (-mass rate (s ∪ t)) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by linarith) have hepos := Real.exp_pos (-L * c) have hele : Real.exp (-L * c) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith) have e₁ := abs_integral_centeredFactor_le rate s hL0 hs h₁ hbase have e₂ := abs_integral_centeredFactor_le rate t hL0 ht h₂ hbase rw [integral_centeredFactor] at e₁ e₂ have hmul := mul_le_mul e₁ e₂ (abs_nonneg _) (mul_nonneg (mul_nonneg hL0 hepos.le) (abs_nonneg _)) have hab := mul_nonneg (abs_nonneg (lam₁ - base)) (abs_nonneg (lam₂ - base)) have hpow : Real.exp (-L * c) ^ 2 ≤ Real.exp (-L * c) := by nlinarith have hbound := mul_le_mul_of_nonneg_left hpow (mul_nonneg (sq_nonneg L) hab) have hcov := mul_le_mul_of_nonneg_left huse hi0 rw [hi] at hcov have hLsq : L ≤ L ^ 2 := by nlinarith have hcov' := mul_le_mul_of_nonneg_right hLsq (mul_nonneg hθ hepos.le) have hfinal := abs_integral_centeredFactor_mul_le_mass rate s t (Real.exp (-L * base)) nlinarith
noncomputable def scheduleMeasure (rate : ι → ℝ≥0) (R : ℕ) : Measure (Fin R → ι → ℕ) := Measure.pi (fun _ : Fin R => batchMeasure rate)
instance flat_HighMomentRecovered_2 (rate : ι → ℝ≥0) (R : ℕ) : IsProbabilityMeasure (scheduleMeasure rate R) := by unfold scheduleMeasure infer_instance
noncomputable def scoreTerm {R : ℕ} (s : Finset ι) (b : ℝ) (own : Fin R → Bool) (ω : Fin R → ι → ℕ) : ℝ := ∏ r, if own r then centeredFactor s b (ω r) else 0omit [DecidableEq ι] in
lemma integrable_scoreTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ) (own : Fin R → Bool) : Integrable (scoreTerm s b own) (scheduleMeasure rate R) := by apply Integrable.fintype_prod (f := fun r ω => if own r then centeredFactor s b ω else 0) intro r cases h : own r <;> simp only [Bool.false_eq_true, ↓reduceIte] · exact integrable_const 0 · exact integrable_centeredFactor rate s bomit [DecidableEq ι] in
lemma integral_scoreTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ) (own : Fin R → Bool) : (∫ ω, scoreTerm s b own ω ∂scheduleMeasure rate R) = ∏ r, if own r then Real.exp (-mass rate s) - b else 0 := by unfold scoreTerm scheduleMeasure rw [integral_fintype_prod_eq_prod (f := fun r ω => if own r then centeredFactor s b ω else 0)] congr 1 funext r cases h : own r <;> simp [integral_centeredFactor]
noncomputable def pairMean (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : ℝ := (Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b) + Real.exp (-(mass rate s + mass rate t)) * (Real.exp (mass rate (s ∩ t)) - 1)
lemma integrable_scoreTerm_mul (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ) (ownS ownT : Fin R → Bool) : Integrable (fun ω => scoreTerm s b ownS ω * scoreTerm t b ownT ω) (scheduleMeasure rate R) := by simp only [scoreTerm, ← Finset.prod_mul_distrib] apply Integrable.fintype_prod (f := fun r ω => (if ownS r then centeredFactor s b ω else 0) * (if ownT r then centeredFactor t b ω else 0)) intro r cases hs : ownS r <;> cases ht : ownT r <;> simp only [Bool.false_eq_true, ↓reduceIte, zero_mul, mul_zero] · exact integrable_const 0 · exact integrable_const 0 · exact integrable_const 0 · exact integrable_centeredFactor_mul rate s t b
lemma integral_scoreTerm_mul (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ) (ownS ownT : Fin R → Bool) : (∫ ω, scoreTerm s b ownS ω * scoreTerm t b ownT ω ∂scheduleMeasure rate R) = ∏ r, if ownS r && ownT r then pairMean rate s t b else 0 := by simp only [scoreTerm, ← Finset.prod_mul_distrib, scheduleMeasure] rw [integral_fintype_prod_eq_prod (f := fun r ω => (if ownS r then centeredFactor s b ω else 0) * (if ownT r then centeredFactor t b ω else 0))] congr 1 funext r cases hs : ownS r <;> cases ht : ownT r <;> simp [integral_centeredFactor_mul, pairMean]
lemma abs_integral_scoreTerm_mul_le (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ) (ownS ownT : Fin R → Bool) : |∫ ω, scoreTerm s b ownS ω * scoreTerm t b ownT ω ∂scheduleMeasure rate R| ≤ |pairMean rate s t b| ^ R := by rw [integral_scoreTerm_mul, Finset.abs_prod] calc _ ≤ ∏ _ : Fin R, |pairMean rate s t b| := by apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) intro r _ split_ifs <;> simp _ = _ := by simp
variable {κ : Type*}
noncomputable def typicalScore {R : ℕ} (H : Finset κ) (directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) (ω : Fin R → ι → ℕ) : ℝ := ∑ h ∈ H, scoreTerm (directions h) b (own h) ω
lemma integral_typicalScore_sq (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ) (directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) : (∫ ω, (typicalScore H directions b own ω)^2 ∂scheduleMeasure rate R) = ∑ h ∈ H, ∑ k ∈ H, ∏ r, if own h r && own k r then pairMean rate (directions h) (directions k) b else 0 := by simp only [typicalScore, pow_two] simp_rw [Finset.sum_mul] simp_rw [Finset.mul_sum] rw [integral_finsetSum H (fun h _ => integrable_finsetSum H (fun k _ => integrable_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k)))] apply Finset.sum_congr rfl intro h _ rw [integral_finsetSum H (fun k _ => integrable_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k))] apply Finset.sum_congr rfl intro k _ exact integral_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k)
end SharpRamseyFive.PoissonScoreend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import Mathlibimport OAI.Combinatorics.SharpRamsey.Marking.HighRankContext
namespace OAI
sectionnamespace SharpLogRamsey.ActualHighRankopen Finset Real Selectionopen scoped Classical BigOperatorsnoncomputable sectionvariable {K V Ω : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Fintype Ω] [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))]
omit [FiniteDimensional K V] [Fintype (Projectivization K (Module.Dual K V))] inlemma projective_card_bound {d : ℕ} (hdim : Module.finrank K V=d+1) : (Fintype.card (Projectivization K V):ℝ)≤2*(Nat.card K:ℝ)^d := by rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim,Nat.cast_sum] simp only [Nat.cast_pow] exact HighRankExcess.geom_sum_le_twice (by exact_mod_cast (Finite.one_lt_card : 1<Nat.card K)) d
omit [FiniteDimensional K V] [Fintype (Projectivization K (Module.Dual K V))] inlemma projective_card_positive {d : ℕ} (hdim : Module.finrank K V=d+1) : (0:ℝ)<Fintype.card (Projectivization K V) := by rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim,Nat.cast_sum] apply lt_of_lt_of_le (by norm_num : (0:ℝ)<(Nat.card K^0:ℕ)) exact single_le_sum (fun i _=>Nat.cast_nonneg _) (mem_range.mpr (by omega))
omit [FiniteDimensional K V] inlemma flag_card_log {d : ℕ} (hdim : Module.finrank K V=d+1) : log (Fintype.card (Projectivization K (Module.Dual K V)×Projectivization K V))≤ 2*(log 2+(d:ℝ)*log (Nat.card K)) := by have hdual : Module.finrank K (Module.Dual K V)=d+1 := by rw [Subspace.dual_finrank_eq,hdim] have ha:=projective_card_bound hdual have hb:=projective_card_bound hdim have hap:=projective_card_positive hdual have hbp:=projective_card_positive hdim have hq : (0:ℝ)<Nat.card K := by exact_mod_cast Finite.card_pos simp only [Fintype.card_prod,Nat.cast_mul] apply (log_le_log (mul_pos hap hbp) (mul_le_mul ha hb hbp.le (by positivity))).trans rw [←pow_two,log_pow,log_mul (by norm_num) (pow_ne_zero _ hq.ne'),log_pow] rfl
omit [FiniteDimensional K V] intheorem raw_entropy {d h : ℕ} (hdim : Module.finrank K V=d+1) (p : Law Ω) (code : Ω→(Fin h→Projectivization K (Module.Dual K V)×Projectivization K V)× (Fin h→Projectivization K (Module.Dual K V)×Projectivization K V)) : entropy (p.map code)≤4*(h:ℝ)*(log 2+(d:ℝ)*log (Nat.card K)) := by apply (raw_rows_entropy h p code).trans have hh:=mul_le_mul_of_nonneg_left (flag_card_log hdim) (by positivity : 0≤2*(h:ℝ)) convert hh using 1 ring
endend SharpLogRamsey.ActualHighRank
end
end OAI123456789101112131415161718192021222324252627282930import Mathlibimport OAI.Combinatorics.SharpRamsey.Parameters.ExposureScales
namespace OAI
sectionnamespace SharpLogRamsey.SourceScalesopen Real Filteropen scoped Topologynoncomputable section
theorem eventually_information_bad_small (η C c ε : ℝ) (hη : 0<η) (hC : 0≤C) (hc : 0<c) (hε : 0<ε) : ∀ᶠ σ : ℝ in atTop, ∀ q D N budget k : ℝ, 0<q → 0<D → 0≤N → budget≤C*N*D*σ^(-beta η) → c*q*D*σ^(3000*beta η)≤k → let a:=σ^(-2000*beta η)/q budget/(D*σ^beta η)+2*budget/(k*a)≤N*ε := by filter_upwards [eventually_integer_bad_small η C c ε hη hC hc hε, eventually_ge_atTop (0:ℝ)] with σ h hσ intro q D N budget k hq hD hN hb hk have hh:=h q D N budget 0 (c*q*σ^(1+η/2)) k hq hD hN hb (mul_nonneg hC hσ) hk le_rfl simpa only [mul_zero,zero_div,add_zero] using hhendend SharpLogRamsey.SourceScales
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.HighMoments
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealnamespace SharpRamseyFive.PoissonScorevariable {ι : Type*} [Fintype ι] [DecidableEq ι]variable {κ : Type*}lemma integral_typicalScore_sq_le (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ) (directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) : (∫ ω, (typicalScore H directions b own ω)^2 ∂scheduleMeasure rate R) ≤ ∑ h ∈ H, ∑ k ∈ H, |pairMean rate (directions h) (directions k) b|^R := by rw [integral_typicalScore_sq] apply Finset.sum_le_sum intro h _ apply Finset.sum_le_sum intro k _ rw [← integral_scoreTerm_mul] exact (le_abs_self _).trans (abs_integral_scoreTerm_mul_le rate (directions h) (directions k) b (own h) (own k))
section TupleCalculation
variable {ν : Type*} [DecidableEq ν]omit [Fintype ι] in
lemma prod_emptyIndicator (I : Finset ν) (directions : ν → Finset ι) (ω : ι → ℕ) : (∏ h ∈ I, emptyIndicator (directions h) ω) = emptyIndicator (I.biUnion directions) ω := by induction I using Finset.induction_on with | empty => simp [emptyIndicator, emptyEvent] | @insert h I hh ih => rw [Finset.prod_insert hh, Finset.biUnion_insert, ih, emptyIndicator_mul]omit [Fintype ι] in
lemma prod_centeredFactor (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) (ω : ι → ℕ) : (∏ h ∈ I, centeredFactor (directions h) b ω) = ∑ J ∈ I.powerset, (-b) ^ (I \ J).card * emptyIndicator (J.biUnion directions) ω := by simp only [centeredFactor, sub_eq_add_neg] rw [Finset.prod_add] apply Finset.sum_congr rfl intro J _ rw [prod_emptyIndicator, Finset.prod_const] ring
lemma integrable_prod_centeredFactor (rate : ι → ℝ≥0) (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) : Integrable (fun ω => ∏ h ∈ I, centeredFactor (directions h) b ω) (batchMeasure rate) := by simp_rw [prod_centeredFactor] exact integrable_finsetSum _ (fun J _ => (integrable_emptyIndicator rate _).const_mul _)
noncomputable def tupleMean (rate : ι → ℝ≥0) (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) : ℝ := ∑ J ∈ I.powerset, (-b) ^ (I \ J).card * Real.exp (-mass rate (J.biUnion directions))
lemma integral_prod_centeredFactor (rate : ι → ℝ≥0) (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) : (∫ ω, ∏ h ∈ I, centeredFactor (directions h) b ω ∂batchMeasure rate) = tupleMean rate I directions b := by simp_rw [prod_centeredFactor] rw [integral_finsetSum _ (fun J _ => (integrable_emptyIndicator rate _).const_mul _)] simp only [integral_const_mul, integral_emptyIndicator, tupleMean]
omit [Fintype ι] [DecidableEq ι] [DecidableEq ν] inlemma prod_scoreTerm (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) (ω : Fin R → ι → ℕ) : (∏ h ∈ I, scoreTerm (directions h) b (own h) ω) = ∏ r, if ∀ h ∈ I, own h r then ∏ h ∈ I, centeredFactor (directions h) b (ω r) else 0 := by simp only [scoreTerm] rw [Finset.prod_comm] apply Finset.prod_congr rfl intro r _ exact Finset.prod_ite_zero
lemma integrable_prod_scoreTerm (rate : ι → ℝ≥0) (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) : Integrable (fun ω => ∏ h ∈ I, scoreTerm (directions h) b (own h) ω) (scheduleMeasure rate R) := by simp_rw [prod_scoreTerm] apply Integrable.fintype_prod (f := fun r ω => if ∀ h ∈ I, own h r then ∏ h ∈ I, centeredFactor (directions h) b ω else 0) intro r split_ifs · exact integrable_prod_centeredFactor rate I directions b · exact integrable_const 0
lemma integral_prod_scoreTerm (rate : ι → ℝ≥0) (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) : (∫ ω, ∏ h ∈ I, scoreTerm (directions h) b (own h) ω ∂scheduleMeasure rate R) = ∏ r, if ∀ h ∈ I, own h r then tupleMean rate I directions b else 0 := by simp_rw [prod_scoreTerm] unfold scheduleMeasure rw [integral_fintype_prod_eq_prod (f := fun r ω => if ∀ h ∈ I, own h r then ∏ h ∈ I, centeredFactor (directions h) b ω else 0)] apply Finset.prod_congr rfl intro r _ split_ifs <;> simp [integral_prod_centeredFactor]
lemma abs_integral_prod_scoreTerm_le (rate : ι → ℝ≥0) (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) : |∫ ω, ∏ h ∈ I, scoreTerm (directions h) b (own h) ω ∂scheduleMeasure rate R| ≤ |tupleMean rate I directions b| ^ R := by rw [integral_prod_scoreTerm, Finset.abs_prod] calc _ ≤ ∏ _ : Fin R, |tupleMean rate I directions b| := by apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) intro r _ split_ifs <;> simp _ = _ := by simp
end TupleCalculation
lemma integral_typicalScore_pow (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ) (directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) (p : ℕ) : (∫ ω, (typicalScore H directions b own ω)^p ∂scheduleMeasure rate R) = ∑ hs ∈ Fintype.piFinset (fun _ : Fin p => H), ∏ r, if ∀ i : Fin p, own (hs i) r then tupleMean rate Finset.univ (fun i => directions (hs i)) b else 0 := by classical simp only [typicalScore] simp_rw [Finset.sum_pow'] rw [integral_finsetSum _ (fun hs _ => integrable_prod_scoreTerm rate Finset.univ (fun i => directions (hs i)) b (fun i => own (hs i)))] apply Finset.sum_congr rfl intro hs _ simpa using integral_prod_scoreTerm rate Finset.univ (fun i => directions (hs i)) b (fun i => own (hs i))
noncomputable def maskedFactor (s : Finset ι) (b : ℝ) (own touched : Bool) (ω : ι → ℕ) : ℝ := if own then (if touched then -b else centeredFactor s b ω) else 0
noncomputable def maskedTerm {R : ℕ} (s : Finset ι) (b : ℝ) (own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) : ℝ := ∏ r, maskedFactor s b (own r) (touched r) (ω r)omit [Fintype ι] [DecidableEq ι] in
lemma abs_maskedFactor_le_one (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Bool) (ω : ι → ℕ) : |maskedFactor s b own touched ω| ≤ 1 := by cases own <;> cases touched <;> simp [maskedFactor, abs_centeredFactor_le_one s b hb ω, abs_of_nonneg hb.1, hb.2]omit [Fintype ι] [DecidableEq ι] in
lemma abs_maskedTerm_le_one {R : ℕ} (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) : |maskedTerm s b own touched ω| ≤ 1 := by rw [maskedTerm, Finset.abs_prod] exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => abs_maskedFactor_le_one s hb _ _ _)
omit [DecidableEq ι] inlemma integrable_schedule_of_abs_le (rate : ι → ℝ≥0) {R : ℕ} (f : (Fin R → ι → ℕ) → ℝ) (C : ℝ) (h : ∀ ω, |f ω| ≤ C) : Integrable f (scheduleMeasure rate R) := by apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable C exact Filter.Eventually.of_forall (fun ω => by simpa only [Real.norm_eq_abs] using h ω)omit [DecidableEq ι] in
lemma integrable_maskedFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) (own touched : Bool) : Integrable (maskedFactor s b own touched) (batchMeasure rate) := by cases own <;> cases touched · exact integrable_const 0 · exact integrable_const 0 · exact integrable_centeredFactor rate s b · exact integrable_const (-b)omit [DecidableEq ι] in
lemma integral_maskedFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) (own touched : Bool) : (∫ ω, maskedFactor s b own touched ω ∂batchMeasure rate) = if own then (if touched then -b else Real.exp (-mass rate s) - b) else 0 := by cases own <;> cases touched <;> simp [maskedFactor, integral_centeredFactor]omit [DecidableEq ι] in
lemma integral_maskedTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ) (own touched : Fin R → Bool) : (∫ ω, maskedTerm s b own touched ω ∂scheduleMeasure rate R) = ∏ r, if own r then (if touched r then -b else Real.exp (-mass rate s) - b) else 0 := by unfold maskedTerm scheduleMeasure rw [integral_fintype_prod_eq_prod] simp only [integral_maskedFactor]omit [DecidableEq ι] in
lemma integral_abs_maskedFactor_exp_le (rate : ι → ℝ≥0) (s : Finset ι) (own touched : Bool) {L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : (∫ ω, |maskedFactor s (Real.exp (-L * base)) own touched ω| ∂batchMeasure rate) ≤ 2 * Real.exp (-L * c) := by have he := Real.exp_pos (-L * c) have hb : Real.exp (-L * base) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by nlinarith) cases own <;> cases touched <;> simp only [maskedFactor, Bool.false_eq_true, ↓reduceIte] · simp only [abs_zero, integral_zero]; positivity · simp only [abs_zero, integral_zero]; positivity · exact integral_abs_centeredFactor_exp_le rate s hL hmass hlam hbase · simp only [abs_neg, abs_of_pos (Real.exp_pos _), integral_const, probReal_univ, smul_eq_mul, one_mul] linarithomit [DecidableEq ι] in
lemma integral_abs_maskedTerm_exp_le (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : (∫ ω, |maskedTerm s (Real.exp (-L * base)) own touched ω| ∂scheduleMeasure rate R) ≤ (2 * Real.exp (-L * c)) ^ R := by simp only [maskedTerm, Finset.abs_prod, scheduleMeasure] rw [integral_fintype_prod_eq_prod (f := fun r ω => |maskedFactor s (Real.exp (-L * base)) (own r) (touched r) ω|)] calc _ ≤ ∏ _ : Fin R, 2 * Real.exp (-L * c) := by apply Finset.prod_le_prod₀ (fun _ _ => integral_nonneg (fun _ => abs_nonneg _)) intro r _ exact integral_abs_maskedFactor_exp_le rate s (own r) (touched r) hL hmass hlam hbase _ = _ := by simpomit [Fintype ι] [DecidableEq ι] in
lemma abs_prod_maskedTerm_le {ν : Type*} [DecidableEq ν] {R : ℕ} (I : Finset ν) (directions : ν → Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : ν → Fin R → Bool) {h : ν} (hh : h ∈ I) (ω : Fin R → ι → ℕ) : |∏ i ∈ I, maskedTerm (directions i) b (own i) (touched i) ω| ≤ |maskedTerm (directions h) b (own h) (touched h) ω| := by rw [Finset.abs_prod, ← Finset.prod_erase_mul _ _ hh] have hp : (∏ i ∈ I.erase h, |maskedTerm (directions i) b (own i) (touched i) ω|) ≤ 1 := Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => abs_maskedTerm_le_one _ hb _ _ _) simpa using mul_le_mul_of_nonneg_right hp (abs_nonneg (maskedTerm (directions h) b (own h) (touched h) ω))
omit [DecidableEq ι] in
lemma integral_abs_component_indicator_le (rate : ι → ℝ≥0) {ν : Type*} [DecidableEq ν] {R : ℕ} (I : Finset ν) (directions : ν → Finset ι) (own touched : ν → Fin R → Bool) (E : Set (Fin R → ι → ℕ)) {h : ν} (hh : h ∈ I) {L lam base c : ℝ} (hL : 0 ≤ L) (hc : 0 ≤ c) (hmass : mass rate (directions h) = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : (∫ ω, |E.indicator (fun ω => ∏ i ∈ I, maskedTerm (directions i) (Real.exp (-L * base)) (own i) (touched i) ω) ω| ∂scheduleMeasure rate R) ≤ (2 * Real.exp (-L * c)) ^ R := by have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 := ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ have hpoint : ∀ ω, |E.indicator (fun ω => ∏ i ∈ I, maskedTerm (directions i) (Real.exp (-L * base)) (own i) (touched i) ω) ω| ≤ |maskedTerm (directions h) (Real.exp (-L * base)) (own h) (touched h) ω| := by intro ω by_cases he : ω ∈ E · simpa only [Set.indicator_of_mem he] using abs_prod_maskedTerm_le I directions hb own touched hh ω · simp only [Set.indicator_of_notMem he, abs_zero]; exact abs_nonneg _ calc _ ≤ ∫ ω, |maskedTerm (directions h) (Real.exp (-L * base)) (own h) (touched h) ω| ∂scheduleMeasure rate R := by apply integral_mono · apply integrable_schedule_of_abs_le rate _ 1 intro ω rw [abs_abs] exact (hpoint ω).trans (abs_maskedTerm_le_one _ hb _ _ _) · exact (integrable_schedule_of_abs_le rate _ 1 (abs_maskedTerm_le_one _ hb _ _)).abs · exact hpoint _ ≤ _ := integral_abs_maskedTerm_exp_le rate _ _ _ hL hmass hlam hbase
def untouchedBatches {R : ℕ} (touched : Fin R → Bool) : Finset (Fin R) := Finset.univ.filter (fun r => touched r = false)
omit [DecidableEq ι] in
lemma abs_integral_maskedTerm_le_untouched (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (own touched : Fin R → Bool) {L base c delta alpha : ℝ} (hL : 1 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) (hinternal : c ≤ base + delta - alpha) (hbase : c ≤ base) (ha : 0 ≤ alpha) : |∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤ (L * Real.exp (-L * c)) ^ R * (|delta| + alpha) ^ (untouchedBatches touched).card := by have hL0 : 0 ≤ L := by linarith have he := (Real.exp_pos (-L * c)).le have hd : 0 ≤ |delta| + alpha := add_nonneg (abs_nonneg _) ha have hu := abs_integral_centeredFactor_le rate s hL0 hmass hinternal hbase rw [integral_centeredFactor] at hu have hdif : |base + delta - alpha - base| ≤ |delta| + alpha := by calc |base + delta - alpha - base| = |delta - alpha| := by congr 1; ring _ ≤ |delta| + |alpha| := abs_sub _ _ _ = _ := by rw [abs_of_nonneg ha] have hu' := hu.trans (mul_le_mul_of_nonneg_left hdif (mul_nonneg hL0 he)) have hb : Real.exp (-L * base) ≤ L * Real.exp (-L * c) := by have h₁ : Real.exp (-L * base) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by nlinarith) have h₂ := mul_le_mul_of_nonneg_right hL he nlinarith rw [integral_maskedTerm, Finset.abs_prod] calc _ ≤ ∏ r, (L * Real.exp (-L * c)) * (if touched r then 1 else |delta| + alpha) := by apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) intro r _ cases ho : own r <;> cases ht : touched r <;> simp only [Bool.false_eq_true, ↓reduceIte, abs_neg, abs_zero, mul_one] · exact mul_nonneg (mul_nonneg hL0 he) hd · exact mul_nonneg hL0 he · exact hu' · simpa only [abs_of_pos (Real.exp_pos _)] using hb _ = _ := by rw [Finset.prod_mul_distrib] simp [Finset.prod_ite, untouchedBatches]omit [DecidableEq ι] in
lemma abs_integral_maskedTerm_le_designations (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (own touched : Fin R → Bool) {L base c delta alpha : ℝ} (hL : 1 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) (hinternal : c ≤ base + delta - alpha) (hbase : c ≤ base) (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} (hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) : |∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤ (2 * L * Real.exp (-L * c)) ^ R * (|delta| ^ N + alpha ^ K) := by have hNR : N ≤ R := hN.trans (by simpa using Finset.card_le_univ (untouchedBatches touched)) have hKpow : alpha ^ N ≤ alpha ^ K := pow_le_pow_of_le_one ha (by linarith [abs_nonneg delta]) hK have h2pow : (2 : ℝ) ^ (N - 1) ≤ 2 ^ R := pow_le_pow_right₀ (by norm_num) ((Nat.sub_le N 1).trans hNR) have hsplit : (|delta| + alpha) ^ (untouchedBatches touched).card ≤ 2 ^ R * (|delta| ^ N + alpha ^ K) := calc _ ≤ (|delta| + alpha) ^ N := pow_le_pow_of_le_one (by positivity) hd hN _ ≤ 2 ^ (N - 1) * (|delta| ^ N + alpha ^ N) := add_pow_le (abs_nonneg _) ha N _ ≤ _ := mul_le_mul h2pow (add_le_add le_rfl hKpow) (by positivity) (by positivity) calc _ ≤ (L * Real.exp (-L * c)) ^ R * (|delta| + alpha) ^ (untouchedBatches touched).card := abs_integral_maskedTerm_le_untouched rate s own touched hL hmass hinternal hbase ha _ ≤ (L * Real.exp (-L * c)) ^ R * (2 ^ R * (|delta| ^ N + alpha ^ K)) := mul_le_mul_of_nonneg_left hsplit (by positivity) _ = _ := by rw [← mul_assoc, ← mul_pow]; congr 2; ring
lemma two_mul_le_exp_small {L : ℝ} (hL : 10000 ≤ L) : 2 * L ≤ Real.exp ((3 / 50 : ℝ) * L) := by have hL0 : 0 ≤ L := by linarith have he := Real.quadratic_le_exp_of_nonneg (show 0 ≤ (3 / 50 : ℝ) * L by positivity) have hs : 10000 * L ≤ L ^ 2 := by nlinarith [mul_nonneg (sub_nonneg.mpr hL) hL0] nlinarith
lemma two_mul_score_attenuation {L : ℝ} (hL : 10000 ≤ L) (R : ℕ) : (2 * L * Real.exp (-(37 / 50 : ℝ) * L)) ^ R ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := by have h := mul_le_mul_of_nonneg_right (two_mul_le_exp_small hL) (Real.exp_pos (-(37 / 50 : ℝ) * L)).le rw [← Real.exp_add] at h have heq : (3 / 50 : ℝ) * L + -(37 / 50 : ℝ) * L = -(17 / 25 : ℝ) * L := by ring rw [heq] at h have hp := pow_le_pow_left₀ (show 0 ≤ 2 * L * Real.exp (-(37 / 50 : ℝ) * L) by have : 0 ≤ L := by linarith positivity) h R rw [← Real.exp_nat_mul] at hp convert hp using 1 congr 1 ring
omit [DecidableEq ι] in
lemma simple_singleton_attenuation (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (own touched : Fin R → Bool) {L base delta alpha : ℝ} (hL : 10000 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) (hinternal : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} (hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) : |∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K) := by have h := abs_integral_maskedTerm_le_designations rate s own touched (show 1 ≤ L by linarith) hmass hinternal hbase ha hd hN hK apply h.trans simpa only [neg_mul, mul_comm L (37 / 50 : ℝ)] using mul_le_mul_of_nonneg_right (two_mul_score_attenuation hL R) (show 0 ≤ |delta| ^ N + alpha ^ K by positivity)
noncomputable def hitIndicator (i : ι) (ω : ι → ℕ) : ℝ := 1 - emptyIndicator {i} ω
omit [Fintype ι] [DecidableEq ι] inlemma hitIndicator_eq (i : ι) (ω : ι → ℕ) : hitIndicator i ω = if ω i = 0 then 0 else 1 := by simp only [hitIndicator, emptyIndicator, emptyEvent ] by_cases h : ω i = 0 <;> simp [h]omit [Fintype ι] [DecidableEq ι] in
lemma hitIndicator_nonneg (i : ι) (ω : ι → ℕ) : 0 ≤ hitIndicator i ω := by rw [hitIndicator_eq]; split <;> norm_numomit [Fintype ι] [DecidableEq ι] in
lemma hitIndicator_le_one (i : ι) (ω : ι → ℕ) : hitIndicator i ω ≤ 1 := by rw [hitIndicator_eq]; split <;> norm_numomit [DecidableEq ι] in
lemma integrable_hitIndicator (rate : ι → ℝ≥0) (i : ι) : Integrable (hitIndicator i) (batchMeasure rate) := (integrable_const 1).sub (integrable_emptyIndicator rate {i})omit [DecidableEq ι] in
lemma integral_hitIndicator (rate : ι → ℝ≥0) (i : ι) : (∫ ω, hitIndicator i ω ∂batchMeasure rate) = 1 - Real.exp (-(rate i : ℝ)) := by unfold hitIndicator rw [integral_sub (integrable_const 1) (integrable_emptyIndicator rate {i}), integral_emptyIndicator] simp [mass]omit [Fintype ι] [DecidableEq ι] in
lemma maskedFactor_mul_hit (s : Finset ι) (i : ι) (hi : i ∈ s) (b : ℝ) (own touched : Bool) (ω : ι → ℕ) : maskedFactor s b own touched ω * hitIndicator i ω = (if own then -b else 0) * hitIndicator i ω := by rw [hitIndicator_eq] by_cases hz : ω i = 0 · simp [hz] · simp only [hz, ↓reduceIte, mul_one] have hh : ω ∉ emptyEvent s := by intro h exact hz (h i hi) cases own <;> cases touched <;> simp [maskedFactor, centeredFactor_of_hit s b ω hi hz]omit [DecidableEq ι] in
lemma integral_abs_maskedFactor_hit_le (rate : ι → ℝ≥0) (s : Finset ι) (i : ι) (hi : i ∈ s) (own touched : Bool) {L base c : ℝ} (hL : 0 ≤ L) (hbase : c ≤ base) : (∫ ω, |maskedFactor s (Real.exp (-L * base)) own touched ω| * hitIndicator i ω ∂batchMeasure rate) ≤ Real.exp (-L * c) * (rate i : ℝ) := by have heq : (fun ω => |maskedFactor s (Real.exp (-L * base)) own touched ω| * hitIndicator i ω) = fun ω => (if own then Real.exp (-L * base) else 0) * hitIndicator i ω := by funext ω rw [← abs_of_nonneg (hitIndicator_nonneg i ω), ← abs_mul, maskedFactor_mul_hit s i hi] cases own <;> simp [abs_mul, abs_of_nonneg (hitIndicator_nonneg i ω), abs_of_pos (Real.exp_pos _)] rw [heq, integral_const_mul, integral_hitIndicator] have hnonneg : 0 ≤ 1 - Real.exp (-(rate i : ℝ)) := by have : Real.exp (-(rate i : ℝ)) ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (rate i).coe_nonneg) linarith have hb : Real.exp (-L * base) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by nlinarith) cases own · simp only [Bool.false_eq_true, ↓reduceIte, zero_mul]; positivity · simp only [↓reduceIte] exact mul_le_mul hb (one_sub_exp_neg_le (rate i : ℝ)) hnonneg (Real.exp_pos _).le
noncomputable def forcedHits {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) : ℝ := ∏ r ∈ T, hitIndicator i (ω r)omit [Fintype ι] [DecidableEq ι] in
lemma forcedHits_nonneg {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) : 0 ≤ forcedHits i T ω := Finset.prod_nonneg (fun _ _ => hitIndicator_nonneg _ _)
end SharpRamseyFive.PoissonScoreend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.CompleteProgramWeight
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen scoped BigOperatorsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators ENNReal NNRealnamespace SharpRamseyFive.SelectionBridgeopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignationsopen SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedProgramsopen Classicalvariable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]omit [DecidableEq V] [DecidableEq H] inlemma labelled_filter_card (P : H → Prop) [DecidablePred P] : (Finset.univ.filter (fun x : H × V => P x.1)).card = (Finset.univ.filter P).card * Fintype.card V := by have he : Finset.univ.filter (fun x : H × V => P x.1) = (Finset.univ.filter P) ×ˢ (Finset.univ : Finset V) := by ext z simp rw [he, Finset.card_product, Finset.card_univ]omit [DecidableEq V] in
lemma vertexBadMass_nonneg (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (R J : ℕ) (A : Finset V) : 0 ≤ vertexBadMass weight rate s t R J A := by unfold vertexBadMass exact badMass_nonneg _ _ (blockTrunc_range _ R J none) _ A
theorem all_bad_residual_sum_le (weight rate : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) (R : ℕ) (denom b mass : ℝ) (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) (A : Finset V) (g : V → H) : (∑ f : V → H, if (∀ v ∉ A, g v = f v) then vertexBadMass weight rate (lines ∘ f) t R J A else 0) ≤ denom ^ A.card * ∑ n : Fin (A.card + 1), branchingBound (V := V) (B := Fin R) (fun z : H × V => lines z.1) rate denom b mass K (N₁ * Fintype.card V) (N₂ * Fintype.card V) low ^ n.val := by let F : (V → H × V) → ℝ := fun f => if Function.Injective f ∧ (∀ v ∉ A, labelled g v = f v) then vertexBadMass weight rate ((fun z : H × V => lines z.1) ∘ f) t R J A else 0 have hF (f : V → H × V) : 0 ≤ F f := by dsimp [F] split_ifs · exact vertexBadMass_nonneg weight rate _ t R J A · exact le_rfl have he (f : V → H) : F (labelled f) = if (∀ v ∉ A, g v = f v) then vertexBadMass weight rate (lines ∘ f) t R J A else 0 := by have ha : (∀ v ∉ A, labelled g v = labelled f v) ↔ (∀ v ∉ A, g v = f v) := by simp only [labelled, Prod.mk.injEq, and_true] simp only [F, labelled_injective, true_and, ha] rfl calc _ = ∑ f : V → H, F (labelled f) := by simp only [he] _ = ∑ f ∈ Finset.univ.image (labelled : (V → H) → (V → H × V)), F f := by rw [Finset.sum_image (fun _ _ _ _ h => labelled_map_injective h)] _ ≤ ∑ f : V → H × V, F f := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun f _ _ => hF f) _ ≤ _ := by apply bad_residual_sum_le weight rate (fun z : H × V => lines z.1) t R denom b mass hd hb hm (fun u => hmass u.1) K J h (N₁ * Fintype.card V) (N₂ * Fintype.card V) hK hh low hsize herr · intro d exact (labelled_filter_card (V := V) (H := H) (fun u => d ∈ lines u)).le.trans (Nat.mul_le_mul_right _ (hN₁ d)) · intro d e hde exact (labelled_filter_card (V := V) (H := H) (fun u => d ∈ lines u ∧ e ∈ lines u)).le.trans (Nat.mul_le_mul_right _ (hN₂ d e hde))
end SharpRamseyFive.SelectionBridge
namespace SharpRamseyFive.ResidualEliminationopen scoped BigOperatorsopen Classicalvariable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
def Agrees (E : Finset V) (g f : V → H) : Prop := ∀ v ∉ E, f v = g v
noncomputable def completionSum (E : Finset V) (g : V → H) (F : (V → H) → ℝ) : ℝ := ∑ f : V → H, if Agrees E g f then F f else 0
omit [DecidableEq H] inlemma completionSum_nonneg (E : Finset V) (g : V → H) (F : (V → H) → ℝ) (hF : ∀ f, 0 ≤ F f) : 0 ≤ completionSum E g F := by apply Finset.sum_nonneg intro f _ split_ifs · exact hF f · exact le_rfl
omit [DecidableEq H] inlemma completionSum_mono (E : Finset V) (g : V → H) (F G : (V → H) → ℝ) (h : ∀ f, Agrees E g f → F f ≤ G f) : completionSum E g F ≤ completionSum E g G := by apply Finset.sum_le_sum intro f _ split_ifs with hf · exact h f hf · exact le_rflomit [DecidableEq H] in
lemma completionSum_congr (E : Finset V) (g : V → H) (F G : (V → H) → ℝ) (h : ∀ f, Agrees E g f → F f = G f) : completionSum E g F = completionSum E g G := by apply le_antisymm <;> apply completionSum_mono · exact fun f hf => le_of_eq (h f hf) · exact fun f hf => le_of_eq (h f hf).symm
omit [DecidableEq H] inlemma completionSum_mul (E : Finset V) (g : V → H) (c : ℝ) (F : (V → H) → ℝ) : completionSum E g (fun f => c * F f) = c * completionSum E g F := by simp only [completionSum, Finset.mul_sum, mul_ite, mul_zero]
omit [DecidableEq H] inlemma completionSum_sum {ι : Type} (T : Finset ι) (E : Finset V) (g : V → H) (F : ι → (V → H) → ℝ) : completionSum E g (fun f => ∑ i ∈ T, F i f) = ∑ i ∈ T, completionSum E g (F i) := by unfold completionSum rw [Finset.sum_comm] apply Finset.sum_congr rfl intro f _ by_cases h : Agrees E g f <;> simp [h]
omit [Fintype V] [Fintype H] [DecidableEq H] inlemma agrees_erase_iff (E : Finset V) (g f : V → H) {u : V} (hu : u ∈ E) (x : H) : Agrees (E.erase u) (Function.update g u x) f ↔ Agrees E g f ∧ f u = x := by constructor · intro h constructor · intro v hv have hvu : v ≠ u := by intro he; exact hv (he ▸ hu) simpa only [Function.update_of_ne hvu] using h v (by simp [hv]) · simpa using h u (Finset.notMem_erase u E) · rintro ⟨h, hx⟩ v hv by_cases hvu : v = u · subst v; simpa using hx · rw [Function.update_of_ne hvu] exact h v (by simpa [hvu] using hv)
lemma completionSum_expose (E : Finset V) (g : V → H) {u : V} (hu : u ∈ E) (F : (V → H) → ℝ) : completionSum E g F = ∑ x : H, completionSum (E.erase u) (Function.update g u x) F := by unfold completionSum rw [Finset.sum_comm] apply Finset.sum_congr rfl intro f _ simp only [agrees_erase_iff E g f hu] by_cases h : Agrees E g f · simp [h, eq_comm] · simp [h]
lemma completionSum_empty (g : V → H) (F : (V → H) → ℝ) : completionSum ∅ g F = F g := by have he (f : V → H) : Agrees ∅ g f ↔ f = g := by constructor · intro h funext v exact h v (Finset.notMem_empty v) · rintro rfl v _ rfl simp [completionSum, he]
noncomputable def term (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (E S : Finset V) (f : V → H) : ℝ := (∏ u ∈ S, a u f) * B (E \ S) f
omit [Fintype V] [Fintype H] [DecidableEq H] inlemma term_nonneg (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (ha : ∀ u f, 0 ≤ a u f) (hB : ∀ A f, 0 ≤ B A f) (E S : Finset V) (f : V → H) : 0 ≤ term a B E S f := mul_nonneg (Finset.prod_nonneg (fun u _ => ha u f)) (hB _ f)
omit [Fintype V] inlemma prod_erase_le (a : V → ℝ) (ha : ∀ u, a u ∈ Set.Icc (0 : ℝ) 1) (S : Finset V) (v : V) : (∏ u ∈ S, a u) ≤ ∏ u ∈ S.erase v, a u := by by_cases hv : v ∈ S · rw [← Finset.mul_prod_erase S a hv] exact mul_le_of_le_one_left (Finset.prod_nonneg (fun u _ => (ha u).1)) (ha v).2 · rw [Finset.erase_eq_of_notMem hv]
omit [Fintype V] inlemma erase_sdiff (E S : Finset V) (u _v : V) (hu : u ∈ S) : E.erase u \ S.erase u = E \ S := by ext w by_cases hw : w = u <;> simp [hw, hu]
omit [Fintype V] inlemma double_erase_sdiff (E S : Finset V) (u v : V) (hu : u ∈ S) : (E.erase u).erase v \ (S.erase u).erase v = (E \ S).erase v := by ext w by_cases hwu : w = u <;> by_cases hwv : w = v <;> simp [hwu, hwv, hu]
omit [Fintype H] [DecidableEq H] inlemma term_shift_step (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (W : H → H → ℝ) (ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1) (hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f) (hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f) (hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v)) (E S : Finset V) {u : V} (hu : u ∈ S) (f : V → H) : term a B E S f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f := by have hp : 0 ≤ (∏ w ∈ S.erase u, a w f) * B (E \ S) f := mul_nonneg (Finset.prod_nonneg (fun w _ => (ha w f).1)) (hB _ f) calc term a B E S f = a u f * ((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := by rw [term, ← Finset.mul_prod_erase S (fun w => a w f) hu, mul_assoc] _ ≤ (∑ v ∈ Finset.univ.erase u, W (f u) (f v)) * ((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := mul_le_mul_of_nonneg_right (hshift u f) hp _ = ∑ v ∈ Finset.univ.erase u, W (f u) (f v) * ((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := by rw [Finset.sum_mul] _ ≤ _ := by apply Finset.sum_le_sum intro v hv apply mul_le_mul_of_nonneg_left _ (hW _ _) unfold term rw [double_erase_sdiff E S u v hu] apply mul_le_mul (prod_erase_le (fun w => a w f) (fun w => ha w f) _ v) (hmono _ _ (Finset.erase_subset v _) f) (hB _ f) exact Finset.prod_nonneg (fun w _ => (ha w f).1)
lemma sum_known_partner (E : Finset V) (g : V → H) {u v : V} (hu : u ∈ E) (hv : v ∉ E) (W : H → H → ℝ) (F : (V → H) → ℝ) (X C : ℝ) (hW : ∀ x y, 0 ≤ W x y) (hX : 0 ≤ X) (hrow : ∑ x : H, W x (g v) ≤ C) (hF : ∀ x : H, completionSum (E.erase u) (Function.update g u x) F ≤ X) : completionSum E g (fun f => W (f u) (f v) * F f) ≤ C * X := by rw [completionSum_expose E g hu] calc _ ≤ ∑ x : H, W x (g v) * X := by apply Finset.sum_le_sum intro x _ have he : completionSum (E.erase u) (Function.update g u x) (fun f => W (f u) (f v) * F f) = W x (g v) * completionSum (E.erase u) (Function.update g u x) F := by rw [← completionSum_mul] apply completionSum_congr intro f hf have hfu : f u = x := by simpa using hf u (Finset.notMem_erase u E) have hvu : v ≠ u := by intro he; exact hv (he ▸ hu) have hfv : f v = g v := by simpa only [Function.update_of_ne hvu] using hf v (by simp [hv]) rw [hfu, hfv] rw [he] exact mul_le_mul_of_nonneg_left (hF x) (hW _ _) _ = (∑ x : H, W x (g v)) * X := by rw [Finset.sum_mul] _ ≤ _ := mul_le_mul_of_nonneg_right hrow hX
lemma sum_new_partner (E : Finset V) (g : V → H) {u v : V} (hu : u ∈ E) (hv : v ∈ E) (hne : v ≠ u) (W : H → H → ℝ) (F : (V → H) → ℝ) (X C : ℝ) (hW : ∀ x y, 0 ≤ W x y) (hX : 0 ≤ X) (hpair : (∑ x : H, ∑ y : H, W x y) ≤ C) (hF : ∀ x y : H, completionSum ((E.erase u).erase v) (Function.update (Function.update g u x) v y) F ≤ X) : completionSum E g (fun f => W (f u) (f v) * F f) ≤ C * X := by rw [completionSum_expose E g hu] have hv' : v ∈ E.erase u := Finset.mem_erase.mpr ⟨hne,hv⟩ calc _ ≤ ∑ x : H, ∑ y : H, W x y * X := by apply Finset.sum_le_sum intro x _ rw [completionSum_expose _ _ hv'] apply Finset.sum_le_sum intro y _ have he : completionSum ((E.erase u).erase v) (Function.update (Function.update g u x) v y) (fun f => W (f u) (f v) * F f) = W x y * completionSum ((E.erase u).erase v) (Function.update (Function.update g u x) v y) F := by rw [← completionSum_mul] apply completionSum_congr intro f hf have hfu : f u = x := by simpa only [Function.update_of_ne hne.symm, Function.update_self] using hf u (by simp) have hfv : f v = y := by simpa using hf v (by simp) rw [hfu, hfv] rw [he] exact mul_le_mul_of_nonneg_left (hF x y) (hW _ _) _ = (∑ x : H, ∑ y : H, W x y) * X := by simp only [Finset.sum_mul] _ ≤ _ := mul_le_mul_of_nonneg_right hpair hX
theorem shift_bad_enumeration (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (W : H → H → ℝ) (C : ℝ) (hC : 0 ≤ C) (ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1) (hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f) (hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f) (hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v)) (hrow : ∀ y, (∑ x : H, W x y) ≤ C) (hpair : (∑ x : H, ∑ y : H, W x y) ≤ C ^ 2) (hbad : ∀ A g, completionSum A g (B A) ≤ C ^ A.card) (E S : Finset V) (hS : S ⊆ E) (g : V → H) : completionSum E g (term a B E S) ≤ ((Fintype.card V + 1 : ℝ) * C) ^ E.card := by let M : ℝ := (Fintype.card V + 1) * C have hCM : C ≤ M := by dsimp [M]; nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card V)] have hM : 0 ≤ M := hC.trans hCM suffices hall : ∀ E : Finset V, ∀ S, S ⊆ E → ∀ g : V → H, completionSum E g (term a B E S) ≤ M ^ E.card from hall E S hS g intro E refine Finset.strongInductionOn E ?_ intro E ih S hS g by_cases hs : S = ∅ · subst S have he : term a B E ∅ = B E := by funext f simp [term] rw [he] exact (hbad E g).trans (pow_le_pow_left₀ hC hCM _) obtain ⟨u,hu⟩ := Finset.nonempty_iff_ne_empty.mpr hs have huE := hS hu have hsub := Finset.erase_ssubset huE have hS' : S.erase u ⊆ E.erase u := Finset.erase_subset_erase u hS have hcard : E.card = (E.erase u).card + 1 := (Finset.card_erase_add_one huE).symm calc _ ≤ completionSum E g (fun f => ∑ v ∈ Finset.univ.erase u, W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f) := by apply completionSum_mono intro f _ exact term_shift_step a B W ha hW hB hmono hshift E S hu f _ = ∑ v ∈ Finset.univ.erase u, completionSum E g (fun f => W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f) := completionSum_sum _ E g _ _ ≤ ∑ _v ∈ Finset.univ.erase u, C * M ^ (E.erase u).card := by apply Finset.sum_le_sum intro v hv have hne : v ≠ u := (Finset.mem_erase.mp hv).1 by_cases hvE : v ∈ E · have hv' : v ∈ E.erase u := Finset.mem_erase.mpr ⟨hne,hvE⟩ have hsmall : (E.erase u).erase v ⊂ E := Finset.ssubset_of_subset_of_ssubset (Finset.erase_subset _ _) hsub have hSt : (S.erase u).erase v ⊆ (E.erase u).erase v := Finset.erase_subset_erase v hS' have hbnd := sum_new_partner E g huE hvE hne W (term a B ((E.erase u).erase v) ((S.erase u).erase v)) (M ^ ((E.erase u).erase v).card) (C ^ 2) hW (pow_nonneg hM _) hpair (fun x y => ih _ hsmall _ hSt _) apply hbnd.trans rw [show (E.erase u).card = ((E.erase u).erase v).card + 1 from (Finset.card_erase_add_one hv').symm, pow_succ M] calc _ = (C * C) * M ^ ((E.erase u).erase v).card := by ring _ ≤ (C * M) * M ^ ((E.erase u).erase v).card := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hCM hC) (pow_nonneg hM _) _ = _ := by ring · have hvS : v ∉ S := fun h => hvE (hS h) rw [Finset.erase_eq_of_notMem (fun h => hvE (Finset.erase_subset u E h)), Finset.erase_eq_of_notMem (fun h => hvS (Finset.erase_subset u S h))] exact sum_known_partner E g huE hvE W (term a B (E.erase u) (S.erase u)) (M ^ (E.erase u).card) C hW (pow_nonneg hM _) (hrow (g v)) (fun x => ih _ hsub _ hS' _) _ ≤ M * M ^ (E.erase u).card := by simp only [Finset.sum_const, nsmul_eq_mul] rw [← mul_assoc] apply mul_le_mul_of_nonneg_right _ (pow_nonneg hM _) change ((Finset.univ.erase u).card : ℝ) * C ≤ M have hc : ((Finset.univ.erase u).card : ℝ) ≤ (Fintype.card V : ℝ) := by exact_mod_cast Finset.card_le_card (Finset.erase_subset u (Finset.univ : Finset V)) dsimp [M] nlinarith _ = _ := by rw [hcard, pow_succ]; ring
end SharpRamseyFive.ResidualElimination
namespace SharpRamseyFive.SingletonEnumerationopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignationsopen SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedProgramsopen SharpRamseyFive.ResidualEliminationopen Classicalvariable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]omit [DecidableEq V] in
lemma vertexBadMass_antitone (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (R J : ℕ) {A A' : Finset V} (hA : A' ⊆ A) : vertexBadMass weight rate s t R J A ≤ vertexBadMass weight rate s t R J A' := by unfold vertexBadMass badMass apply integral_mono (badTerm_integrable _ _ (blockTrunc_range _ R J none) _ A) (badTerm_integrable _ _ (blockTrunc_range _ R J none) _ A') intro z apply mul_le_mul_of_nonneg_left _ (blockTrunc_range _ R J none z).1 exact Finset.prod_le_prod_of_subset_of_le_one₀ hA (fun v _ => (badIndicator_range _ v z).1) (fun v _ _ => (badIndicator_range _ v z).2)
lemma sum_powers_le (x : ℝ) (hx : 0 ≤ x) (n : ℕ) : (∑ i ∈ Finset.range (n + 1), x ^ i) ≤ (1 + x) ^ n := by induction n with | zero => simp | succ n ih => rw [Finset.sum_range_succ] calc _ ≤ (1 + x) ^ n + x ^ (n + 1) := add_le_add ih le_rfl _ ≤ (1 + x) ^ n + x * (1 + x) ^ n := by rw [pow_succ'] exact add_le_add le_rfl (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hx (by linarith : x ≤ 1 + x) n) hx) _ = _ := by rw [pow_succ]; ring
lemma actual_bad_completion (weight rate : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) (R : ℕ) (denom b mass : ℝ) (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) (A : Finset V) (g : V → H) : completionSum A g (fun f => vertexBadMass weight rate (lines ∘ f) t R J A) ≤ (denom * (1 + branchingBound (V := V) (B := Fin R) (fun z : H × V => lines z.1) rate denom b mass K (N₁ * Fintype.card V) (N₂ * Fintype.card V) low)) ^ A.card := by have he : completionSum A g (fun f => vertexBadMass weight rate (lines ∘ f) t R J A) = ∑ f : V → H, if (∀ v ∉ A, g v = f v) then vertexBadMass weight rate (lines ∘ f) t R J A else 0 := by unfold completionSum apply Finset.sum_congr rfl intro f _ have : Agrees A g f ↔ (∀ v ∉ A, g v = f v) := by simp only [Agrees, eq_comm] simp only [this] rw [he] apply (all_bad_residual_sum_le weight rate lines t R denom b mass hd hb hm hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ A g).trans rw [mul_pow] apply mul_le_mul_of_nonneg_left _ (pow_nonneg hd.le _) rw [Fin.sum_univ_eq_sum_range] apply sum_powers_le exact branchingBound_nonneg _ _ _ _ _ hd.le (by linarith) hm _ _ _ _
noncomputable def shiftKernel (weight : D → ℝ≥0) (lines : H → Finset D) (p K : ℕ) (x y : H) : ℝ := min 1 (((p : ℝ) * mass weight (lines x ∩ lines y)) ^ K)
omit [Fintype H] [DecidableEq H] inomit [Fintype D] inlemma shiftKernel_range (weight : D → ℝ≥0) (lines : H → Finset D) (p K : ℕ) (x y : H) : shiftKernel weight lines p K x y ∈ Set.Icc (0 : ℝ) 1 := by unfold shiftKernel exact ⟨le_min zero_le_one (pow_nonneg (mul_nonneg (Nat.cast_nonneg _) (mass_nonneg _ _)) _), min_le_left _ _⟩
end SharpRamseyFive.SingletonEnumerationend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.SinglesUnique
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen scoped BigOperatorsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators ENNReal NNRealnamespace SharpRamseyFive.AmbientEnumerationopen scoped BigOperators NNRealopen Classicalopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartitionopen SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualEliminationopen SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridgevariable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]omit [Fintype D] inlemma large_card (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : Fintype.card (Components weight s t) - (simpleSet weight s t).card = (largeLabels (componentMap (strongGraph weight s t))).card := by rw [← large_image, Finset.card_image_of_injective _ (vertex_injective weight s t), Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ]
end SharpRamseyFive.AmbientEnumeration
namespace SharpRamseyFive.AmbientEnumerationopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen Classicalopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartitionopen SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualEliminationopen SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridgeopen SharpRamseyFive.WeightedProgramsvariable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
noncomputable def vertexExpansion (weight : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (E : Finset V) (f : V → H) : ℝ := badExpansion (fun u f => independentWeight weight (fun d => L * weight d) lines R J base (f u) + alpha weight (lines ∘ f) t u ^ K) (fun A f => vertexBadMass weight (fun d => L * weight d) (lines ∘ f) t R J A) E fomit [Fintype H] [DecidableEq H] in
lemma vertexExpansion_nonneg (weight : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (E : Finset V) (f : V → H) : 0 ≤ vertexExpansion weight lines t R J K L base E f := by apply Finset.sum_nonneg intro U _ apply mul_nonneg · apply Finset.prod_nonneg intro u _ exact add_nonneg (independentWeight_nonneg _ _ _ _ _ _ _) (pow_nonneg (alpha_nonneg _ _ _ _) _) · exact vertexBadMass_nonneg _ _ _ _ _ _ _omit [Fintype H] [DecidableEq H] in
lemma designated_le_partition (weight : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (f : V → H) : designatedBound weight (lines ∘ f) t R J K L base ≤ Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) ^ (largeLabels (componentMap (strongGraph weight (lines ∘ f) t))).card * (Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) ^ (singles (componentMap (strongGraph weight (lines ∘ f) t))).card * vertexExpansion weight lines t R J K L base (singles (componentMap (strongGraph weight (lines ∘ f) t))) f) := by have ht := mul_le_mul_of_nonneg_left (designation_sum_le_vertex weight lines f t R J K L base) (show 0 ≤ Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) ^ (simpleSet weight (lines ∘ f) t).card * Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) ^ (Fintype.card (Components weight (lines ∘ f) t) - (simpleSet weight (lines ∘ f) t).card) by positivity) change designatedBound weight (lines ∘ f) t R J K L base ≤ _ at ht rw [large_card, simple_card, simple_image] at ht exact ht.trans_eq (by unfold vertexExpansion; ring)
theorem designation_sum_enumerated (weight : D → ℝ≥0) (lines : H → Finset D) {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) (R : ℕ) (L : ℝ≥0) (denom rootB mass C D₀ base A : ℝ) (hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C) (hD : 0 ≤ D₀) (hA : 0 ≤ A) (hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) (hBC : denom * (1 + branchingBound (V := V) (B := Fin R) (fun z : H × V => lines z.1) (fun d => L * weight d) denom rootB mass K (N₁ * Fintype.card V) (N₂ * Fintype.card V) low) ≤ C) (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) (hDsum : (∑ x : H, independentWeight weight (fun d => L * weight d) lines R J base x) ≤ D₀) (hsingle : Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) * (D₀ + 2 * ((Fintype.card V + 1 : ℝ) * C)) ≤ A) (Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ) (hnum : ∀ m : ℕ, 2 ≤ m → m ≤ Fintype.card V → Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) * ((m : ℝ) ^ 2 * Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) * ((m : ℝ) ^ 2 * Δ) ^ (m - 2)) ≤ A ^ m) : (∑ f : V → H, designatedBound weight (lines ∘ f) (1 / (100 * p)) R J K L base) ≤ (Fintype.card V : ℝ) ^ Fintype.card V * A ^ Fintype.card V := by let t : ℝ := 1 / (100 * p) let a := Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) let b := Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) let F (E : Finset V) (f : V → H) := a ^ E.card * vertexExpansion weight lines t R J K L base E f have hres (r : V → V) (g : V → H) : completionSum (singles r) g (F (singles r)) ≤ A ^ (singles r).card := by change completionSum (singles r) g (fun f => a ^ (singles r).card * vertexExpansion weight lines t R J K L base (singles r) f) ≤ _ rw [completionSum_mul] apply (mul_le_mul_of_nonneg_left (actual_all_singleton_enumeration weight (fun d => L * weight d) lines hp hc R denom rootB mass C D₀ base hd hb hm hC hD hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ hBC hrow hpair hDsum (singles r) g) (show 0 ≤ a ^ (singles r).card by dsimp [a]; positivity)).trans rw [← mul_pow] exact pow_le_pow_left₀ (by positivity) hsingle _ apply (Finset.sum_le_sum (fun f _ => designated_le_partition weight lines t R J K L base f)).trans have ht := graph_partition_sum (V := V) (overlapRelation weight lines t) (overlapRelation_symm weight lines t) b A (Real.exp_pos _).le hA Δ hΔ hnum F (fun E f => mul_nonneg (pow_nonneg (Real.exp_pos _).le _) (vertexExpansion_nonneg _ _ _ _ _ _ _ _ _ _)) hres simpa only [relation_graph_eq] using ht
end SharpRamseyFive.AmbientEnumeration
namespace SharpRamseyFive.MomentBudgetsopen scoped BigOperators
lemma block_cost (P B E Δ : ℝ) (p m : ℕ) (hP : 0 ≤ P) (hB : 0 ≤ B) (hE : 0 ≤ E) (hΔ : 0 ≤ Δ) (hm : 2 ≤ m) (hmp : m ≤ p) (hp : (p : ℝ) ^ 2 ≤ Real.exp (P / 10)) (hpair : E ≤ B ^ 2 * Real.exp (P / 10)) (hdeg : Δ ≤ B * Real.exp (-P)) : Real.exp (-(7 / 10 : ℝ) * P) * ((m : ℝ) ^ 2 * E * ((m : ℝ) ^ 2 * Δ) ^ (m - 2)) ≤ (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ m := by let A := B * Real.exp (-(1 / 5 : ℝ) * P) have hA : 0 ≤ A := mul_nonneg hB (Real.exp_pos _).le have hm2 : (m : ℝ) ^ 2 ≤ Real.exp (P / 10) := by apply (pow_le_pow_left₀ (by positivity) (show (m : ℝ) ≤ p by exact_mod_cast hmp) 2).trans hp have hfirst : Real.exp (-(7 / 10 : ℝ) * P) * ((m : ℝ) ^ 2 * E) ≤ A ^ 2 := by calc _ ≤ Real.exp (-(7 / 10 : ℝ) * P) * (Real.exp (P / 10) * (B ^ 2 * Real.exp (P / 10))) := by exact mul_le_mul_of_nonneg_left (mul_le_mul hm2 hpair hE (Real.exp_pos _).le) (Real.exp_pos _).le _ = B ^ 2 * Real.exp (-(1 / 2 : ℝ) * P) := by rw [show Real.exp (-(7 / 10 : ℝ) * P) * (Real.exp (P / 10) * (B ^ 2 * Real.exp (P / 10))) = B ^ 2 * (Real.exp (-(7 / 10 : ℝ) * P) * Real.exp (P / 10) * Real.exp (P / 10)) by ring] rw [← Real.exp_add, ← Real.exp_add] congr 2 ring _ ≤ B ^ 2 * Real.exp (-(2 / 5 : ℝ) * P) := by exact mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) (sq_nonneg B) _ = A ^ 2 := by dsimp [A] rw [mul_pow, ← Real.exp_nat_mul] congr 2 ring have hstep : (m : ℝ) ^ 2 * Δ ≤ A := by calc _ ≤ Real.exp (P / 10) * (B * Real.exp (-P)) := mul_le_mul hm2 hdeg hΔ (Real.exp_pos _).le _ = B * Real.exp (-(9 / 10 : ℝ) * P) := by rw [show Real.exp (P / 10) * (B * Real.exp (-P)) = B * (Real.exp (P / 10) * Real.exp (-P)) by ring, ← Real.exp_add] congr 2 ring _ ≤ A := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) hB calc _ = (Real.exp (-(7 / 10 : ℝ) * P) * ((m : ℝ) ^ 2 * E)) * ((m : ℝ) ^ 2 * Δ) ^ (m - 2) := by ring _ ≤ A ^ 2 * A ^ (m - 2) := mul_le_mul hfirst (pow_le_pow_left₀ (mul_nonneg (sq_nonneg _) hΔ) hstep _) (by positivity) (pow_nonneg hA _) _ = A ^ m := by rw [← pow_add, Nat.add_sub_of_le hm]
lemma singleton_cost (P B M : ℝ) (hP : 0 ≤ P) (hB : 0 ≤ B) (hM : M ≤ B * Real.exp (P / 5)) : Real.exp (-(17 / 25 : ℝ) * P) * M ≤ B * Real.exp (-(1 / 5 : ℝ) * P) := by calc _ ≤ Real.exp (-(17 / 25 : ℝ) * P) * (B * Real.exp (P / 5)) := mul_le_mul_of_nonneg_left hM (Real.exp_pos _).le _ = B * Real.exp (-(12 / 25 : ℝ) * P) := by rw [show Real.exp (-(17 / 25 : ℝ) * P) * (B * Real.exp (P / 5)) = B * (Real.exp (-(17 / 25 : ℝ) * P) * Real.exp (P / 5)) by ring, ← Real.exp_add] congr 2 ring _ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) hB
lemma partition_cost (P B : ℝ) (p : ℕ) (hB : 0 ≤ B) (hp : (p : ℝ) ≤ Real.exp (P / 10)) : (p : ℝ) ^ p * (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ p ≤ B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * P)) := by calc _ ≤ Real.exp (P / 10) ^ p * (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ p := mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by positivity) hp _) (by positivity) _ = _ := by rw [← mul_pow, show Real.exp (P / 10) * (B * Real.exp (-(1 / 5 : ℝ) * P)) = B * (Real.exp (P / 10) * Real.exp (-(1 / 5 : ℝ) * P)) by ring, ← Real.exp_add, mul_pow, ← Real.exp_nat_mul] congr 2 ring
end SharpRamseyFive.MomentBudgets
namespace SharpRamseyFive.AmbientEnumerationopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen Classicalopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartitionopen SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualEliminationopen SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridgeopen SharpRamseyFive.WeightedProgramsvariable {D H : Type} [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H]
theorem ambient_refined_truncated_moment (weight : D → ℝ≥0) (lines : H → Finset D) {p : ℕ} (hp : 0 < p) (R : ℕ) (own : H → Fin R → Bool) (L : ℝ≥0) (denom rootB mass C D₀ base B : ℝ) (hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base) (hlower : ∀ k, (3 / 4 : ℝ) ≤ PoissonScore.mass weight (lines k)) (hdelta : ∀ k, |PoissonScore.mass weight (lines k) - base| ≤ (17 / 100 : ℝ)) (hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C) (hD : 0 ≤ D₀) (hB : 0 ≤ B) (hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hKR : K ≤ R / 2) (hh : 0 < h) (low : Bool) (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) (herr : (p : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) (hBC : denom * (1 + branchingBound (V := Fin p) (B := Fin R) (fun z : H × Fin p => lines z.1) (fun d => L * weight d) denom rootB mass K (N₁ * p) (N₂ * p) low) ≤ C) (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) (hDsum : (∑ x : H, independentWeight weight (fun d => L * weight d) lines R J base x) ≤ D₀) (hcost : D₀ + 2 * ((p + 1 : ℝ) * C) ≤ B * Real.exp (((L : ℝ) * R) / 5)) (hp2 : (p : ℝ) ^ 2 ≤ Real.exp (((L : ℝ) * R) / 10)) (Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ) (hdeg : (Δ : ℝ) ≤ B * Real.exp (-((L : ℝ) * R))) (hRelPairs : (Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) : ℝ) ≤ B ^ 2 * Real.exp (((L : ℝ) * R) / 10)) : (∫ ω, HighMoment.allTrunc R J ω * (∑ k : H, scoreTerm (lines k) (Real.exp (-(L : ℝ) * base)) (own k) (fun r d => ω (r,d))) ^ p ∂batchMeasure (fun i : Fin R × D => L * weight i.2)) ≤ B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * ((L : ℝ) * R))) := by have hP : 0 ≤ (L : ℝ) * R := by positivity apply (truncated_power_designated weight R J K L base lines own hp hL hbase hlower hdelta hKR).trans have hs := designation_sum_enumerated (V := Fin p) weight lines hp (by simp) R L denom rootB mass C D₀ base (B * Real.exp (-(1 / 5 : ℝ) * ((L : ℝ) * R))) hd hb hm hC hD (by positivity) hmass K J h N₁ N₂ hK hh low hsize (by simpa only [Fintype.card_fin] using herr) hN₁ hN₂ (by simpa only [Fintype.card_fin] using hBC) hrow hpair hDsum (by simpa only [Fintype.card_fin] using MomentBudgets.singleton_cost _ B _ hP hB hcost) Δ hΔ (fun m hm hmp => MomentBudgets.block_cost _ B _ _ p m hP hB (by positivity) (by positivity) hm (by simpa only [Fintype.card_fin] using hmp) hp2 hRelPairs hdeg) apply hs.trans simp only [Fintype.card_fin] apply MomentBudgets.partition_cost _ B p hB have hpr : (1 : ℝ) ≤ p := by exact_mod_cast hp exact (show (p : ℝ) ≤ (p : ℝ) ^ 2 by nlinarith).trans hp2
omit [DecidableEq D] in
lemma allTrunc_eq_one {R J : ℕ} (h : R < J) (ω : Fin R × D → ℕ) : HighMoment.allTrunc R J ω = 1 := by apply Finset.prod_eq_one intro d _ unfold lineTrunc apply ite_eq_left exact (show (Finset.univ.filter (fun r => ω (r,d) ≠ 0)).card ≤ R by simpa only [Finset.card_univ, Fintype.card_fin] using Finset.card_le_card (Finset.filter_subset (fun r : Fin R => ω (r,d) ≠ 0) Finset.univ)).trans_lt h
theorem ambient_untruncated_moment (weight : D → ℝ≥0) (lines : H → Finset D) {p : ℕ} (hp : 0 < p) (R : ℕ) (own : H → Fin R → Bool) (L : ℝ≥0) (denom rootB mass C D₀ base B : ℝ) (hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base) (hlower : ∀ k, (3 / 4 : ℝ) ≤ PoissonScore.mass weight (lines k)) (hdelta : ∀ k, |PoissonScore.mass weight (lines k) - base| ≤ (17 / 100 : ℝ)) (hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C) (hD : 0 ≤ D₀) (hB : 0 ≤ B) (hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass) (K h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hKR : K ≤ R / 2) (hh : 0 < h) (hsize : h ≤ (R / 2) / (2 * K)) (herr : (p : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) (hBC : denom * (1 + branchingBound (V := Fin p) (B := Fin R) (fun z : H × Fin p => lines z.1) (fun d => L * weight d) denom rootB mass K (N₁ * p) (N₂ * p) true) ≤ C) (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) (hDsum : (∑ x : H, |PoissonScore.mass weight (lines x) - base| ^ (R / 2)) ≤ D₀) (hcost : D₀ + 2 * ((p + 1 : ℝ) * C) ≤ B * Real.exp (((L : ℝ) * R) / 5)) (hp2 : (p : ℝ) ^ 2 ≤ Real.exp (((L : ℝ) * R) / 10)) (Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ) (hdeg : (Δ : ℝ) ≤ B * Real.exp (-((L : ℝ) * R))) (hRelPairs : (Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) : ℝ) ≤ B ^ 2 * Real.exp (((L : ℝ) * R) / 10)) : (∫ ω, (∑ k : H, scoreTerm (lines k) (Real.exp (-(L : ℝ) * base)) (own k) (fun r d => ω (r,d))) ^ p ∂batchMeasure (fun i : Fin R × D => L * weight i.2)) ≤ B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * ((L : ℝ) * R))) := by have hs := ambient_refined_truncated_moment weight lines hp R own L denom rootB mass C D₀ base B hL hbase hlower hdelta hd hb hm hC hD hB hmass K (R+1) h N₁ N₂ hK hKR hh true (by simpa using hsize) herr hN₁ hN₂ hBC hrow hpair (by simpa only [independentWeight, Nat.lt_succ_self, ite_true, add_zero] using hDsum) hcost hp2 Δ hΔ hdeg hRelPairs simpa only [allTrunc_eq_one (Nat.lt_succ_self R), one_mul] using hs
end SharpRamseyFive.AmbientEnumeration
namespace SharpLogRamsey.MomentBudgetBridge
def anchorBudget (p : ℕ) (P : ℝ) : ℝ := 200 * (p : ℝ) + 2 * P
def certificateOverhead (p D : ℕ) (P : ℝ) : ℝ := 1 + 4 * (p : ℝ)^2 + 4 * (p : ℝ)^3 * anchorBudget p P + (p : ℝ)^4 * (anchorBudget p P)^2 + (p : ℝ)^4 * ((D : ℝ)+4) * (2*P)^200
lemma anchorBudget_nonneg (p : ℕ) {P : ℝ} (hP : 0 ≤ P) : 0 ≤ anchorBudget p P := by unfold anchorBudget positivity
lemma certificateOverhead_nonneg (p D : ℕ) {P : ℝ} (hP : 0 ≤ P) : 0 ≤ certificateOverhead p D P := by have hA := anchorBudget_nonneg p hP unfold certificateOverhead positivity
theorem labelled_branching_bound (p D : ℕ) (P B H N M : ℝ) (hP : 0 ≤ P) (hB : 1 ≤ B) (hH : H ≤ 4*B^2) (hN : N ≤ 4*B) (hM : M ≤ (p : ℝ)^2 * (B^2 * Real.exp (P/50) * ((D : ℝ)+4) * (2*P)^200)) : 1 + (((p : ℝ)*(H*p)/B)/B^8 + (p : ℝ)^2*(N*p)*anchorBudget p P/B + ((p : ℝ)^3*p*(anchorBudget p P)^2/B)*B + (p : ℝ)^2*M/B^2) ≤ Real.exp (P/50)*certificateOverhead p D P := by have hB0 : 0 < B := lt_of_lt_of_le zero_lt_one hB have hp : (0 : ℝ) ≤ p := Nat.cast_nonneg p have hA := anchorBudget_nonneg p hP have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity) have hroot : ((p : ℝ)*(H*p)/B)/B^8 ≤ 4*(p : ℝ)^2 := by apply (div_le_iff₀ (pow_pos hB0 8)).mpr apply (div_le_iff₀ hB0).mpr have hpow : B^2 ≤ B^9 := pow_le_pow_right₀ hB (by decide) calc (p : ℝ)*(H*p) ≤ (p : ℝ)*(4*B^2*p) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hH hp) hp _ = 4*(p : ℝ)^2*B^2 := by ring _ ≤ 4*(p : ℝ)^2*B^9 := mul_le_mul_of_nonneg_left hpow (by positivity) _ = 4*(p : ℝ)^2*B^8*B := by ring have hanchor : (p : ℝ)^2*(N*p)*anchorBudget p P/B ≤ 4*(p : ℝ)^3*anchorBudget p P := by apply (div_le_iff₀ hB0).mpr calc _ ≤ (p : ℝ)^2*(4*B*p)*anchorBudget p P := by exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hN hp) (by positivity)) hA _ = _ := by ring have htwo : ((p : ℝ)^3*p*(anchorBudget p P)^2/B)*B = (p : ℝ)^4*(anchorBudget p P)^2 := by rw [div_mul_cancel₀ _ hB0.ne'] ring have hpair : (p : ℝ)^2*M/B^2 ≤ Real.exp (P/50)*((p : ℝ)^4*((D : ℝ)+4)*(2*P)^200) := by apply (div_le_iff₀ (pow_pos hB0 2)).mpr calc _ ≤ (p : ℝ)^2*((p : ℝ)^2*(B^2*Real.exp (P/50)*((D : ℝ)+4)*(2*P)^200)) := mul_le_mul_of_nonneg_left hM (by positivity) _ = _ := by ring have hplain : 1 + 4*(p : ℝ)^2 + 4*(p : ℝ)^3*anchorBudget p P + (p : ℝ)^4*(anchorBudget p P)^2 ≤ Real.exp (P/50)*(1 + 4*(p : ℝ)^2 + 4*(p : ℝ)^3*anchorBudget p P + (p : ℝ)^4*(anchorBudget p P)^2) := by exact le_mul_of_one_le_left (by positivity) he unfold certificateOverhead rw [htwo] nlinarith only [hroot, hanchor, hpair, hplain]
theorem absorb_certificate (p D : ℕ) (P : ℝ) (h : certificateOverhead p D P ≤ Real.exp (2*P/25)) : Real.exp (P/50)*certificateOverhead p D P ≤ Real.exp (P/10) := by calc _ ≤ Real.exp (P/50)*Real.exp (2*P/25) := mul_le_mul_of_nonneg_left h (Real.exp_pos _).le _ = _ := by rw [← Real.exp_add]; congr 1; ring
theorem singleton_budget (p : ℕ) (B P : ℝ) (hB : 0 ≤ B) (hP : 0 ≤ P) (hp : 2*(p : ℝ)+3 ≤ Real.exp (P/10)) : B*Real.exp (P/100) + 2*((p+1 : ℝ)*(B*Real.exp (P/10))) ≤ B*Real.exp (P/5) := by have he : Real.exp (P/100) ≤ Real.exp (P/10) := Real.exp_le_exp.mpr (by linarith) calc _ ≤ B*Real.exp (P/10)+2*((p+1 : ℝ)*(B*Real.exp (P/10))) := by linarith only [mul_le_mul_of_nonneg_left he hB] _ = (B*Real.exp (P/10))*(2*(p : ℝ)+3) := by ring _ ≤ (B*Real.exp (P/10))*Real.exp (P/10) := mul_le_mul_of_nonneg_left hp (mul_nonneg hB (Real.exp_pos _).le) _ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring
def shiftOverhead (p D : ℕ) : ℝ := 4+(D : ℝ)*(200*(p : ℝ))^200
lemma shifted_dyadic_budget (p D : ℕ) (P C : ℝ) (hP : 0 ≤ P) (hC : 0 ≤ C) (hpoly : shiftOverhead p D ≤ Real.exp (2*P/25)) : 4*C+(D : ℝ)*C*Real.exp (P/50)*(2*(p : ℝ))^200 ≤ C*Real.exp (P/10) := by have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity) have hp : (2*(p : ℝ))^200 ≤ (200*(p : ℝ))^200 := pow_le_pow_left₀ (by positivity) (by have := (Nat.cast_nonneg p : (0 : ℝ) ≤ p); linarith) _ have heC : 4*C ≤ 4*C*Real.exp (P/50) := le_mul_of_one_le_right (by positivity) he have hpow := mul_le_mul_of_nonneg_left hp (show 0 ≤ (D : ℝ)*C*Real.exp (P/50) by positivity) calc _ ≤ C*Real.exp (P/50)*shiftOverhead p D := by unfold shiftOverhead nlinarith only [heC, hpow] _ ≤ C*Real.exp (P/50)*Real.exp (2*P/25) := mul_le_mul_of_nonneg_left hpoly (by positivity) _ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring
lemma strong_dyadic_budget (p D : ℕ) (P C : ℝ) (hP : 0 ≤ P) (hC : 0 ≤ C) (hpoly : shiftOverhead p D ≤ Real.exp (2*P/25)) : 4*C+(D : ℝ)*C*Real.exp (P/50)*(200*(p : ℝ))^200 ≤ C*Real.exp (P/10) := by have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity) have heC : 4*C ≤ 4*C*Real.exp (P/50) := le_mul_of_one_le_right (by positivity) he calc _ ≤ C*Real.exp (P/50)*shiftOverhead p D := by unfold shiftOverhead nlinarith only [heC] _ ≤ C*Real.exp (P/50)*Real.exp (2*P/25) := mul_le_mul_of_nonneg_left hpoly (by positivity) _ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring
end SharpLogRamsey.MomentBudgetBridgeend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.AnchorEventsRealized
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen scoped BigOperatorsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators ENNReal NNRealnamespace SharpRamseyFive.CertificateCoveropen SharpRamseyFive.StaticCertificatesopen SharpRamseyFive.CertificateEnumerationopen SharpRamseyFive.WeightedProgramsopen SharpRamseyFive.ResidualCertificateopen scoped BigOperatorsvariable {V H D B : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B]variable (lines : H → Finset D)omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] inlemma make_pair (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (v u : V) (hv : v ∉ E) (hu : u ∉ E) (hne : v ≠ u) (hp : K ≤ (sharedBatches (outsideDirections (fun v => lines (f v)) E) hit v u).card) : ∃ a : Action lines K s, Coherent lines f hit K (insert v (insert u E)) (advance lines K s a) ∧ (insert v (insert u E)).card = E.card + degree lines K s a ∧ Enabled lines K low s a ∧ actionCharge lines K s a = 0 := by classical obtain ⟨T, d, hT, hd, _, _, _, _⟩ := pair_step_witnesses (fun v => lines (f v)) hit E s.2 v u K hs.2.1 hs.2.2.1 hp have hmem (r : T) : d r ∈ PairDirections lines s (f v) (f u) := by apply Finset.mem_sdiff.mpr refine ⟨(hd r).1, ?_⟩ intro hc exact (hd r).2.1 (hs.2.1 hc) let c : PairChoice lines K s := ⟨v, u, f v, ⟨f u, fun he => hne (hf he.symm)⟩, ⟨T, Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, hT⟩⟩, fun r => ⟨d r, hmem r⟩⟩ let a : Action lines K s := .inr (.inr (.inr c)) have hv' : v ∉ insert u E := by simp [hne, hv] have hc : (insert v (insert u E)).card = E.card + degree lines K s a := by simp [a, degree, Finset.card_insert_of_notMem hv', Finset.card_insert_of_notMem hu, Nat.add_assoc] refine ⟨a, ?_, hc, ?_, rfl⟩ · apply coherent_step lines f hit K hK E (insert v (insert u E)) s hs a ((Finset.subset_insert _ _).trans (Finset.subset_insert _ _)) _ _ _ hc · have hu' := agrees_update f (insert v E) (Function.update s.1 v (f v), s.2) (agrees_update f E s hs.1 v s.2) u (advance lines K s a).2 simpa only [a, c, advance, newValues, Finset.insert_comm] using hu' · intro z hz obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, (Finset.mem_inter.mp (hd r).1).1⟩ · intro p hp obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp exact (hd r).2.2 · intro c' he simp [a] at heomit [Fintype V] [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma make_root (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (v : V) (hv : v ∉ E) : ∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧ (insert v E).card = E.card + degree lines K s a ∧ Enabled lines K low s a ∧ actionCharge lines K s a = -8 := by let a : Action lines K s := .inl (v, f v) have hc : (insert v E).card = E.card + degree lines K s a := by simp [a, degree, Finset.card_insert_of_notMem hv] refine ⟨a, ?_, hc, ?_, rfl⟩ · apply coherent_step lines f hit K hK E (insert v E) s hs a (Finset.subset_insert _ _) (agrees_update f E s hs.1 v _) _ _ hc · simp [a, newEvents, paidDirections] · simp [a, newEvents, Realized] · intro c' he simp [a] at he
abbrev Word (K : ℕ) := DWord (Action (V := V) (B := B) lines K) (advance lines K)abbrev finish (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) := dFinish (Action lines K) (advance lines K) s wabbrev charge (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) := dCharge (Action lines K) (advance lines K) (actionCharge lines K) s w
def degreeSum (K : ℕ) : {n : ℕ} → (s : State V H D B) → Word lines K n s → ℕ | 0, _, _ => 0 | _ + 1, s, w => degree lines K s w.1 + degreeSum K (advance lines K s w.1) w.2
def TraceOK (K : ℕ) (low : Bool) : {n : ℕ} → (s : State V H D B) → Word lines K n s → Prop | 0, _, _ => True | _ + 1, s, w => s.2.card ≤ K * Fintype.card V ∧ Enabled lines K low s w.1 ∧ TraceOK K low (advance lines K s w.1) w.2
def append (K : ℕ) {m : ℕ} : {n : ℕ} → (s : State V H D B) → (w : Word lines K n s) → Word lines K m (finish lines K s w) → Word lines K (m + n) s | 0, _, _, w' => w' | _ + 1, s, w, w' => ⟨w.1, append K (advance lines K s w.1) w.2 w'⟩
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] inlemma finish_append (K : ℕ) {m n : ℕ} (s : State V H D B) (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) : finish lines K s (append lines K s w w') = finish lines K (finish lines K s w) w' := by induction n generalizing s with | zero => rfl | succ n ih => exact ih _ w.2 w'
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] inlemma degreeSum_append (K : ℕ) {m n : ℕ} (s : State V H D B) (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) : degreeSum lines K s (append lines K s w w') = degreeSum lines K s w + degreeSum lines K (finish lines K s w) w' := by induction n generalizing s with | zero => simp only [append, degreeSum, finish, dFinish, Nat.zero_add] | succ n ih => simpa only [append, degreeSum, finish, dFinish, Nat.add_assoc] using congrArg (fun t => degree lines K s w.1 + t) (ih (advance lines K s w.1) w.2 w')
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] inlemma charge_append (K : ℕ) {m n : ℕ} (s : State V H D B) (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) : charge lines K s (append lines K s w w') = charge lines K s w + charge lines K (finish lines K s w) w' := by induction n generalizing s with | zero => simp only [append, charge, dCharge, finish, dFinish, zero_add] | succ n ih => simpa only [append, charge, dCharge, finish, dFinish, add_assoc] using congrArg (fun t => actionCharge lines K s w.1 + t) (ih (advance lines K s w.1) w.2 w')
omit [Fintype H] [DecidableEq H] [Fintype D] inlemma traceOK_append (K : ℕ) (low : Bool) {m n : ℕ} (s : State V H D B) (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) (h : TraceOK lines K low s w) (h' : TraceOK lines K low (finish lines K s w) w') : TraceOK lines K low s (append lines K s w w') := by induction n generalizing s with | zero => exact h' | succ n ih => exact ⟨h.1, h.2.1, ih _ w.2 w' h.2.2 h'⟩
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq B] inlemma one_le_degree (K : ℕ) (s : State V H D B) (a : Action lines K s) : 1 ≤ degree lines K s a := by rcases a with a | a · exact le_rfl rcases a with a | a · exact le_rfl rcases a with a | a · exact le_rfl · norm_num [degree]omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in
lemma length_le_degreeSum (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) : n ≤ degreeSum lines K s w := by induction n generalizing s with | zero => exact le_rfl | succ n ih => have h1 := one_le_degree lines K s w.1 have h2 := ih _ w.2 change n + 1 ≤ _ + _ omegaomit [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma trace_weight (rate : D → ℝ≥0) (denom : ℝ) (hd : denom ≠ 0) (K : ℕ) (low : Bool) {n : ℕ} (s : State V H D B) (w : Word lines K n s) (hw : TraceOK lines K low s w) : weight (fun p : B × D => rate p.2) (finish lines K s w).2 = weight (fun p : B × D => rate p.2) s.2 * dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s w * denom ^ degreeSum lines K s w := by induction n generalizing s with | zero => simp [finish, dFinish, dWeight, degreeSum] | succ n ih => change weight _ (finish lines K (advance lines K s w.1) w.2).2 = _ rw [ih _ w.2 hw.2.2, step_weight lines rate denom hd K low s w.1 hw.2.1 hw.1] simp only [dWeight, degreeSum, pow_add] ring
def Segment (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) (E F : Finset V) (s : State V H D B) {n : ℕ} (w : Word lines K n s) : Prop := Coherent lines f hit K F (finish lines K s w) ∧ F.card = E.card + degreeSum lines K s w ∧ TraceOK lines K low s w
omit [Fintype H] [DecidableEq H] [Fintype D] inlemma segment_empty (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) : Segment lines f hit K low E E s (n := 0) (PUnit.unit : Word lines K 0 s) := by exact ⟨hs, by simp [degreeSum], trivial⟩
omit [Fintype H] [DecidableEq H] [Fintype D] inlemma segment_single (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) (E F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (a : Action lines K s) (hf : Coherent lines f hit K F (advance lines K s a)) (hc : F.card = E.card + degree lines K s a) (he : Enabled lines K low s a) : Segment lines f hit K low E F s (n := 1) (⟨a, PUnit.unit⟩ : Word lines K 1 s) := by refine ⟨hf, ?_, ?_⟩ · simpa [degreeSum] using hc · exact ⟨hs.2.2.2.trans (Nat.mul_le_mul_left K (Finset.card_le_univ E)), he, trivial⟩omit [Fintype H] [DecidableEq H] [Fintype D] in
lemma segment_append (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) (E F G : Finset V) {m n : ℕ} (s : State V H D B) (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) (h : Segment lines f hit K low E F s w) (h' : Segment lines f hit K low F G (finish lines K s w) w') : Segment lines f hit K low E G s (append lines K s w w') := by refine ⟨?_, ?_, traceOK_append lines K low s w w' h.2.2 h'.2.2⟩ · rw [finish_append]; exact h'.1 · rw [degreeSum_append, ← Nat.add_assoc, ← h.2.1] exact h'.2.1omit [Fintype V] [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma make_encoding (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) {E F : Finset V} (h : EncodingStep (fun v => lines (f v)) hit (if low then 1 else 2) K E F) (s : State V H D B) (hs : Coherent lines f hit K E s) : ∃ a : Action lines K s, Coherent lines f hit K F (advance lines K s a) ∧ F.card = E.card + degree lines K s a ∧ Enabled lines K low s a ∧ 0 ≤ actionCharge lines K s a := by cases h with | anchor v hv ha => cases low with | false => obtain ⟨a, hh, hc, he, hq⟩ := make_two lines f hit K hK false E s hs v hv ha exact ⟨a, hh, hc, he, by omega⟩ | true => obtain ⟨a, hh, hc, he, hq⟩ := make_one lines f hit K hK E s hs v hv ha exact ⟨a, hh, hc, he, by omega⟩ | pair v u hv hu hne hp => obtain ⟨a, hh, hc, he, hq⟩ := make_pair lines f hf hit K hK low E s hs v u hv hu hne hp exact ⟨a, hh, hc, he, by omega⟩
omit [Fintype H] [DecidableEq H] inomit [Fintype D] in
theorem encoding_path_program (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) {E F : Finset V} (h : Relation.ReflTransGen (EncodingStep (fun v => lines (f v)) hit (if low then 1 else 2) K) E F) (s : State V H D B) (hs : Coherent lines f hit K E s) : ∃ n, ∃ w : Word lines K n s, Segment lines f hit K low E F s w ∧ 0 ≤ charge lines K s w := by induction h with | refl => exact ⟨0, PUnit.unit, segment_empty lines f hit K low E s hs, le_rfl⟩ | @tail F G h hFG ih => obtain ⟨n, w, hw, hq⟩ := ih obtain ⟨a, ha, hc, he, hqa⟩ := make_encoding lines f hf hit K hK low hFG (finish lines K s w) hw.1 let w' : Word lines K 1 (finish lines K s w) := ⟨a, PUnit.unit⟩ refine ⟨1 + n, append lines K s w w', ?_, ?_⟩ · exact segment_append lines f hit K low E F G s w w' hw (segment_single lines f hit K low F G _ hw.1 a ha hc he) · rw [charge_append] exact add_nonneg hq (by simpa [w', charge, dCharge] using hqa)
omit [Fintype H] [DecidableEq H] [Fintype D] in
lemma encode_set (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) (E R : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (c : ℤ) (hdis : Disjoint E R) (hmake : ∀ F : Finset V, E ⊆ F → ∀ s' : State V H D B, Coherent lines f hit K F s' → ∀ v ∈ R, v ∉ F → ∃ a : Action lines K s', Coherent lines f hit K (insert v F) (advance lines K s' a) ∧ (insert v F).card = F.card + degree lines K s' a ∧ Enabled lines K low s' a ∧ actionCharge lines K s' a = c) : ∃ n, ∃ w : Word lines K n s, Segment lines f hit K low E (E ∪ R) s w ∧ charge lines K s w = c * R.card := by classical induction R using Finset.induction with | empty => refine ⟨0, PUnit.unit, ?_, ?_⟩ · simpa using segment_empty lines f hit K low E s hs · simp [charge, dCharge] | @insert v R hvR ih => have hdis' : Disjoint E R := hdis.mono_right (Finset.subset_insert _ _) obtain ⟨n, w, hw, hq⟩ := ih hdis' (by intro F hEF s' hs' u hu hfu exact hmake F hEF s' hs' u (Finset.mem_insert_of_mem hu) hfu) have hvE : v ∉ E := fun hvE => Finset.disjoint_left.mp hdis hvE (Finset.mem_insert_self _ _) have hvF : v ∉ E ∪ R := by simp [hvE, hvR] obtain ⟨a, ha, hc, he, hqa⟩ := hmake (E ∪ R) Finset.subset_union_left (finish lines K s w) hw.1 v (Finset.mem_insert_self _ _) hvF let w' : Word lines K 1 (finish lines K s w) := ⟨a, PUnit.unit⟩ refine ⟨1 + n, append lines K s w w', ?_, ?_⟩ · have hh := segment_append lines f hit K low E (E ∪ R) (insert v (E ∪ R)) s w w' hw (segment_single lines f hit K low (E ∪ R) _ _ hw.1 a ha hc he) simpa only [Finset.union_insert] using hh · rw [charge_append, hq] change c * (R.card : ℤ) + (actionCharge lines K _ a + 0) = _ rw [hqa, Finset.card_insert_of_notMem hvR, Nat.cast_add, Nat.cast_one] ringomit [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma residual_program (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) (F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K F s) (roots : Finset {v // v ∉ F}) (hsize : 10 * roots.card ≤ Fintype.card {v // v ∉ F}) (hroot : ∀ v, ∃ u ∈ roots, ∃ w ∈ roots, u ≠ w ∧ u ≠ v ∧ w ≠ v ∧ ∃ d ∈ survivingDirections (fun v => lines (f v)) F v ∩ survivingDirections (fun v => lines (f v)) F u, ∃ e ∈ survivingDirections (fun v => lines (f v)) F v ∩ survivingDirections (fun v => lines (f v)) F w, d ≠ e ∧ (∃ r, hit r d) ∧ (∃ r, hit r e)) : ∃ n, ∃ w : Word lines K n s, Segment lines f hit K low F Finset.univ s w ∧ 0 ≤ charge lines K s w := by classical let R : Finset V := roots.image Subtype.val have hRc : R.card = roots.card := by dsimp [R] apply Finset.card_image_of_injective exact Subtype.val_injective have hdis : Disjoint F R := by apply Finset.disjoint_left.mpr intro v hv hR obtain ⟨u, _, rfl⟩ := Finset.mem_image.mp hR exact u.property hv obtain ⟨n, w, hw, hq⟩ := encode_set lines f hit K low F R s hs (-8) hdis (by intro G hFG s' hs' v hv hvg exact make_root lines f hit K hK low G s' hs' v hvg) let NR : Finset V := Finset.univ \ (F ∪ R) have hdisNR : Disjoint (F ∪ R) NR := Finset.disjoint_sdiff have hmake : ∀ G : Finset V, F ∪ R ⊆ G → ∀ s' : State V H D B, Coherent lines f hit K G s' → ∀ v ∈ NR, v ∉ G → ∃ a : Action lines K s', Coherent lines f hit K (insert v G) (advance lines K s' a) ∧ (insert v G).card = G.card + degree lines K s' a ∧ Enabled lines K low s' a ∧ actionCharge lines K s' a = 1 := by intro G hFG s' hs' v hv hvg have hvF : v ∉ F := fun hvF => (Finset.mem_sdiff.mp hv).2 (Finset.mem_union_left R hvF) obtain ⟨u, hu, u', hu', _, _, _, d, hd, e, he, hde, hdp, hep⟩ := hroot ⟨v, hvF⟩ have hdv : d ∈ lines (f v) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp hd).1).1 have hdu : d ∈ lines (f u.val) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp hd).2).1 have hev : e ∈ lines (f v) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp he).1).1 have heu : e ∈ lines (f u'.val) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp he).2).1 have hdE : d ∈ encodedDirections (fun v => lines (f v)) G := Finset.mem_biUnion.mpr ⟨u.val, hFG (Finset.mem_union_right F (Finset.mem_image_of_mem Subtype.val hu)), hdu⟩ have heE : e ∈ encodedDirections (fun v => lines (f v)) G := Finset.mem_biUnion.mpr ⟨u'.val, hFG (Finset.mem_union_right F (Finset.mem_image_of_mem Subtype.val hu')), heu⟩ apply make_two lines f hit K hK low G s' hs' v hvg apply Finset.one_lt_card.mpr exact ⟨d, Finset.mem_filter.mpr ⟨Finset.mem_inter.mpr ⟨hdv, hdE⟩, hdp⟩, e, Finset.mem_filter.mpr ⟨Finset.mem_inter.mpr ⟨hev, heE⟩, hep⟩, hde⟩ obtain ⟨m, w', hw', hq'⟩ := encode_set lines f hit K low (F ∪ R) NR (finish lines K s w) hw.1 1 hdisNR hmake have hfull : (F ∪ R) ∪ NR = Finset.univ := by ext v simp only [NR, Finset.mem_union, Finset.mem_sdiff, Finset.mem_univ, true_and] tauto refine ⟨m + n, append lines K s w w', ?_, ?_⟩ · simpa only [hfull] using segment_append lines f hit K low F (F ∪ R) _ s w w' hw hw' · rw [charge_append, hq, hq', one_mul] have hr : Fintype.card {v // v ∉ F} = Fintype.card V - F.card := by rw [Fintype.card_subtype_compl] simp have hc : NR.card + (F.card + R.card) = Fintype.card V := by have hh := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ (F ∪ R)) simpa only [NR, Finset.card_univ, Finset.card_union_of_disjoint hdis] using hh rw [← hRc, hr] at hsize omega
omit [Fintype H] [DecidableEq H] inomit [Fintype D] in
theorem bad_program_high (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop) [∀ r d, Decidable (hit r d)] (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (hsize : h ≤ (Fintype.card B / 2 - J) / (2 * K)) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (hbad : ∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches (fun v => lines (f v)) hit v).card) (htrunc : ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : ∃ n, ∃ w : Word lines K n s, Segment lines f hit K false E Finset.univ s w ∧ 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by classical obtain ⟨F, hpath, roots, hr, hroot⟩ := high_case_certificate_geometry (fun v => lines (f v)) hit E K J h hh hsize hbad (by intro d apply le_trans _ (htrunc d) apply Finset.card_le_card intro r hr simpa only [Finset.mem_filter, Finset.mem_univ, true_and] using hr) herr obtain ⟨n, w, hw, hq⟩ := encoding_path_program lines f hf hit K hK false hpath s hs obtain ⟨m, w', hw', hq'⟩ := residual_program lines f hit K hK false F (finish lines K s w) hw.1 roots hr hroot refine ⟨m + n, append lines K s w w', segment_append lines f hit K false E F _ s w w' hw hw', ?_, ?_⟩ · rw [charge_append]; exact add_nonneg hq hq' · have hl := length_le_degreeSum lines K s (append lines K s w w') have hc := (segment_append lines f hit K false E F _ s w w' hw hw').2.1 simp only [Finset.card_univ] at hc omegaomit [Fintype H] [DecidableEq H] inomit [Fintype D] in
theorem bad_program_low (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop) (K h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (hsize : h ≤ (Fintype.card B / 2) / (2 * K)) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (hbad : ∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches (fun v => lines (f v)) hit v).card) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : ∃ n, ∃ w : Word lines K n s, Segment lines f hit K true E Finset.univ s w ∧ 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by obtain ⟨F, hpath, roots, hr, hroot⟩ := low_case_certificate_geometry (fun v => lines (f v)) hit E K h hh hsize hbad herr obtain ⟨n, w, hw, hq⟩ := encoding_path_program lines f hf hit K hK true hpath s hs obtain ⟨m, w', hw', hq'⟩ := residual_program lines f hit K hK true F (finish lines K s w) hw.1 roots hr hroot refine ⟨m + n, append lines K s w w', segment_append lines f hit K true E F _ s w w' hw hw', ?_, ?_⟩ · rw [charge_append]; exact add_nonneg hq hq' · have hl := length_le_degreeSum lines K s (append lines K s w w') have hc := (segment_append lines f hit K true E F _ s w w' hw hw').2.1 simp only [Finset.card_univ] at hc omega
omit [DecidableEq D] [DecidableEq B] inlemma decoded_static_union_bound {F C : Type*} [Fintype F] [DecidableEq F] [Fintype C] [DecidableEq C] (rate : D → ℝ≥0) (requirements : C → Finset (B × D)) (decode : C → F) (events : F → Set ((B × D) → ℕ)) (hm : ∀ f, MeasurableSet (events f)) (hc : ∀ f ω, ω ∈ events f → ∃ c, decode c = f ∧ ω ∈ positiveEvent (requirements c)) : (∑ f, (poissonLaw (fun p : B × D => rate p.2)).real (events f)) ≤ ∑ c, weight (fun p : B × D => rate p.2) (requirements c) := by classical calc _ ≤ ∑ f, ∑ c ∈ Finset.univ.filter (fun c => decode c = f), weight (fun p : B × D => rate p.2) (requirements c) := by apply Finset.sum_le_sum intro f _ apply static_union_bound _ requirements _ (events f) (hm f) intro ω hω obtain ⟨c, hd, he⟩ := hc f ω hω exact ⟨c, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hd⟩, he⟩ _ = _ := by simp only [Finset.sum_filter] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro c _ simp
abbrev AllPrograms (K : ℕ) (E : Finset V) (s : State V H D B) := (n : Fin (Fintype.card V - E.card + 1)) × Word lines K n.val s
def CompleteProgram (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) (c : AllPrograms lines K E s) : Prop := TraceOK lines K low s c.2 ∧ 0 ≤ charge lines K s c.2 ∧ degreeSum lines K s c.2 = Fintype.card V - E.card
noncomputable def completePrograms (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) := {c : AllPrograms lines K E s // CompleteProgram lines K low E s c}
noncomputable instance completePrograms_fintype (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) : Fintype (completePrograms lines K low E s) := by classical unfold completePrograms infer_instanceend SharpRamseyFive.CertificateCoverend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import Mathlibimport OAI.Combinatorics.SharpRamsey.Marking.MarkingTwoScans
namespace OAI
sectionnamespace SharpLogRamsey.Selectionopen scoped BigOperators Classicalnoncomputable sectionvariable {Ω Γ α ι : Type*} [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype ι]
def selectedDeficit (p : Law Ω) (θ : Ω → Γ) (F : Ω → ι → α) (S : Γ → Finset ι) (J : ℝ) : ℝ := ∑ z, (p.map θ).mass z*((S z).card*J-entropy (((p.cond θ z).map F).restrict (S z)))endend SharpLogRamsey.Selection
namespace SharpLogRamsey.Markingopen scoped BigOperators Classicalnoncomputable sectionvariable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] [Finite K]
abbrev jointJ (K : Type*) (d : ℕ) : ℝ := Real.log (64*(Nat.card K:ℝ)^d)
def sourceMessage {Ω Γ : Type*} {N : ℕ} (C : Ω → Γ) (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) : Ω → TwoMessage (K:=K) (V:=V) Γ N := Selection.markingMessage C (fun x => twoMask (Nat.card K) (F x)) bothExpensive F
variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ]
def excessCost {N : ℕ} (p : Selection.Law Ω) (C : Ω → Γ) (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) (Jprev J₀ : ℝ) : ℝ := Selection.entropy (p.map C)+Real.log (Fintype.card (TwoMask (K:=K) (V:=V) N))+ N*J₀-Selection.entropy (p.map F)+ (∑ x, p.mass x*((bothExpensive (twoMask (Nat.card K) (F x))).card:ℝ))*(Jprev-J₀)
theorem twoScan_subset_deficit {N n : ℕ} (hdim : Module.finrank K V=n+3) (p : Selection.Law Ω) (C : Ω → Γ) (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) (D : Γ → Fin N → Finset (ProjectivePair (K:=K) (V:=V))) (Jprev : ℝ) (hcons : ∀ x, p.mass x≠0 → ScanConsistent ((List.ofFn (F x)).map toScan)) (hinc : ∀ x, p.mass x≠0 → ∀ i, Incidence.Incident (F x i).1 (F x i).2) (hD : ∀ x, p.mass x≠0 → ∀ i, F x i∈D (C x) i) (hprev : ∀ c i, Real.log (D c i).card≤Jprev) (S : TwoMessage (K:=K) (V:=V) Γ N → Finset (Fin N)) (hS : ∀ z, Disjoint (S z) (bothExpensive z.2.2)) : 0 ≤ Selection.selectedDeficit p (sourceMessage C F) F S (jointJ K (n+2)) ∧ Selection.selectedDeficit p (sourceMessage C F) F S (jointJ K (n+2)) ≤ excessCost p C F Jprev (jointJ K (n+2)) := by have hh := Selection.marking_subset_deficit p C (fun x => twoMask (Nat.card K) (F x)) bothExpensive F D cheapBoth Jprev (jointJ K (n+2)) hD hprev (fun x hx i hi => cheapBoth_mem C F x (hcons x hx) (hinc x hx) i hi) (fun z i _ => cheapBoth_log_card hdim z i) S hS change 0≤_ ∧ _≤_ at hh convert hh using 1 <;> simp only [Selection.selectedDeficit,sourceMessage,excessCost,Fintype.card_fin] all_goals congr!
endend SharpLogRamsey.Marking
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.TwoAnchorCrossCost
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen scoped BigOperatorsnamespace SharpRamseyFive.WeightedProgramsopen SharpRamseyFive.StaticCertificatesopen SharpRamseyFive.CertificateEnumerationopen scoped BigOperators NNRealvariable {V H D B : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B]variable (lines : H → Finset D)def newEvents (K : ℕ) (s : State V H D B) : Action lines K s → Finset (B × D) | .inl _ => ∅ | .inr (.inl c) => c.2.2.1.requirements | .inr (.inr (.inl c)) => c.2.2.2.1.requirements ∪ c.2.2.2.2.1.requirements | .inr (.inr (.inr c)) => witnessRequirements c.2.2.2.2.1.val (PairDirections lines s c.2.2.1 c.2.2.2.1.val) c.2.2.2.2.2
def newValues (K : ℕ) (s : State V H D B) : Action lines K s → V → H | .inl c => Function.update s.1 c.1 c.2 | .inr (.inl c) => Function.update s.1 c.1 c.2.2.2.val | .inr (.inr (.inl c)) => Function.update s.1 c.1 c.2.2.2.2.2.val | .inr (.inr (.inr c)) => Function.update (Function.update s.1 c.1 c.2.2.1) c.2.1 c.2.2.2.1.val
def advance (K : ℕ) (s : State V H D B) (a : Action lines K s) : State V H D B := (newValues lines K s a, s.2 ∪ newEvents lines K s a)
def degree (K : ℕ) (s : State V H D B) : Action lines K s → ℕ | .inr (.inr (.inr _)) => 2 | _ => 1
def actionCharge (K : ℕ) (s : State V H D B) : Action lines K s → ℤ | .inl _ => -8 | .inr (.inr (.inl _)) => 1 | _ => 0
noncomputable def rawCost (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool) (s : State V H D B) : Action lines K s → ℝ | .inl _ => 1 / denom | .inr (.inl c) => if low then oneCost lines rate denom s c else 0 | .inr (.inr (.inl c)) => twoCost lines rate denom s c | .inr (.inr (.inr c)) => pairCost lines rate denom K s c
noncomputable def programCost (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : ℝ := if s.2.card ≤ K * Fintype.card V then rawCost lines rate denom K low s a else 0
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inomit [Fintype D] inlemma newEvents_fresh (K : ℕ) (s : State V H D B) (a : Action lines K s) : Disjoint s.2 (newEvents lines K s a) := by rcases a with a | a · exact Finset.disjoint_empty_right _ rcases a with a | a · exact a.2.2.1.fresh rcases a with a | a · exact Finset.disjoint_union_right.mpr ⟨a.2.2.2.1.fresh, a.2.2.2.2.1.fresh⟩ · apply witnessRequirements_disjoint apply Finset.disjoint_left.mpr intro d hd hdC exact (Finset.mem_sdiff.mp hd).2 hdC
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] inomit [Fintype D] inlemma rawCost_nonneg (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom) (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : 0 ≤ rawCost lines rate denom K low s a := by rcases a with a | a · exact div_nonneg zero_le_one hd rcases a with a | a · change 0 ≤ if low then _ else 0 split_ifs · exact div_nonneg (a.2.2.1.cost_nonneg rate) hd · exact le_rfl rcases a with a | a · exact div_nonneg (mul_nonneg (a.2.2.2.1.cost_nonneg rate) (a.2.2.2.2.1.cost_nonneg rate)) hd · exact div_nonneg (weight_nonneg _ _) (sq_nonneg _)omit [DecidableEq V] [Fintype H] [DecidableEq H] inomit [Fintype D] in
lemma programCost_nonneg (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom) (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : 0 ≤ programCost lines rate denom K low s a := by unfold programCost split_ifs · exact rawCost_nonneg lines rate denom hd K low s a · exact le_rfl
noncomputable def uniformAnchorBudget (K : ℕ) (mass : ℝ) : ℝ := K * Fintype.card V + Fintype.card B * mass
noncomputable def branchingBound (rate : D → ℝ≥0) (denom b mass : ℝ) (K N₁ N₂ : ℕ) (low : Bool) : ℝ := ((Fintype.card V : ℝ) * Fintype.card H / denom) / b ^ 8 + (if low then Fintype.card V ^ 2 * (N₁ : ℝ) * uniformAnchorBudget (V := V) (B := B) K mass / denom else 0) + (Fintype.card V ^ 3 * (N₂ : ℝ) * uniformAnchorBudget (V := V) (B := B) K mass ^ 2 / denom) * b + Fintype.card V ^ 2 * pairMoment (B := B) lines rate K / denom ^ 2
omit [DecidableEq V] inomit [Fintype D] [DecidableEq B] inlemma branchingBound_nonneg (rate : D → ℝ≥0) (denom b mass : ℝ) (hd : 0 ≤ denom) (hb : 0 ≤ b) (hm : 0 ≤ mass) (K N₁ N₂ : ℕ) (low : Bool) : 0 ≤ branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low := by unfold branchingBound uniformAnchorBudget have hp := pairMoment_nonneg (B := B) lines rate K split_ifs <;> positivity
omit [DecidableEq V] [Fintype D] inlemma discounted_raw_sum (rate : D → ℝ≥0) (denom b : ℝ) (K : ℕ) (low : Bool) (s : State V H D B) : (∑ a : Action lines K s, rawCost lines rate denom K low s a * b ^ actionCharge lines K s a) = ((Fintype.card V : ℝ) * Fintype.card H / denom) / b ^ 8 + (if low then ∑ c : OneChoice lines s, oneCost lines rate denom s c else 0) + (∑ c : TwoChoice lines s, twoCost lines rate denom s c) * b + ∑ c : PairChoice lines K s, pairCost lines rate denom K s c := by classical change (∑ a : RootChoice (V := V) (H := H) ⊕ OneChoice lines s ⊕ TwoChoice lines s ⊕ PairChoice lines K s, _) = _ simp only [Fintype.sum_sum_type, rawCost, actionCharge] cases low <;> simp only [Bool.false_eq_true, ↓reduceIte, zpow_neg, zpow_ofNat, ← Finset.sum_mul, Finset.sum_const, Finset.card_univ, Fintype.card_prod, nsmul_eq_mul, RootChoice, Nat.cast_mul] <;> ring
omit [DecidableEq V] inomit [Fintype D] in
theorem discounted_row_bound (rate : D → ℝ≥0) (denom b mass : ℝ) (hd : 0 ≤ denom) (hb : 0 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) (K N₁ N₂ : ℕ) (low : Bool) (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) (s : State V H D B) : (∑ a : Action lines K s, programCost lines rate denom K low s a * b ^ actionCharge lines K s a) ≤ branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low := by classical by_cases hs : s.2.card ≤ K * Fintype.card V · simp only [programCost, ite_eq_left hs] rw [discounted_raw_sum] have hA : anchorBudget rate s mass ≤ uniformAnchorBudget (V := V) (B := B) K mass := by unfold anchorBudget uniformAnchorBudget apply add_le_add _ le_rfl exact_mod_cast hs have h1 := sum_oneCost_le lines rate denom hd s mass hmass N₁ hN₁ have h2 := sum_twoCost_le lines rate denom hd s mass hm hmass N₂ hN₂ have h3 := sum_pairCost_le lines rate denom K s unfold branchingBound apply add_le_add · apply add_le_add · apply add_le_add le_rfl split_ifs with hl · apply h1.trans apply div_le_div_of_nonneg_right _ hd exact mul_le_mul_of_nonneg_left hA (by positivity) · exact le_rfl · apply mul_le_mul_of_nonneg_right _ hb apply h2.trans apply div_le_div_of_nonneg_right _ hd apply mul_le_mul_of_nonneg_left _ (by positivity) exact pow_le_pow_left₀ (anchorBudget_nonneg rate s mass hm) hA 2 · exact h3 · simp only [programCost, ite_eq_right hs, zero_mul, Finset.sum_const_zero] exact branchingBound_nonneg (V := V) lines rate denom b mass hd hb hm K N₁ N₂ low
omit [Fintype D] in
theorem program_enumeration (rate : D → ℝ≥0) (denom b mass : ℝ) (hd : 0 ≤ denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) (K N₁ N₂ : ℕ) (low : Bool) (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) (n : ℕ) (s : State V H D B) : (∑ w : DWord (Action lines K) (advance lines K) n s, if 0 ≤ dCharge (Action lines K) (advance lines K) (actionCharge lines K) s w then dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s w else 0) ≤ branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n := by classical exact constrained_dSum_le (Action lines K) (advance lines K) (programCost lines rate denom K low) (programCost_nonneg lines rate denom hd K low) (actionCharge lines K) b _ hb (branchingBound_nonneg (V := V) lines rate denom b mass hd (by linarith) hm K N₁ N₂ low) (discounted_row_bound lines rate denom b mass hd (by linarith) hm hmass K N₁ N₂ low hN₁ hN₂) n s _ (fun _ h => h)
end SharpRamseyFive.WeightedPrograms
open MeasureTheory ProbabilityTheoryopen scoped BigOperators ENNReal NNReal
namespace SharpRamseyFive.ResidualCertificate
variable {V : Type*} [Fintype V] [DecidableEq V]
noncomputable def rootProbability : unitInterval := ⟨1 / 20, by norm_num⟩
noncomputable def rootMeasure : Measure (V → Bool) := Measure.pi (fun _ => bernoulliMeasure true false rootProbability)
instance flat_HighMomentRecovered_6 : IsProbabilityMeasure (rootMeasure (V := V)) := by unfold rootMeasure infer_instance
noncomputable def selected (ω : V → Bool) : Finset V := Finset.univ.filter (fun v => ω v = true)
def voidEvent (W : Finset V) : Set (V → Bool) := (W : Set V).pi (fun _ => {false})
noncomputable def voidIndicator (W : Finset V) (ω : V → Bool) : ℝ := (voidEvent W).indicator (fun _ => 1) ω
noncomputable def badIndicator (W : Finset V) (ω : V → Bool) : ℝ := if (W ∩ selected ω).card < 2 then 1 else 0
omit [DecidableEq V] inlemma integrable_bounded (f : (V → Bool) → ℝ) (C : ℝ) (hf : ∀ ω, |f ω| ≤ C) : Integrable f rootMeasure := by apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable C exact Filter.Eventually.of_forall (by intro ω; simpa only [Real.norm_eq_abs] using hf ω)omit [DecidableEq V] in
lemma integrable_voidIndicator (W : Finset V) : Integrable (voidIndicator W) rootMeasure := by apply integrable_bounded _ 1 intro ω by_cases h : ω ∈ voidEvent W <;> simp [voidIndicator, h]
lemma integrable_badIndicator (W : Finset V) : Integrable (badIndicator W) rootMeasure := by apply integrable_bounded _ 1 intro ω simp only [badIndicator] split_ifs <;> norm_num
omit [Fintype V] [DecidableEq V] inlemma voidIndicator_nonneg (W : Finset V) (ω : V → Bool) : 0 ≤ voidIndicator W ω := by by_cases h : ω ∈ voidEvent W <;> simp [voidIndicator, h]
lemma badIndicator_nonneg (W : Finset V) (ω : V → Bool) : 0 ≤ badIndicator W ω := by simp only [badIndicator] split_ifs <;> norm_num
omit [DecidableEq V] inlemma integral_voidIndicator (W : Finset V) : ∫ ω, voidIndicator W ω ∂rootMeasure = (19 / 20 : ℝ) ^ W.card := by have hm : MeasurableSet (voidEvent W) := MeasurableSet.pi W.finite_toSet.countable (fun _ _ => measurableSet_singleton false) have hprob : rootMeasure (voidEvent W) = ENNReal.ofReal ((19 / 20 : ℝ) ^ W.card) := by rw [rootMeasure, voidEvent, Measure.pi_pi_finset] simp only [bernoulliMeasure_apply rootProbability (measurableSet_singleton false)] norm_num [rootProbability, unitInterval.toNNReal, unitInterval.symm] congr 1 exact ENNReal.ofReal_coe_nnreal.symm simp only [voidIndicator] rw [ integral_indicator_const _ hm, Measure.real, hprob, ENNReal.toReal_ofReal (by positivity)] simp
lemma erase_void_witness (W : Finset V) (hW : W.Nonempty) (ω : V → Bool) (hbad : (W ∩ selected ω).card < 2) : ∃ j ∈ W, ω ∈ voidEvent (W.erase j) := by have hsmall : (W ∩ selected ω).card ≤ 1 := by omega have hc := Finset.card_le_one.mp hsmall by_cases he : (W ∩ selected ω).Nonempty · obtain ⟨j, hj⟩ := he refine ⟨j, (Finset.mem_inter.mp hj).1, ?_⟩ intro k hk apply Set.mem_singleton_iff.mpr apply Bool.eq_false_of_not_eq_true intro hkt have hkm : k ∈ W ∩ selected ω := by simp only [Finset.mem_inter, selected, Finset.mem_filter, Finset.mem_univ, true_and] exact ⟨(Finset.mem_erase.mp hk).2, hkt⟩ exact (Finset.mem_erase.mp hk).1 (hc k hkm j hj) · obtain ⟨j, hj⟩ := hW refine ⟨j, hj, ?_⟩ intro k hk apply Set.mem_singleton_iff.mpr apply Bool.eq_false_of_not_eq_true intro hkt apply he refine ⟨k, ?_⟩ simp only [Finset.mem_inter, selected, Finset.mem_filter, Finset.mem_univ, true_and] exact ⟨(Finset.mem_erase.mp hk).2, hkt⟩
lemma badIndicator_le_erase_void (W : Finset V) (hW : W.Nonempty) (ω : V → Bool) : badIndicator W ω ≤ ∑ j ∈ W, voidIndicator (W.erase j) ω := by unfold badIndicator split_ifs with hb · obtain ⟨j, hj, hv⟩ := erase_void_witness W hW ω hb have hle := Finset.single_le_sum (f := fun j => voidIndicator (W.erase j) ω) (fun j _ => voidIndicator_nonneg _ _) hj simpa only [voidIndicator, Set.indicator_of_mem hv] using hle · exact Finset.sum_nonneg (fun j _ => voidIndicator_nonneg _ _)
lemma integral_badIndicator_le (W : Finset V) (hW : W.Nonempty) : ∫ ω, badIndicator W ω ∂rootMeasure ≤ W.card * (19 / 20 : ℝ) ^ (W.card - 1) := by calc _ ≤ ∫ ω, ∑ j ∈ W, voidIndicator (W.erase j) ω ∂rootMeasure := integral_mono (integrable_badIndicator W) (integrable_finsetSum _ (fun j _ => integrable_voidIndicator _)) (badIndicator_le_erase_void W hW) _ = ∑ j ∈ W, (19 / 20 : ℝ) ^ (W.card - 1) := by rw [integral_finsetSum _ (fun j _ => integrable_voidIndicator _)] apply Finset.sum_congr rfl intro j hj rw [integral_voidIndicator, Finset.card_erase_of_mem hj] _ = _ := by simp
omit [DecidableEq V] inlemma indicator_selected (ω : V → Bool) : ((selected ω).card : ℝ) = ∑ v : V, if ω v = true then (1 : ℝ) else 0 := by symm exact Finset.sum_boole _ _omit [DecidableEq V] in
lemma integrable_selected_card : Integrable (fun ω : V → Bool => ((selected ω).card : ℝ)) rootMeasure := by simp_rw [indicator_selected] apply integrable_finsetSum intro v hv apply integrable_bounded _ 1 intro ω split_ifs <;> norm_numomit [DecidableEq V] in
lemma integral_selected_card : ∫ ω : V → Bool, ((selected ω).card : ℝ) ∂rootMeasure = (Fintype.card V : ℝ) / 20 := by simp_rw [indicator_selected] rw [integral_finsetSum] · have hv (v : V) : (∫ ω : V → Bool, if ω v = true then (1 : ℝ) else 0 ∂rootMeasure) = 1 / 20 := by rw [rootMeasure, integral_comp_eval (μ := fun _ : V => bernoulliMeasure true false rootProbability) (i := v) (f := fun a : Bool => if a = true then (1 : ℝ) else 0) (measurable_of_countable _).aestronglyMeasurable, integral_bernoulliMeasure] norm_num [rootProbability] simp_rw [hv] simp [div_eq_mul_inv] · intro v hv apply integrable_bounded _ 1 intro ω split_ifs <;> norm_num
theorem exists_small_root_set (W : V → Finset V) {k : ℕ} (hk : 0 < k) (hW : ∀ v, (W v).card = k) (herr : (Fintype.card V : ℝ) * k * (19 / 20 : ℝ) ^ (k - 1) < 1 / 2) : ∃ roots : Finset V, 10 * roots.card ≤ Fintype.card V ∧ ∀ v, 2 ≤ (W v ∩ roots).card := by classical by_cases hn : Fintype.card V = 0 · have : IsEmpty V := Fintype.card_eq_zero_iff.mp hn exact ⟨∅, by simp [], fun v => isEmptyElim v⟩ have hnpos : (0 : ℝ) < Fintype.card V := by exact_mod_cast (Nat.pos_of_ne_zero hn) let F : (V → Bool) → ℝ := fun ω => (10 / Fintype.card V : ℝ) * (selected ω).card + ∑ v, badIndicator (W v) ω have hFi : Integrable F rootMeasure := (integrable_selected_card.const_mul _).add (integrable_finsetSum _ (fun v _ => integrable_badIndicator (W v))) have hFint : ∫ ω, F ω ∂rootMeasure < 1 := by have he (v : V) : ∫ ω, badIndicator (W v) ω ∂rootMeasure ≤ k * (19 / 20 : ℝ) ^ (k - 1) := by simpa only [hW] using integral_badIndicator_le (W v) (Finset.card_pos.mp (by rw [hW v]; exact hk)) have sumle : ∑ v : V, (∫ ω, badIndicator (W v) ω ∂rootMeasure) ≤ (Fintype.card V : ℝ) * k * (19 / 20 : ℝ) ^ (k - 1) := by calc _ ≤ ∑ _v : V, (k : ℝ) * (19 / 20 : ℝ) ^ (k - 1) := Finset.sum_le_sum (fun v _ => he v) _ = _ := by simp; ring have hc : (10 / Fintype.card V : ℝ) * ((Fintype.card V : ℝ) / 20) = 1 / 2 := by field_simp ; ring dsimp [F] rw [integral_add (integrable_selected_card.const_mul _) (integrable_finsetSum _ (fun v _ => integrable_badIndicator (W v))), integral_const_mul, integral_selected_card, integral_finsetSum _ (fun v _ => integrable_badIndicator (W v)), hc] linarith have hex : ∃ ω, F ω < 1 := by by_contra h push Not at h have hle := integral_mono (integrable_const (1 : ℝ)) hFi h simp only [integral_const] at hle simp at hle linarith obtain ⟨ω, hω⟩ := hex have hsum : 0 ≤ ∑ v : V, badIndicator (W v) ω := Finset.sum_nonneg (fun v _ => badIndicator_nonneg _ _) have hcost : 0 ≤ (10 / Fintype.card V : ℝ) * (selected ω).card := by positivity refine ⟨selected ω, ?_, ?_⟩ · have ht : (10 / Fintype.card V : ℝ) * (selected ω).card < 1 := by dsimp [F] at hω; linarith have hcard : (10 : ℝ) * (selected ω).card ≤ Fintype.card V := by have := (mul_lt_mul_iff_right₀ hnpos).mpr ht field_simp at this nlinarith exact_mod_cast hcard · intro v by_contra hv have hbad : badIndicator (W v) ω = 1 := by simp [badIndicator, show (W v ∩ selected ω).card < 2 by omega] have hle := Finset.single_le_sum (f := fun v => badIndicator (W v) ω) (fun v _ => badIndicator_nonneg _ _) (Finset.mem_univ v) rw [hbad] at hle dsimp [F] at hω linarith
section WitnessMatching
variable {E N D : Type*} [DecidableEq E] [DecidableEq N] [DecidableEq D]
theorem exists_distinct_witnesses (s : Finset E) (neighbor : E → N) (direction : E → D) (K : ℕ) (hn : ∀ n, (s.filter (fun e => neighbor e = n)).card ≤ K) (hd : ∀ d, (s.filter (fun e => direction e = d)).card ≤ K) : ∃ t ⊆ s, Set.InjOn neighbor (t : Set E) ∧ Set.InjOn direction (t : Set E) ∧ s.card ≤ 2 * K * t.card := by classical let family : Finset (Finset E) := s.powerset.filter (fun t => Set.InjOn neighbor (t : Set E) ∧ Set.InjOn direction (t : Set E)) have hempty : ∅ ∈ family := by simp [family, Set.injOn_empty] obtain ⟨t, htf, hmax⟩ := Finset.exists_max_image family Finset.card ⟨∅, hempty⟩ have ht : t ⊆ s := Finset.mem_powerset.mp (Finset.mem_filter.mp htf).1 have hinj := (Finset.mem_filter.mp htf).2 have hcover (e : E) (he : e ∈ s) : ∃ a ∈ t, neighbor e = neighbor a ∨ direction e = direction a := by by_contra h push Not at h have hen : e ∉ t := by intro het exact (h e het).1 rfl have hnnew : Set.InjOn neighbor (↑(insert e t) : Set E) := by rw [Finset.coe_insert, Set.injOn_insert hen] refine ⟨hinj.1, ?_⟩ rintro ⟨a, ha, hea⟩ exact (h a ha).1 hea.symm have hdnew : Set.InjOn direction (↑(insert e t) : Set E) := by rw [Finset.coe_insert, Set.injOn_insert hen] refine ⟨hinj.2, ?_⟩ rintro ⟨a, ha, hea⟩ exact (h a ha).2 hea.symm have hnew : insert e t �� family := by simp only [family, Finset.mem_filter, Finset.mem_powerset] exact ⟨Finset.insert_subset he ht, hnnew, hdnew⟩ have := hmax _ hnew rw [Finset.card_insert_of_notMem hen] at this omega refine ⟨t, ht, hinj.1, hinj.2, ?_⟩ have hsub : s ⊆ t.biUnion (fun a => (s.filter (fun e => neighbor e = neighbor a)) ∪ (s.filter (fun e => direction e = direction a))) := by intro e he obtain ⟨a, ha, hor⟩ := hcover e he apply Finset.mem_biUnion.mpr refine ⟨a, ha, ?_⟩ simpa only [Finset.mem_union, Finset.mem_filter, and_or_left] using And.intro he hor calc s.card ≤ _ := Finset.card_le_card hsub _ ≤ ∑ a ∈ t, ((s.filter (fun e => neighbor e = neighbor a)) ∪ (s.filter (fun e => direction e = direction a))).card := Finset.card_biUnion_le _ ≤ ∑ _a ∈ t, 2 * K := by apply Finset.sum_le_sum intro a ha exact (Finset.card_union_le _ _).trans (by have := hn (neighbor a); have := hd (direction a); omega) _ = 2 * K * t.card := by simp [Nat.mul_comm]
end WitnessMatchingend SharpRamseyFive.ResidualCertificateend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454import Mathlibimport OAI.Combinatorics.SharpRamsey.Entropy.ShiftKernelSum
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen scoped BigOperatorsopen MeasureTheory ProbabilityTheoryopen scoped BigOperators ENNReal NNRealnamespace SharpRamseyFive.ResidualEliminationopen scoped BigOperatorsopen Classicalvariable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]omit [Fintype V] [Fintype H] [DecidableEq H] inlemma patch_notMem (g : V → H) (T : Finset V) (x : T → H) (u : V) (hu : u ∉ T) : patch g T x u = g u := by simp [patch, hu]omit [Fintype V] [Fintype H] [DecidableEq H] in
lemma agrees_sdiff_patch (E T : Finset V) (hT : T ⊆ E) (g f : V → H) (x : T → H) : Agrees (E \ T) (patch g T x) f ↔ Agrees E g f ∧ x = fun u : T => f u := by constructor · intro h constructor · intro u hu have hnu : u ∉ T := fun hh => hu (hT hh) simpa only [patch_notMem g T x u hnu] using h u (by simp [hu]) · funext u have hu := h u (by simp) simpa only [patch_mem] using hu.symm · rintro ⟨h,rfl⟩ u hu by_cases hnu : u ∈ T · simp [patch, hnu] · rw [patch_notMem g T _ u hnu] exact h u (by simpa [hnu] using hu)
lemma completionSum_split (E T : Finset V) (hT : T ⊆ E) (g : V → H) (F : (V → H) → ℝ) : completionSum E g F = ∑ x : T → H, completionSum (E \ T) (patch g T x) F := by unfold completionSum rw [Finset.sum_comm] apply Finset.sum_congr rfl intro f _ simp only [agrees_sdiff_patch E T hT] by_cases hf : Agrees E g f <;> simp [hf]
theorem weighted_block_exposure (E T : Finset V) (hT : T ⊆ E) (g : V → H) (w : (T → H) → ℝ) (hw : ∀ x, 0 ≤ w x) (F : (V → H) → ℝ) (C : ℝ) (hF : ∀ g, completionSum (E \ T) g F ≤ C) : completionSum E g (fun f => w (fun u : T => f u) * F f) ≤ (∑ x : T → H, w x) * C := by rw [completionSum_split E T hT, Finset.sum_mul] apply Finset.sum_le_sum intro x _ calc _ = completionSum (E \ T) (patch g T x) (fun f => w x * F f) := by apply completionSum_congr intro f hf have hx := (agrees_sdiff_patch E T hT g f x).mp hf rw [← hx.2] _ = w x * completionSum (E \ T) (patch g T x) F := completionSum_mul .. _ ≤ _ := mul_le_mul_of_nonneg_left (hF _) (hw x)
theorem independent_positions_exposure (E T : Finset V) (hT : T ⊆ E) (g : V → H) (w : V → H → ℝ) (hw : ∀ u h, 0 ≤ w u h) (F : (V → H) → ℝ) (C : ℝ) (hF : ∀ g, completionSum (E \ T) g F ≤ C) : completionSum E g (fun f => (∏ u ∈ T, w u (f u)) * F f) ≤ (∏ u ∈ T, ∑ h : H, w u h) * C := by let W : (T → H) → ℝ := fun x => ∏ u : T, w u (x u) have hW : ∀ x, 0 ≤ W x := by intro x exact Finset.prod_nonneg (fun u _ => hw _ _) have he (f : V → H) : (∏ u ∈ T, w u (f u)) = W (fun u : T => f u) := by exact (Finset.prod_coe_sort T (fun u => w u (f u))).symm simp_rw [he] apply (weighted_block_exposure E T hT g W hW F C hF).trans_eq have hs : (∑ x : T → H, W x) = ∏ u ∈ T, ∑ h : H, w u h := by rw [show (∑ x : T → H, W x) = ∏ u : T, ∑ h : H, w u h from (Fintype.prod_sum (fun u : T => w u)).symm] exact Finset.prod_coe_sort T (fun u => ∑ h : H, w u h) rw [hs]
end SharpRamseyFive.ResidualElimination
namespace SharpRamseyFive.ResidualEliminationopen scoped BigOperatorsopen Classicalvariable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
omit [Fintype V] inlemma powerset_sdiff (E U : Finset V) : (E \ U).powerset = E.powerset.filter (fun S => Disjoint S U) := by ext S simp only [Finset.mem_powerset, Finset.mem_filter] constructor · intro h refine ⟨h.trans Finset.sdiff_subset, Finset.disjoint_left.mpr ?_⟩ intro u hu hU exact (Finset.mem_sdiff.mp (h hu)).2 hU · rintro ⟨h,hD⟩ u hu exact Finset.mem_sdiff.mpr ⟨h hu, fun hU => Finset.disjoint_left.mp hD hu hU⟩omit [Fintype V] in
lemma sum_disjoint_swap (E : Finset V) (F : Finset V → Finset V → ℝ) : (∑ U ∈ E.powerset, ∑ S ∈ (E \ U).powerset, F U S) = ∑ S ∈ E.powerset, ∑ U ∈ (E \ S).powerset, F U S := by simp_rw [powerset_sdiff, Finset.sum_filter] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro S hS apply Finset.sum_congr rfl intro U hU simp only [disjoint_comm]
noncomputable def badExpansion (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (E : Finset V) (f : V → H) : ℝ := ∑ U ∈ E.powerset, (∏ u ∈ E \ U, a u f) * B U f
omit [Fintype V] [Fintype H] [DecidableEq H] inlemma badExpansion_nonneg (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (ha : ∀ u f, 0 ≤ a u f) (hB : ∀ E f, 0 ≤ B E f) (E : Finset V) (f : V → H) : 0 ≤ badExpansion a B E f := by apply Finset.sum_nonneg intro U hU exact mul_nonneg (Finset.prod_nonneg (fun u _ => ha u f)) (hB U f)
omit [Fintype H] [DecidableEq H] inomit [Fintype V] inlemma badExpansion_add (a d : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (E : Finset V) (f : V → H) : badExpansion (fun u f => d u f + a u f) B E f = ∑ S ∈ E.powerset, (∏ u ∈ S, d u f) * badExpansion a B (E \ S) f := by unfold badExpansion simp_rw [Finset.prod_add, Finset.sum_mul] rw [sum_disjoint_swap] apply Finset.sum_congr rfl intro S hS rw [Finset.mul_sum] apply Finset.sum_congr rfl intro U hU have he : (E \ U) \ S = (E \ S) \ U := sdiff_sdiff_comm rw [he, mul_assoc]omit [DecidableEq H] in
lemma badExpansion_sum_le (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) (E : Finset V) (g : V → H) (M : ℝ) (_hM : 0 ≤ M) (hterm : ∀ S, S ⊆ E → completionSum E g (term a B E S) ≤ M ^ E.card) : completionSum E g (badExpansion a B E) ≤ (2 * M) ^ E.card := by rw [show badExpansion a B E = (fun f => ∑ U ∈ E.powerset, (∏ u ∈ E \ U, a u f) * B U f) from rfl, completionSum_sum] calc _ ≤ ∑ _U ∈ E.powerset, M ^ E.card := by apply Finset.sum_le_sum intro U hU have hU : U ⊆ E := Finset.mem_powerset.mp hU have he : E \ (E \ U) = U := Finset.sdiff_sdiff_eq_self hU have ht := hterm (E \ U) Finset.sdiff_subset change completionSum E g (fun f => (∏ u ∈ E \ U, a u f) * B (E \ (E \ U)) f) ≤ M ^ E.card at ht simpa only [he] using ht _ = _ := by simp [mul_pow]
theorem all_singleton_enumeration (a : V → (V → H) → ℝ) (d : V → H → ℝ) (B : Finset V → (V → H) → ℝ) (W : H → H → ℝ) (C D : ℝ) (hC : 0 ≤ C) (_hD : 0 ≤ D) (ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1) (hd : ∀ u x, 0 ≤ d u x) (hsum : ∀ u, (∑ x : H, d u x) ≤ D) (hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f) (hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f) (hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v)) (hrow : ∀ y, (∑ x : H, W x y) ≤ C) (hpair : (∑ x : H, ∑ y : H, W x y) ≤ C ^ 2) (hbad : ∀ A g, completionSum A g (B A) ≤ C ^ A.card) (E : Finset V) (g : V → H) : completionSum E g (badExpansion (fun u f => d u (f u) + a u f) B E) ≤ (D + 2 * ((Fintype.card V + 1 : ℝ) * C)) ^ E.card := by let M : ℝ := (Fintype.card V + 1) * C have hM : 0 ≤ M := by dsimp [M]; positivity have hbnd (A : Finset V) (g : V → H) : completionSum A g (badExpansion a B A) ≤ (2 * M) ^ A.card := by apply badExpansion_sum_le a B A g M hM intro S hS exact shift_bad_enumeration a B W C hC ha hW hB hmono hshift hrow hpair hbad A S hS g have he : badExpansion (fun u f => d u (f u) + a u f) B E = fun f => ∑ S ∈ E.powerset, (∏ u ∈ S, d u (f u)) * badExpansion a B (E \ S) f := by funext f exact badExpansion_add a (fun u f => d u (f u)) B E f rw [he, completionSum_sum] calc _ ≤ ∑ S ∈ E.powerset, D ^ S.card * (2 * M) ^ (E \ S).card := by apply Finset.sum_le_sum intro S hS apply (independent_positions_exposure E S (Finset.mem_powerset.mp hS) g d hd (badExpansion a B (E \ S)) ((2 * M) ^ (E \ S).card) (hbnd (E \ S))).trans apply mul_le_mul_of_nonneg_right _ (pow_nonneg (by positivity) _) calc (∏ u ∈ S, ∑ x : H, d u x) ≤ ∏ _u ∈ S, D := Finset.prod_le_prod₀ (fun u _ => Finset.sum_nonneg (fun x _ => hd u x)) (fun u _ => hsum u) _ = _ := Finset.prod_const _ _ = (D + 2 * M) ^ E.card := by have := Finset.prod_add (fun _ : V => D) (fun _ => 2 * M) E simpa only [Finset.prod_const] using this.symm
end SharpRamseyFive.ResidualElimination
namespace SharpRamseyFive.SingletonEnumerationopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignationsopen SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedProgramsopen SharpRamseyFive.ResidualEliminationopen Classicalvariable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
noncomputable def independentWeight (weight rate : D → ℝ≥0) (lines : H → Finset D) (R J : ℕ) (base : ℝ) (h : H) : ℝ := |mass weight (lines h) - base| ^ (R / 2) + (if R < J then 0 else ∑ d ∈ lines h, ((R : ℝ) * (rate d : ℝ)) ^ J)
omit [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H] inlemma independentWeight_nonneg (weight rate : D → ℝ≥0) (lines : H → Finset D) (R J : ℕ) (base : ℝ) (h : H) : 0 ≤ independentWeight weight rate lines R J base h := by unfold independentWeight split_ifs <;> positivity
theorem actual_all_singleton_enumeration (weight rate : D → ℝ≥0) (lines : H → Finset D) {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) (R : ℕ) (denom b mass C D₀ base : ℝ) (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hC : 0 ≤ C) (hD : 0 ≤ D₀) (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) (hN₂ : ∀ d e, d ≠ e → (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) (hBC : denom * (1 + branchingBound (V := V) (B := Fin R) (fun z : H × V => lines z.1) rate denom b mass K (N₁ * Fintype.card V) (N₂ * Fintype.card V) low) ≤ C) (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) (hDsum : (∑ x : H, independentWeight weight rate lines R J base x) ≤ D₀) (E : Finset V) (g : V → H) : completionSum E g (badExpansion (fun u f => independentWeight weight rate lines R J base (f u) + alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K) (fun A f => vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J A) E) ≤ (D₀ + 2 * ((Fintype.card V + 1 : ℝ) * C)) ^ E.card := by apply all_singleton_enumeration (fun u f => alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K) (fun _ x => independentWeight weight rate lines R J base x) (fun A f => vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J A) (shiftKernel weight lines p K) C D₀ hC hD · intro u f exact ⟨pow_nonneg (alpha_nonneg _ _ _ _) _, pow_le_one₀ (alpha_nonneg _ _ _ _) (by have := source_alpha_le weight (lines ∘ f) hp hc u linarith)⟩ · exact fun _ x => independentWeight_nonneg weight rate lines R J base x · exact fun _ => hDsum · exact fun x y => (shiftKernel_range weight lines p K x y).1 · exact fun A f => vertexBadMass_nonneg _ _ _ _ _ _ _ · exact fun A A' hh f => vertexBadMass_antitone _ _ _ _ _ _ hh · exact fun u f => shift_le_kernel_sum weight lines hp hc (by omega) u f · exact hrow · exact hpair · intro A g apply (actual_bad_completion weight rate lines (1 / (100 * p)) R denom b mass hd hb hm hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ A g).trans apply pow_le_pow_left₀ _ hBC apply mul_nonneg hd.le have hn := branchingBound_nonneg (V := V) (B := Fin R) (fun z : H × V => lines z.1) rate denom b mass hd.le (by linarith) hm K (N₁ * Fintype.card V) (N₂ * Fintype.card V) low linarith
end SharpRamseyFive.SingletonEnumeration
namespace SharpRamseyFive.SingletonEnumerationopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponentsopen SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignationsopen SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedProgramsopen SharpRamseyFive.ResidualEliminationopen Classicalvariable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
lemma inside_sum_le {C : Type} [Fintype C] [DecidableEq C] (label : D → Option C) (c : C) (S : Finset D) (F : D → ℝ) (hF : ∀ d, 0 ≤ F d) : (∑ d ∈ inside label c S, F d) ≤ ∑ d ∈ S, F d := by have hi : Function.Injective (Subtype.val : IntDir label c → D) := Subtype.val_injective rw [← Finset.sum_image (hi.injOn)] apply Finset.sum_le_sum_of_subset_of_nonneg · intro d hd rcases Finset.mem_image.mp hd with ⟨e,he,rfl⟩ exact (Finset.mem_filter.mp he).2 · exact fun d _ _ => hF d
omit [Fintype H] [DecidableEq H] inlemma extraWeight_le_independent (weight : D → ℝ≥0) (lines : H → Finset D) (f : V → H) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (c : Components weight (lines ∘ f) t) : extraWeight weight (lines ∘ f) t R J K L base c ≤ independentWeight weight (fun d => L * weight d) lines R J base (f (vertex weight (lines ∘ f) t c)) + alpha weight (lines ∘ f) t (vertex weight (lines ∘ f) t c) ^ K := by unfold extraWeight independentWeight delta have h := inside_sum_le (componentLabel weight (lines ∘ f) t) c ((lines ∘ f) (vertex weight (lines ∘ f) t c)) (fun d => ((R : ℝ) * ((L * weight d : ℝ≥0) : ℝ)) ^ J) (fun _ => by positivity) dsimp only [Function.comp_def] at * split_ifs <;> linarith
omit [Fintype H] [DecidableEq H] in
theorem designation_sum_le_vertex (weight : D → ℝ≥0) (lines : H → Finset D) (f : V → H) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) : let s := lines ∘ f let S := simpleSet weight s t let E := S.image (vertex weight s t) (∑ U ∈ S.powerset, (∏ c ∈ S \ U, extraWeight weight s t R J K L base c) * badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => L * weight i.1.2)) (blockTrunc (componentLabel weight s t) R J none) (isBad weight s t R) U) ≤ badExpansion (fun u f => independentWeight weight (fun d => L * weight d) lines R J base (f u) + alpha weight (lines ∘ f) t u ^ K) (fun A f => vertexBadMass weight (fun d => L * weight d) (lines ∘ f) t R J A) E f := by dsimp only unfold badExpansion rw [Finset.powerset_image, Finset.sum_image (Finset.image_injective (vertex_injective weight (lines ∘ f) t)).injOn] apply Finset.sum_le_sum intro U hU rw [← Finset.image_sdiff _ _ (vertex_injective weight (lines ∘ f) t), Finset.prod_image (vertex_injective weight (lines ∘ f) t).injOn, component_bad_mass_eq_vertex weight (fun d => L * weight d) (lines ∘ f) t R J U] apply mul_le_mul_of_nonneg_right _ (vertexBadMass_nonneg _ _ _ _ _ _ _) apply Finset.prod_le_prod₀ · exact fun c _ => extraWeight_nonneg _ _ _ _ _ _ _ _ c · exact fun c _ => extraWeight_le_independent weight lines f t R J K L base c
end SharpRamseyFive.SingletonEnumeration
namespace SharpRamseyFive.ResidualEliminationopen scoped BigOperatorsopen Classicalvariable {V H C : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [DecidableEq C]
theorem disjoint_blocks_exposure (E : Finset V) (I : Finset C) (T : C → Finset V) (Win : (c : C) → (T c → H) → ℝ) (M : C → ℝ) (hw : ∀ c x, 0 ≤ Win c x) (hM : ∀ c, 0 ≤ M c) (hwithin : ∀ c ∈ I, T c ⊆ E) (hdisj : ∀ c ∈ I, ∀ d ∈ I, c ≠ d → Disjoint (T c) (T d)) (hsum : ∀ c ∈ I, (∑ x : T c → H, Win c x) ≤ M c) (F : (V → H) → ℝ) (K : ℝ) (hK : 0 ≤ K) (hres : ∀ g, completionSum (E \ I.biUnion T) g F ≤ K) (g : V → H) : completionSum E g (fun f => (∏ c ∈ I, Win c (fun v => f v)) * F f) ≤ (∏ c ∈ I, M c) * K := by induction I using Finset.induction generalizing E g with | empty => simpa using hres g | @insert c I hc ih => have hwi : T c ⊆ E := hwithin c (Finset.mem_insert_self c I) have hrwithin : ∀ d ∈ I, T d ⊆ E \ T c := by intro d hd v hv refine Finset.mem_sdiff.mpr ⟨hwithin d (Finset.mem_insert_of_mem hd) hv, ?_⟩ intro hvc exact Finset.disjoint_left.mp (hdisj d (Finset.mem_insert_of_mem hd) c (Finset.mem_insert_self _ _) (by intro he; subst d; exact hc hd)) hv hvc have he : (E \ T c) \ I.biUnion T = E \ (insert c I).biUnion T := by ext v simp only [Finset.mem_sdiff, Finset.biUnion_insert, Finset.mem_union] tauto have hr (g : V → H) : completionSum (E \ T c) g (fun f => (∏ d ∈ I, Win d (fun v => f v)) * F f) ≤ (∏ d ∈ I, M d) * K := by apply ih (E \ T c) hrwithin (fun d hd e he hne => hdisj d (Finset.mem_insert_of_mem hd) e (Finset.mem_insert_of_mem he) hne) (fun d hd => hsum d (Finset.mem_insert_of_mem hd)) intro g rw [he] exact hres g simp_rw [Finset.prod_insert hc, mul_assoc] apply (weighted_block_exposure E (T c) hwi g (Win c) (hw c) (fun f => (∏ d ∈ I, Win d (fun v => f v)) * F f) ((∏ d ∈ I, M d) * K) hr).trans exact mul_le_mul_of_nonneg_right (hsum c (Finset.mem_insert_self _ _)) (mul_nonneg (Finset.prod_nonneg (fun d _ => hM d)) hK)
end SharpRamseyFive.ResidualElimination
namespace SharpRamseyFive.ComponentPartitionopen scoped BigOperatorsopen Classicalvariable {V C : Type} [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]
noncomputable def fiber (r : V → C) (c : C) : Finset V := Finset.univ.filter (fun v => r v = c)noncomputable def singles (r : V → C) : Finset V := Finset.univ.filter (fun v => (fiber r (r v)).card = 1)noncomputable def largeLabels (r : V → C) : Finset C := Finset.univ.filter (fun c => 2 ≤ (fiber r c).card)
omit [DecidableEq V] [Fintype C] in@[simp] lemma mem_fiber (r : V → C) (c : C) (v : V) : v ∈ fiber r c ↔ r v = c := by simp [fiber]omit [DecidableEq V] [Fintype C] in@[simp] lemma mem_singles (r : V → C) (v : V) : v ∈ singles r ↔ (fiber r (r v)).card = 1 := by simp [singles]omit [DecidableEq V] in@[simp] lemma mem_largeLabels (r : V → C) (c : C) : c ∈ largeLabels r ↔ 2 ≤ (fiber r c).card := by simp [largeLabels]omit [DecidableEq V] [Fintype C] in
lemma self_mem_fiber (r : V → C) (v : V) : v ∈ fiber r (r v) := by simpomit [DecidableEq V] [Fintype C] inlemma fiber_card_pos (r : V → C) (v : V) : 0 < (fiber r (r v)).card := Finset.card_pos.mpr ⟨v,self_mem_fiber r v⟩omit [DecidableEq V] [Fintype C] in
lemma fiber_disjoint (r : V → C) {c d : C} (hne : c ≠ d) : Disjoint (fiber r c) (fiber r d) := by apply Finset.disjoint_left.mpr intro v hc hd exact hne ((mem_fiber r c v).mp hc |>.symm.trans ((mem_fiber r d v).mp hd))
lemma large_union (r : V → C) : (largeLabels r).biUnion (fiber r) = Finset.univ \ singles r := by ext v simp only [Finset.mem_biUnion, mem_largeLabels, mem_fiber, Finset.mem_sdiff, Finset.mem_univ, true_and, mem_singles] constructor · rintro ⟨c,hc,he⟩ rw [he] omega · intro hv exact ⟨r v,by have := fiber_card_pos r v; omega,rfl⟩end SharpRamseyFive.ComponentPartitionend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465import Mathlib
namespace OAI
/-! High moments, finite-field subspaces, and incidence bounds. -/
sectionopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealopen MeasureTheory ProbabilityTheoryopen scoped BigOperators NNRealnamespace SharpRamseyFive.StaticCertificatesvariable {ι : Type*} [Fintype ι] [DecidableEq ι]noncomputable def poissonLaw (rate : ι → ℝ≥0) : Measure (ι → ℕ) := Measure.pi (fun i => poissonMeasure (rate i))
instance flat_HighMomentRecovered_3 (rate : ι → ℝ≥0) : IsProbabilityMeasure (poissonLaw rate) := by unfold poissonLaw infer_instance
def positiveEvent (C : Finset ι) : Set (ι → ℕ) := (C : Set ι).pi (fun _ => ({0} : Set ℕ)ᶜ)
noncomputable def certificateIndicator (C : Finset ι) (ω : ι → ℕ) : ℝ := (positiveEvent C).indicator (fun _ => 1) ω
noncomputable def weight (rate : ι → ℝ≥0) (C : Finset ι) : ℝ := ∏ i ∈ C, (rate i : ℝ)
omit [Fintype ι] [DecidableEq ι] inlemma measurableSet_positiveEvent (C : Finset ι) : MeasurableSet (positiveEvent C) := MeasurableSet.pi C.finite_toSet.countable (fun _ _ => (measurableSet_singleton 0).compl)omit [DecidableEq ι] in
lemma integrable_certificateIndicator (rate : ι → ℝ≥0) (C : Finset ι) : Integrable (certificateIndicator C) (poissonLaw rate) := (integrable_const (1 : ℝ)).indicator (measurableSet_positiveEvent C)
omit [Fintype ι] [DecidableEq ι] inlemma indicator_nonneg (C : Finset ι) (ω : ι → ℕ) : 0 ≤ certificateIndicator C ω := by exact Set.indicator_nonneg (fun _ _ => zero_le_one) _omit [DecidableEq ι] in
lemma integral_certificateIndicator (rate : ι → ℝ≥0) (C : Finset ι) : (∫ ω, certificateIndicator C ω ∂poissonLaw rate) = ∏ i ∈ C, (1 - Real.exp (-(rate i : ℝ))) := by unfold certificateIndicator rw [integral_indicator_const _ (measurableSet_positiveEvent C)] simp only [smul_eq_mul, mul_one] rw [Measure.real, poissonLaw, positiveEvent, Measure.pi_pi_finset, ENNReal.toReal_prod] apply Finset.prod_congr rfl intro i _ rw [← Measure.real, measureReal_compl (measurableSet_singleton 0), probReal_univ, Measure.real, poissonMeasure_singleton] simp only [pow_zero, Nat.factorial_zero, Nat.cast_one, mul_one, div_one] rw [ENNReal.toReal_ofReal (Real.exp_pos _).le]omit [DecidableEq ι] in
lemma integral_certificateIndicator_le (rate : ι → ℝ≥0) (C : Finset ι) : (∫ ω, certificateIndicator C ω ∂poissonLaw rate) ≤ weight rate C := by rw [integral_certificateIndicator] apply Finset.prod_le_prod₀ · intro i _ have he := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (rate i).coe_nonneg) linarith · intro i _ have he := Real.add_one_le_exp (-(rate i : ℝ)) linarith
omit [Fintype ι] [DecidableEq ι] inlemma weight_nonneg (rate : ι → ℝ≥0) (C : Finset ι) : 0 ≤ weight rate C := by exact Finset.prod_nonneg (fun i _ => (rate i).coe_nonneg)
omit [Fintype ι] in
lemma weight_union (rate : ι → ℝ≥0) (C D : Finset ι) : weight rate (C ∪ D) = weight rate C * weight rate (D \ C) := by unfold weight rw [← Finset.prod_union (Finset.disjoint_sdiff)] congr 1 ext i simp only [Finset.mem_union, Finset.mem_sdiff] tauto
omit [Fintype ι] inlemma positiveEvent_union (C D : Finset ι) : positiveEvent (C ∪ D) = positiveEvent C ∩ positiveEvent D := by ext ω simp [positiveEvent, Set.mem_pi, or_imp, forall_and]
omit [DecidableEq ι] in
theorem static_union_bound {κ : Type*} (D : Finset κ) (requirements : κ → Finset ι) (rate : ι → ℝ≥0) (E : Set (ι → ℕ)) (hE : MeasurableSet E) (hcover : ∀ ω ∈ E, ∃ c ∈ D, ω ∈ positiveEvent (requirements c)) : (poissonLaw rate).real E ≤ ∑ c ∈ D, weight rate (requirements c) := by have hp (ω : ι → ℕ) : E.indicator (fun _ => (1 : ℝ)) ω ≤ ∑ c ∈ D, certificateIndicator (requirements c) ω := by by_cases hω : ω ∈ E · obtain ⟨c, hc, he⟩ := hcover ω hω have := Finset.single_le_sum (f := fun c => certificateIndicator (requirements c) ω) (fun c _ => indicator_nonneg _ _) hc simpa [certificateIndicator, he, hω] using this · simp only [Set.indicator_of_notMem hω] exact Finset.sum_nonneg (fun c _ => indicator_nonneg _ _) calc _ = ∫ ω, E.indicator (fun _ => (1 : ℝ)) ω ∂poissonLaw rate := by rw [integral_indicator_const _ hE] simp _ ≤ ∫ ω, ∑ c ∈ D, certificateIndicator (requirements c) ω ∂poissonLaw rate := integral_mono ((integrable_const (1 : ℝ)).indicator hE) (integrable_finsetSum _ (fun c _ => integrable_certificateIndicator _ _)) hp _ = ∑ c ∈ D, ∫ ω, certificateIndicator (requirements c) ω ∂poissonLaw rate := integral_finsetSum _ (fun c _ => integrable_certificateIndicator _ _) _ ≤ _ := Finset.sum_le_sum (fun c _ => integral_certificateIndicator_le _ _)
section PairWitnesses
variable {κ : Type*} [Fintype κ] [DecidableEq κ]
def witnessRequirements (T : Finset κ) (S : Finset ι) (f : T → S) : Finset (κ × ι) := T.attach.image (fun r => (r.val, (f r).val))
omit [Fintype ι] [Fintype κ] inlemma witnessRequirements_card (T : Finset κ) (S : Finset ι) (f : T → S) : (witnessRequirements T S f).card = T.card := by rw [witnessRequirements, Finset.card_image_of_injective] · exact Finset.card_attach · intro a b h exact Subtype.ext (congrArg Prod.fst h)
omit [Fintype ι] [Fintype κ] inlemma witness_weight (rate : ι → ℝ≥0) (T : Finset κ) (S : Finset ι) (f : T → S) : weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f) = ∏ r : T, (rate (f r) : ℝ) := by unfold weight witnessRequirements rw [Finset.prod_image] · rw [Finset.univ_eq_attach T] · intro a _ b _ h exact Subtype.ext (congrArg Prod.fst h)omit [Fintype ι] [Fintype κ] in
lemma sum_witness_weight (rate : ι → ℝ≥0) (T : Finset κ) (S : Finset ι) : (∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) = (∑ i ∈ S, (rate i : ℝ)) ^ T.card := by simp_rw [witness_weight] rw [← Fintype.prod_sum (fun (_r : T) (i : S) => (rate i : ℝ))] rw [Finset.sum_coe_sort S (fun i => (rate i : ℝ))] simp
omit [Fintype ι] in
theorem pair_certificate_weight (rate : ι → ℝ≥0) (S : Finset ι) (K : ℕ) : (∑ T ∈ (Finset.univ : Finset κ).powersetCard K, ∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) = (Fintype.card κ).choose K * (∑ i ∈ S, (rate i : ℝ)) ^ K := by simp_rw [sum_witness_weight] calc _ = ∑ _T ∈ (Finset.univ : Finset κ).powersetCard K, (∑ i ∈ S, (rate i : ℝ)) ^ K := by apply Finset.sum_congr rfl intro T hT rw [(Finset.mem_powersetCard.mp hT).2] _ = _ := by simp
omit [Fintype ι] in
theorem pair_certificate_weight_le (rate : ι → ℝ≥0) (S : Finset ι) (K : ℕ) : (∑ T ∈ (Finset.univ : Finset κ).powersetCard K, ∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) ≤ ((Fintype.card κ : ℝ) * ∑ i ∈ S, (rate i : ℝ)) ^ K := by rw [pair_certificate_weight, mul_pow] apply mul_le_mul_of_nonneg_right · exact_mod_cast Nat.choose_le_pow (Fintype.card κ) K · positivity
omit [Fintype ι] [Fintype κ] in
theorem pair_witness_exists (S : Finset ι) (T : Finset κ) (ω : κ × ι → ℕ) (hT : ∀ r ∈ T, ∃ i ∈ S, ω (r, i) ≠ 0) : ∃ f : T → S, ω ∈ positiveEvent (witnessRequirements T S f) := by classical have h (r : T) : ∃ i : S, ω (r.val, i.val) ≠ 0 := by obtain ⟨i, hi, he⟩ := hT r r.property exact ⟨⟨i, hi⟩, he⟩ choose f hf using h refine ⟨f, ?_⟩ intro p hp obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp exact hf r
def dictionary (C : Finset (κ × ι)) : Finset ι := C.image Prod.snd
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma direction_mem_dictionary {C : Finset (κ × ι)} {r : κ} {i : ι} (h : (r, i) ∈ C) : i ∈ dictionary C := Finset.mem_image_of_mem _ homit [Fintype ι] [Fintype κ] in
lemma witnessRequirements_disjoint {C : Finset (κ × ι)} (T : Finset κ) (S : Finset ι) (f : T → S) (hnew : Disjoint S (dictionary C)) : Disjoint C (witnessRequirements T S f) := by apply Finset.disjoint_left.mpr intro p hp hp' obtain ⟨r, _, hr⟩ := Finset.mem_image.mp hp' have he := congrArg Prod.snd hr have hf : p.2 ∈ S := he ▸ (f r).property exact Finset.disjoint_left.mp hnew hf (direction_mem_dictionary hp)
omit [Fintype ι] [Fintype κ] inlemma weight_union_fresh (rate : κ × ι → ℝ≥0) (C D : Finset (κ × ι)) (hfresh : Disjoint C D) : weight rate (C ∪ D) = weight rate C * weight rate D := by exact Finset.prod_union hfresh
omit [Fintype ι] [Fintype κ] in
theorem pair_dictionary_extension (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (T : Finset κ) (S : Finset ι) (f : T → S) (hnew : Disjoint S (dictionary C)) : weight (fun p : κ × ι => rate p.2) (C ∪ witnessRequirements T S f) = weight (fun p : κ × ι => rate p.2) C * ∏ r : T, (rate (f r) : ℝ) := by rw [weight_union_fresh _ _ _ (witnessRequirements_disjoint T S f hnew), witness_weight]
def anchorRequirements (C : Finset (κ × ι)) (r : κ) (i : ι) : Finset (κ × ι) := if i ∈ dictionary C then ∅ else {(r, i)}omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
lemma anchorRequirements_disjoint (C : Finset (κ × ι)) (r : κ) (i : ι) : Disjoint C (anchorRequirements C r i) := by unfold anchorRequirements split_ifs with h · exact Finset.disjoint_empty_right _ · simp only [Finset.disjoint_singleton_right] exact fun hi => h (direction_mem_dictionary hi)
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma anchorRequirements_weight (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (r : κ) (i : ι) : weight (fun p : κ × ι => rate p.2) (anchorRequirements C r i) = if i ∈ dictionary C then 1 else (rate i : ℝ) := by unfold anchorRequirements weight split_ifs <;> simpomit [Fintype ι] [Fintype κ] in
lemma anchor_dictionary_extension (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (r : κ) (i : ι) : weight (fun p : κ × ι => rate p.2) (C ∪ anchorRequirements C r i) = weight (fun p : κ × ι => rate p.2) C * (if i ∈ dictionary C then 1 else (rate i : ℝ)) := by rw [weight_union_fresh _ _ _ (anchorRequirements_disjoint C r i), anchorRequirements_weight]omit [Fintype ι] [Fintype κ] in
lemma anchor_dictionary_subset (C : Finset (κ × ι)) (r : κ) (i : ι) : dictionary (C ∪ anchorRequirements C r i) ⊆ insert i (dictionary C) := by intro d hd obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hd rcases Finset.mem_union.mp hp with hp | hp · exact Finset.mem_insert_of_mem (direction_mem_dictionary hp) · unfold anchorRequirements at hp split_ifs at hp with h · simp at hp · have he := Finset.mem_singleton.mp hp rw [he] exact Finset.mem_insert_self _ _
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
lemma old_reference_has_hit (C : Finset (κ × ι)) (i : ι) (hi : i ∈ dictionary C) (ω : (κ × ι) → ℕ) (hω : ω ∈ positiveEvent C) : ∃ r, ω (r, i) ≠ 0 := by obtain ⟨p, hp, hpi⟩ := Finset.mem_image.mp hi refine ⟨p.1, ?_⟩ have hh := hω p hp simpa [← hpi] using hh
omit [Fintype ι] [DecidableEq κ] in
theorem anchor_choice_weight_le (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) : (∑ _i ∈ S ∩ dictionary C, (1 : ℝ)) + (∑ _r : κ, ∑ i ∈ S \ dictionary C, (rate i : ℝ)) ≤ (dictionary C).card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ) := by apply add_le_add · simp only [Finset.sum_const, nsmul_eq_mul, mul_one] exact_mod_cast Finset.card_le_card (Finset.inter_subset_right (s₁ := S)) · simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.sdiff_subset) (by intro i _ _; exact (rate i).coe_nonneg)
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma dictionary_card_le (C : Finset (κ × ι)) : (dictionary C).card ≤ C.card := Finset.card_image_le
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma anchorRequirements_card_le (C : Finset (κ × ι)) (r : κ) (i : ι) : (anchorRequirements C r i).card ≤ 1 := by unfold anchorRequirements split_ifs <;> simpomit [Fintype ι] [Fintype κ] in
lemma anchor_extension_card (C : Finset (κ × ι)) (r : κ) (i : ι) : (C ∪ anchorRequirements C r i).card ≤ C.card + 1 := (Finset.card_union_le _ _).trans (Nat.add_le_add_left (anchorRequirements_card_le C r i) _)omit [Fintype ι] [Fintype κ] in
lemma pair_extension_card (C : Finset (κ × ι)) (T : Finset κ) (S : Finset ι) (f : T → S) : (C ∪ witnessRequirements T S f).card ≤ C.card + T.card := by simpa only [witnessRequirements_card] using Finset.card_union_le C (witnessRequirements T S f)
abbrev AnchorChoice (C : Finset (κ × ι)) (S : Finset ι) := {i // i ∈ S ∩ dictionary C} ⊕ (κ × {i // i ∈ S \ dictionary C})
def AnchorChoice.direction {C : Finset (κ × ι)} {S : Finset ι} : AnchorChoice C S → ι | .inl d => d.val | .inr rd => rd.2.val
def AnchorChoice.requirements {C : Finset (κ × ι)} {S : Finset ι} : AnchorChoice C S → Finset (κ × ι) | .inl _ => ∅ | .inr rd => {(rd.1, rd.2.val)}
noncomputable def AnchorChoice.cost (rate : ι → ℝ≥0) {C : Finset (κ × ι)} {S : Finset ι} : AnchorChoice C S → ℝ | .inl _ => 1 | .inr rd => rate rd.2.val
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma AnchorChoice.cost_nonneg (rate : ι → ℝ≥0) {C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) : 0 ≤ x.cost rate := by cases x <;> simp [AnchorChoice.cost]
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma AnchorChoice.direction_mem {C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) : x.direction ∈ S := by cases x with | inl d => exact (Finset.mem_inter.mp d.property).1 | inr rd => exact (Finset.mem_sdiff.mp rd.2.property).1omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
lemma AnchorChoice.fresh {C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) : Disjoint C x.requirements := by cases x with | inl d => exact Finset.disjoint_empty_right _ | inr rd => apply Finset.disjoint_singleton_right.mpr intro he exact (Finset.mem_sdiff.mp rd.2.property).2 (direction_mem_dictionary he)
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma AnchorChoice.weight (rate : ι → ℝ≥0) {C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) : weight (fun p : κ × ι => rate p.2) x.requirements = x.cost rate := by cases x <;> simp [AnchorChoice.requirements, StaticCertificates.weight, AnchorChoice.cost]
omit [Fintype ι] [Fintype κ] [DecidableEq κ] inlemma AnchorChoice.distinct_events {C : Finset (κ × ι)} {S : Finset ι} (x y : AnchorChoice C S) (hne : x.direction ≠ y.direction) : Disjoint x.requirements y.requirements := by cases x with | inl d => exact Finset.disjoint_empty_left _ | inr rd => cases y with | inl d => exact Finset.disjoint_empty_right _ | inr re => apply Finset.disjoint_singleton_left.mpr simp only [AnchorChoice.requirements, Finset.mem_singleton] intro he exact hne (congrArg Prod.snd he)
omit [Fintype ι] [Fintype κ] in
lemma two_anchor_extension_weight (rate : ι → ℝ≥0) {C : Finset (κ × ι)} {S : Finset ι} (x y : AnchorChoice C S) (hne : x.direction ≠ y.direction) : weight (fun p : κ × ι => rate p.2) (C ∪ (x.requirements ∪ y.requirements)) = weight (fun p : κ × ι => rate p.2) C * (x.cost rate * y.cost rate) := by rw [weight_union_fresh _ _ _ (Finset.disjoint_union_right.mpr ⟨x.fresh, y.fresh⟩), weight_union_fresh _ _ _ (x.distinct_events y hne), x.weight rate, y.weight rate]
omit [Fintype ι] [DecidableEq κ] inlemma sum_anchor_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) : (∑ x : AnchorChoice C S, x.cost rate) = (S ∩ dictionary C).card + Fintype.card κ * ∑ i ∈ S \ dictionary C, (rate i : ℝ) := by rw [Fintype.sum_sum_type] simp only [AnchorChoice.cost, Finset.sum_const, Finset.card_univ, Fintype.card_coe, nsmul_eq_mul, mul_one, Fintype.sum_prod_type] rw [Finset.sum_coe_sort (S \ dictionary C) (fun i => (rate i : ℝ))]
omit [Fintype ι] [DecidableEq κ] in
theorem sum_anchor_cost_le (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) : (∑ x : AnchorChoice C S, x.cost rate) ≤ C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ) := by rw [sum_anchor_cost] apply add_le_add · exact_mod_cast (Finset.card_le_card (Finset.inter_subset_right (s₁ := S))).trans (dictionary_card_le C) · apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) exact Finset.sum_le_sum_of_subset_of_nonneg Finset.sdiff_subset (by intro i _ _; exact (rate i).coe_nonneg)
section AnchorGeometryvariable {H : Type*} [Fintype H] [DecidableEq H]
omit [DecidableEq H] inomit [Fintype ι] [DecidableEq κ] in
theorem one_anchor_geometric_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) (lineSet : H → Finset ι) (N₁ : ℕ) (hN : ∀ d, (Finset.univ.filter (fun H => d ∈ lineSet H)).card ≤ N₁) : (∑ x : AnchorChoice C S, x.cost rate * (Finset.univ.filter (fun H => x.direction ∈ lineSet H)).card) ≤ (N₁ : ℝ) * (C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ)) := by calc _ ≤ ∑ x : AnchorChoice C S, x.cost rate * N₁ := by apply Finset.sum_le_sum intro x _ apply mul_le_mul_of_nonneg_left _ (x.cost_nonneg rate) exact_mod_cast hN x.direction _ = (N₁ : ℝ) * ∑ x : AnchorChoice C S, x.cost rate := by rw [← Finset.sum_mul, mul_comm] _ ≤ _ := mul_le_mul_of_nonneg_left (sum_anchor_cost_le rate C S) (Nat.cast_nonneg _)
omit [DecidableEq H] inomit [Fintype ι] [DecidableEq κ] in
theorem two_anchor_geometric_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) (lineSet : H → Finset ι) (N₂ : ℕ) (hN : ∀ d e, d ≠ e → (Finset.univ.filter (fun H => d ∈ lineSet H ∧ e ∈ lineSet H)).card ≤ N₂) : (∑ x : AnchorChoice C S, ∑ y : AnchorChoice C S, if x.direction ≠ y.direction then x.cost rate * y.cost rate * (Finset.univ.filter (fun H => x.direction ∈ lineSet H ∧ y.direction ∈ lineSet H)).card else 0) ≤ (N₂ : ℝ) * (C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ)) ^ 2 := by classical let A : ℝ := ∑ x : AnchorChoice C S, x.cost rate have hA : 0 ≤ A := Finset.sum_nonneg (fun x _ => x.cost_nonneg rate) calc _ ≤ ∑ x : AnchorChoice C S, ∑ y : AnchorChoice C S, x.cost rate * y.cost rate * N₂ := by apply Finset.sum_le_sum intro x _ apply Finset.sum_le_sum intro y _ split_ifs with hxy · apply mul_le_mul_of_nonneg_left _ (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate)) exact_mod_cast hN x.direction y.direction hxy · exact mul_nonneg (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate)) (Nat.cast_nonneg _) _ = (N₂ : ℝ) * A ^ 2 := by simp only [Finset.sum_mul, Finset.mul_sum, A, pow_two] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ ring _ ≤ _ := by apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) exact pow_le_pow_left₀ hA (sum_anchor_cost_le rate C S) 2
end AnchorGeometryend PairWitnessesend SharpRamseyFive.StaticCertificatesend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import Mathlibimport OAI.Combinatorics.SharpRamsey.Marking.MarkingDeficit
namespace OAI
sectionnamespace SharpLogRamsey.Selectionopen Finset Realopen scoped Classicalnoncomputable sectionvariable {Ω α Γ : Type*} [Fintype Ω] [Fintype α] [Fintype Γ]
theorem entropy_append_alphabet (p : Law Ω) (C : Ω→Γ) (F : Ω→α) (D : Γ→Finset α) (hD : ∀ x,p.mass x≠0→F x∈D (C x)) : entropy (p.map (fun x=>(F x,C x))) ≤ entropy (p.map C)+ ∑ x,p.mass x*log (D (C x)).card := by rw [entropy_cond_chain,←p.sum_map C (fun c=>log (D c).card)] apply add_le_add le_rfl apply sum_le_sum intro c _ by_cases hc : (p.map C).mass c=0 · simp [hc] · apply mul_le_mul_of_nonneg_left _ ((p.map C).nonneg c) apply entropy_mapped_support intro x hx obtain ⟨hp,he⟩ := p.cond_support C c hc x hx simpa only [←he] using hD x hp
def ProtocolValid (D : ∀ n:ℕ,(Fin n→α)→Finset α) : ∀ n:ℕ,(Fin n→α)→Prop | 0,_ => True | n+1,x => ProtocolValid D n (Fin.init x) ∧ x (Fin.last n)∈D n (Fin.init x)
noncomputable def protocolCost (D : ∀ n:ℕ,(Fin n→α)→Finset α) : ∀ n:ℕ,(Fin n→α)→ℝ | 0,_ => 0 | n+1,x => protocolCost D n (Fin.init x)+log (D n (Fin.init x)).card
omit [Fintype Γ] in
theorem protocol_entropy (p : Law Ω) (D : ∀ n:ℕ,(Fin n→α)→Finset α) (n : ℕ) (F : Ω→Fin n→α) (hF : ∀ x,p.mass x≠0→ProtocolValid D n (F x)) : entropy (p.map F)≤∑ x,p.mass x*protocolCost D n (F x) := by induction n with | zero => have h := entropy_le_log_card (p.map F) univ (fun x hx=>False.elim (hx (mem_univ x))) simpa only [card_univ,Fintype.card_fun,Fintype.card_fin,pow_zero, Nat.cast_one,log_one,protocolCost,mul_zero,sum_const_zero] using h | succ n ih => let C := fun x=>Fin.init (F x) let a := fun x=>F x (Fin.last n) have hi := ih C (fun x hx=>(hF x hx).1) have ha := entropy_append_alphabet p C a (D n) (fun x hx=>(hF x hx).2) have he : entropy (p.map (fun x=>(a x,C x)))=entropy (p.map F) := by have h := entropy_map_eq_of_leftInverse (p.map F) (fun y:Fin (n+1)→α=>(y (Fin.last n),Fin.init y)) (fun z:α×(Fin n→α)=>Fin.snoc z.2 z.1) (fun y=>Fin.snoc_init_self y) rw [Law.map_map] at h exact h rw [he] at ha have hs : (∑ x,p.mass x*protocolCost D n (C x))+ (∑ x,p.mass x*log (D n (C x)).card)= ∑ x,p.mass x*protocolCost D (n+1) (F x) := by simp only [protocolCost,mul_add,sum_add_distrib,C] rw [←hs] linarith
omit [Fintype Γ] in
theorem protocol_entropy_maximum (p : Law Ω) (D : ∀ n:ℕ,(Fin n→α)→Finset α) (n : ℕ) (F : Ω→Fin n→α) (K : ℝ) (hF : ∀ x,p.mass x≠0→ProtocolValid D n (F x)) (hK : ∀ x,p.mass x≠0→protocolCost D n (F x)≤K) : entropy (p.map F)≤K := by apply (protocol_entropy p D n F hF).trans calc _ ≤ ∑ x,p.mass x*K := by apply sum_le_sum intro x _ by_cases hx : p.mass x=0 · simp [hx] · exact mul_le_mul_of_nonneg_left (hK x hx) (p.nonneg x) _ = K := by rw [←sum_mul,p.total,one_mul]
endend SharpLogRamsey.Selection
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114import Mathlibimport OAI.Combinatorics.SharpRamsey.Trees.PivotAlphabetCostimport OAI.Combinatorics.SharpRamsey.Trees.ChronologicalExecutionimport OAI.Combinatorics.SharpRamsey.Execution.ExecutedOverhead
namespace OAI
sectionnamespace SharpLogRamsey.ActualPivotopen Finset Real Incidence Validation ScheduledBanks PublicTables ReadyTests PivotGeometry ProjectiveDuality TreeDecoder FreshExecution ExecutedPotentialopen scoped Classical BigOperatorsnoncomputable sectionvariable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] {I Ω : Type*} [Fintype I] [Fintype Ω] {n : ℕ} {b τ P H : ℝ}
def Book.publicAlphabet (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) (z : I→Banks (K:=K) (V:=V) b) (U : ChronoDomains (K:=K) (V:=V)) : Finset (I×Code (K:=K) (V:=V) b) := univ.biUnion (fun i=>(book.allowed (z i).1 U.swap).image (fun c=>(i,c)))
variable (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3))
omit [Finite K] inlemma Book.mem_publicAlphabet (z : I→Banks (K:=K) (V:=V) b) (U : ChronoDomains (K:=K) (V:=V)) (i : I) (c : Code (K:=K) (V:=V) b) (hc : c∈book.allowed (z i).1 U.swap) : (i,c)∈book.publicAlphabet z U := by exact mem_biUnion.mpr ⟨i,mem_univ _,mem_image.mpr ⟨c,hc,rfl⟩⟩
omit [Finite K] inlemma Book.publicAlphabet_card (z : I→Banks (K:=K) (V:=V) b) (U : ChronoDomains (K:=K) (V:=V)) : (book.publicAlphabet z U).card≤∑ i,(book.allowed (z i).1 U.swap).card := by apply (card_biUnion_le).trans exact sum_le_sum (fun i _=>card_image_le)
variable (hb : 0≤b) (hH : 0≤H) (hP : 4≤P) (haP : b+log 1000000≤P)include hb hH hP haP
lemma Book.publicAlphabet_log (z : I→Banks (K:=K) (V:=V) b) (U : ChronoDomains (K:=K) (V:=V)) : log ((book.publicAlphabet z U).card:ℝ)≤ log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+ (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) := by let L := headerCost (K:=K) (V:=V)+ (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) have hL : 0≤L := add_nonneg headerCost_nonneg (mul_nonneg (by positivity) (add_nonneg (potential_nonneg _ _) (by linarith))) have hs : potential ((Nat.card K:ℝ)^(n+3)) U.swap=potential ((Nat.card K:ℝ)^(n+3)) U := by dsimp only [potential,Prod.swap]; rw [mul_comm] have hc : ((book.publicAlphabet z U).card:ℝ)≤((Fintype.card I:ℝ)+1)*exp L := by calc _ ≤ ∑ i,((book.allowed (z i).1 U.swap).card:ℝ) := by exact_mod_cast book.publicAlphabet_card z U _ ≤ ∑ _i : I,exp L := by apply sum_le_sum intro i _ simpa only [hs] using book.allowed_card_exp hb hH hP haP (z i).1 U.swap _ = (Fintype.card I:ℝ)*exp L := by simp only [sum_const,card_univ,nsmul_eq_mul] _ ≤ _ := mul_le_mul_of_nonneg_right (by linarith) (exp_pos L).le by_cases hz : (book.publicAlphabet z U).card=0 · rw [hz,Nat.cast_zero,log_zero,add_assoc] exact add_nonneg (log_nonneg (by have := Nat.cast_nonneg (α:=ℝ) (Fintype.card I); linarith)) hL · apply (log_le_iff_le_exp (by exact_mod_cast Nat.pos_of_ne_zero hz)).mpr rw [add_assoc,exp_add,exp_log (by positivity)] exact hc
local instance publicCodeDecidableEq : DecidableEq (I×Code (K:=K) (V:=V) b) := Classical.decEq _
variable (hdim : Module.finrank K V=n+3) (hτ : 0≤τ) (hτsmall : τ≤1/40000)
theorem Book.actual_full_entropy (p : Selection.Law Ω) (s : Ω→I→Original (K:=K) (V:=V) n b) (z : I→Banks (K:=K) (V:=V) b) (t : Ω→BinaryTree I) (U : ChronoDomains (K:=K) (V:=V)) (N ht m : ℕ) (targets : Ω→I→List (Projectivization K (Module.Dual K V)×Projectivization K V)) (counts : Ω→I→ℕ) (hcounts : ∀ ω i,counts ω i ≤ m) (hN : ∀ ω,(t ω).numNodes≤N) (hht : ∀ ω,(t ω).height≤ht) : let rd := fixedRead (fun _i : I=>chronoRead (K:=K) (V:=V) b) z let ch := fun ω=>fixedChoose (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) z let M := fun ω=>codeTree (countReader rd) (countChoose (fun y x=>SharpLogRamsey.Incidence.Incident x y) rd (ch ω) (targets ω) (counts ω)) (t ω) U let S := univ.image M let msg : Ω→S := fun ω=>⟨M ω,mem_image.mpr ⟨ω,mem_univ _,rfl⟩⟩ Selection.entropy (p.map msg)≤((2*N+1:ℕ):ℝ)*log 2+ (N:ℝ)*(log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+log (m+1:ℕ))+ (2*(H+22)*(Nat.card K:ℝ)*P)* ((ht:ℝ)*(potential ((Nat.card K:ℝ)^(n+3)) U+(N:ℝ)*(b+log 4+2*log 2000))+(N:ℝ)*P) := by apply full_execution_entropy_overhead p ((Nat.card K:ℝ)^(n+3)) 2000 b (2*(H+22)*(Nat.card K:ℝ)*P) P (log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)) (by have : 0<Nat.card K:=Nat.zero_lt_one.trans (Finite.one_lt_card (α:=K)); positivity) (by norm_num) hb (by positivity) (by linarith) (add_nonneg (log_nonneg (by have := Nat.cast_nonneg (α:=ℝ) (Fintype.card I); linarith)) headerCost_nonneg) N ht m _ (book.publicAlphabet z) _ _ t U targets counts hcounts hN hht · intro ω i U c hc obtain ⟨x,hx,rfl⟩:=Option.map_eq_some_iff.mp hc apply book.mem_publicAlphabet exact book.choose_allowed hdim hτ hτsmall (s ω i) (z i) U.swap x hx · intro ω i U c hc obtain ⟨x,hx,rfl⟩:=Option.map_eq_some_iff.mp hc have hh:=book.choose_caps hdim hτ hτsmall (s ω i) U.swap (z i) x hx refine ⟨(s ω i).B,(s ω i).A,(s ω i).nonemptyB,(s ω i).nonemptyA,hh.2.1,hh.1,?_,hh.2.2.2.2.2,hh.2.2.2.2.1⟩ simpa only [mul_comm] using (s ω i).product · intro ω i U c hc exact book.publicAlphabet_log hb hH hP haP z U
endend SharpLogRamsey.ActualPivot
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import Mathlibimport OAI.Combinatorics.SharpRamsey.Marking.SelectionLogBound
namespace OAI
sectionnamespace SharpLogRamsey.Selectionopen Real Finsetopen scoped Classicalnoncomputable sectionvariable {Ω α : Type} [Fintype Ω] [Fintype α] [Nonempty α]
theorem selected_map_entropy {N ℓ d : ℕ} (hd : 1 ≤ d) (hℓ : 0 < ℓ) (hN : ℓ ≤ N) (p : Law Ω) (stream : Ω → Fin N → α) (F : Ω → Fin ℓ → α) (reverse : (Fin ℓ → α) → (Fin ℓ → α)) {C q σ η c : ℝ} (hC : 0 < C) (hq : 0 < q) (hσ : 0 < σ) (hc : 0 < c) (hdom : ∀ g, (p.map stream).mass g ≤ C/(Fintype.card α:ℝ)^N) (hselect : ∀ x, p.mass x ≠ 0 → Occurs (F x) (stream x) ∨ Occurs (reverse (F x)) (stream x)) (hsize : (N:ℝ) ≤ q^d*σ) (hlength : c*q*σ^(1+η) ≤ (ℓ:ℝ)) (halphabet : q^(2*d-1) ≤ (Fintype.card α:ℝ)) : (ℓ:ℝ)*((d:ℝ)*log q+η*log σ+log c-1)-log (2*C) ≤ entropy (p.map F) := by let P := p.map (fun x => (stream x,F x)) have hfst : P.fst = p.map stream := by rw [←Law.map_fst] dsimp only [P] rw [Law.map_map] rfl have hsnd : P.snd = p.map F := by rw [←Law.map_snd] dsimp only [P] rw [Law.map_map] rfl have hh := selected_entropy_source_scales hd hℓ hN P reverse hC hq hσ hc (by simpa only [hfst] using hdom) (by intro g f hgf obtain ⟨x,hx,he⟩ := p.map_support (fun x => (stream x,F x)) (g,f) hgf have hh := hselect x hx have he1 : stream x = g := congrArg Prod.fst he have he2 : F x = f := congrArg Prod.snd he simpa only [he1,he2] using hh) hsize hlength halphabet rwa [hsnd] at hh
theorem selected_map_linear_deficit {N ℓ d : ℕ} (hd : 1 ≤ d) (hℓ : 0 < ℓ) (hN : ℓ ≤ N) (p : Law Ω) (stream : Ω → Fin N → α) (F : Ω → Fin ℓ → α) (reverse : (Fin ℓ → α) → (Fin ℓ → α)) {C q σ η c : ℝ} (hC : 0 < C) (hq : 0 < q) (hσ : 1 ≤ σ) (hη : 0 ≤ η) (hc : 0 < c) (hdom : ∀ g, (p.map stream).mass g ≤ C/(Fintype.card α:ℝ)^N) (hselect : ∀ x, p.mass x ≠ 0 → Occurs (F x) (stream x) ∨ Occurs (reverse (F x)) (stream x)) (hsize : (N:ℝ) ≤ q^d*σ) (hlength : c*q*σ^(1+η) ≤ (ℓ:ℝ)) (halphabet : q^(2*d-1) ≤ (Fintype.card α:ℝ)) : (ℓ:ℝ)*((d:ℝ)*log q)-(1+|log c|+|log (2*C)|)*ℓ ≤ entropy (p.map F) := by have hh := selected_map_entropy hd hℓ hN p stream F reverse hC hq (by linarith) hc hdom hselect hsize hlength halphabet have hpos : (1:ℝ) ≤ ℓ := by exact_mod_cast hℓ have hl : 0 ≤ log σ := log_nonneg hσ have hgain : 0 ≤ (ℓ:ℝ)*(η*log σ) := mul_nonneg (Nat.cast_nonneg _) (mul_nonneg hη hl) have hc' : -|log c| ≤ log c := neg_abs_le _ have hm : log (2*C) ≤ |log (2*C)| := le_abs_self _ have hm' : |log (2*C)| ≤ (ℓ:ℝ)*|log (2*C)| := le_mul_of_one_le_left (abs_nonneg _) hpos have hc'' := mul_le_mul_of_nonneg_left hc' (Nat.cast_nonneg ℓ) nlinarith only [hh,hgain,hm,hm',hc'']endend SharpLogRamsey.Selection
end
end OAIlean/OAI/Combinatorics/Sensitivity/RecursiveJointZero.leanAdded+97
lean/OAI/Combinatorics/Sensitivity/RecursiveOne.leanAdded+150
lean/OAI/Combinatorics/Sensitivity/RecursiveProfiles.leanAdded+110
lean/OAI/Combinatorics/Sensitivity/RecursiveRepair.leanAdded+103
lean/OAI/Combinatorics/Sensitivity/RecursiveSets.leanAdded+89
lean/OAI/Combinatorics/Sensitivity/RecursiveZero.leanAdded+121
lean/OAI/Combinatorics/Sensitivity/Reindex.leanAdded+106
lean/OAI/Combinatorics/Sensitivity/ScalarBounds.leanAdded+54
lean/OAI/Combinatorics/Sensitivity/SeedAmplification.leanAdded+47
lean/OAI/Combinatorics/Sensitivity/Separation.leanAdded+57
lean/OAI/Combinatorics/Sensitivity/SeparationArithmetic.leanAdded+116
lean/OAI/Combinatorics/Sensitivity/Tournament.leanAdded+68
lean/OAI/Combinatorics/Sensitivity/TournamentCounts.leanAdded+69
lean/OAI/Combinatorics/Sensitivity/TournamentCyclic.leanAdded+53
lean/OAI/Combinatorics/Sensitivity/Tower.leanAdded+161
lean/OAI/Combinatorics/Sensitivity/TowerProfiles.leanAdded+80
lean/OAI/Combinatorics/Sensitivity/UniformCoordinates.leanAdded+31
lean/OAI/Combinatorics/SharpRamsey/Bounds/FromConstruction.leanAdded+79
lean/OAI/Combinatorics/SharpRamsey/Bounds/Lower.leanAdded+186
lean/OAI/Combinatorics/SharpRamsey/Bounds/SamplingParameter.leanAdded+313
lean/OAI/Combinatorics/SharpRamsey/Bounds/SumFiberCenter.leanAdded+461
lean/OAI/Combinatorics/SharpRamsey/Bounds/Upper.leanAdded+452
lean/OAI/Combinatorics/SharpRamsey/Construction/FiniteStreamTail.leanAdded+124
lean/OAI/Combinatorics/SharpRamsey/Construction/FlagConstruction.leanAdded+217
lean/OAI/Combinatorics/SharpRamsey/Construction/GraphWitness.leanAdded+73
lean/OAI/Combinatorics/SharpRamsey/Construction/InitialLaw.leanAdded+121
lean/OAI/Combinatorics/SharpRamsey/Construction/InitialRectangles.leanAdded+137
lean/OAI/Combinatorics/SharpRamsey/Construction/InitialTools.leanAdded+96
lean/OAI/Combinatorics/SharpRamsey/Construction/PrimeConstruction.leanAdded+35
lean/OAI/Combinatorics/SharpRamsey/Construction/RectangleStreamEvent.leanAdded+157
lean/OAI/Combinatorics/SharpRamsey/Construction/SourceSizes.leanAdded+47
lean/OAI/Combinatorics/SharpRamsey/Entropy/AnchorEventsRealized.leanAdded+478
lean/OAI/Combinatorics/SharpRamsey/Entropy/CompleteProgramWeight.leanAdded+463
lean/OAI/Combinatorics/SharpRamsey/Entropy/ComponentLabelWitness.leanAdded+460
lean/OAI/Combinatorics/SharpRamsey/Entropy/ExternalMass.leanAdded+478
lean/OAI/Combinatorics/SharpRamsey/Entropy/ForcedHits.leanAdded+467
lean/OAI/Combinatorics/SharpRamsey/Entropy/HighMoments.leanAdded+423
lean/OAI/Combinatorics/SharpRamsey/Entropy/HighRankEntropy.leanAdded+63
lean/OAI/Combinatorics/SharpRamsey/Entropy/InformationScales.leanAdded+30
lean/OAI/Combinatorics/SharpRamsey/Entropy/IntegralTypicalScoreSq.leanAdded+450
lean/OAI/Combinatorics/SharpRamsey/Entropy/LabelledFilterCard.leanAdded+469
lean/OAI/Combinatorics/SharpRamsey/Entropy/LargeCard.leanAdded+448
lean/OAI/Combinatorics/SharpRamsey/Entropy/MakePair.leanAdded+470
lean/OAI/Combinatorics/SharpRamsey/Entropy/MarkingTwoEntropy.leanAdded+66
lean/OAI/Combinatorics/SharpRamsey/Entropy/NewEvents.leanAdded+487
lean/OAI/Combinatorics/SharpRamsey/Entropy/PatchNotMem.leanAdded+454
lean/OAI/Combinatorics/SharpRamsey/Entropy/PoissonLaw.leanAdded+465
lean/OAI/Combinatorics/SharpRamsey/Entropy/ProtocolEntropy.leanAdded+90
lean/OAI/Combinatorics/SharpRamsey/Entropy/ReciprocalEntropy.leanAdded+114
lean/OAI/Combinatorics/SharpRamsey/Entropy/SelectedEntropy.leanAdded+67