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
- lean/OAI/Combinatorics/Sensitivity/RecursiveJointZero.lean +97 -0
- lean/OAI/Combinatorics/Sensitivity/RecursiveOne.lean +150 -0
- lean/OAI/Combinatorics/Sensitivity/RecursiveProfiles.lean +110 -0
- lean/OAI/Combinatorics/Sensitivity/RecursiveRepair.lean +103 -0
- lean/OAI/Combinatorics/Sensitivity/RecursiveSets.lean +89 -0
- lean/OAI/Combinatorics/Sensitivity/RecursiveZero.lean +121 -0
- lean/OAI/Combinatorics/Sensitivity/Reindex.lean +106 -0
- lean/OAI/Combinatorics/Sensitivity/ScalarBounds.lean +54 -0
- lean/OAI/Combinatorics/Sensitivity/SeedAmplification.lean +47 -0
- lean/OAI/Combinatorics/Sensitivity/Separation.lean +57 -0
- lean/OAI/Combinatorics/Sensitivity/SeparationArithmetic.lean +116 -0
- lean/OAI/Combinatorics/Sensitivity/Tournament.lean +68 -0
- lean/OAI/Combinatorics/Sensitivity/TournamentCounts.lean +69 -0
- lean/OAI/Combinatorics/Sensitivity/TournamentCyclic.lean +53 -0
- lean/OAI/Combinatorics/Sensitivity/Tower.lean +161 -0
- lean/OAI/Combinatorics/Sensitivity/TowerProfiles.lean +80 -0
- lean/OAI/Combinatorics/Sensitivity/UniformCoordinates.lean +31 -0
- lean/OAI/Combinatorics/SharpRamsey/Bounds/FromConstruction.lean +79 -0
- lean/OAI/Combinatorics/SharpRamsey/Bounds/Lower.lean +186 -0
- lean/OAI/Combinatorics/SharpRamsey/Bounds/SamplingParameter.lean +313 -0
- lean/OAI/Combinatorics/SharpRamsey/Bounds/SumFiberCenter.lean +461 -0
- lean/OAI/Combinatorics/SharpRamsey/Bounds/Upper.lean +452 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/FiniteStreamTail.lean +124 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/FlagConstruction.lean +217 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/GraphWitness.lean +73 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/InitialLaw.lean +121 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/InitialRectangles.lean +137 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/InitialTools.lean +96 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/PrimeConstruction.lean +35 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/RectangleStreamEvent.lean +157 -0
- lean/OAI/Combinatorics/SharpRamsey/Construction/SourceSizes.lean +47 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/AnchorEventsRealized.lean +478 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/CompleteProgramWeight.lean +463 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ComponentLabelWitness.lean +460 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ExternalMass.lean +478 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ForcedHits.lean +467 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/HighMoments.lean +423 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/HighRankEntropy.lean +63 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/InformationScales.lean +30 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/IntegralTypicalScoreSq.lean +450 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/LabelledFilterCard.lean +469 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/LargeCard.lean +448 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/MakePair.lean +470 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/MarkingTwoEntropy.lean +66 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/NewEvents.lean +487 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/PatchNotMem.lean +454 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/PoissonLaw.lean +465 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ProtocolEntropy.lean +90 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/ReciprocalEntropy.lean +114 -0
- lean/OAI/Combinatorics/SharpRamsey/Entropy/SelectedEntropy.lean +67 -0
lean/OAI/Combinatorics/Sensitivity/RecursiveJointZero.lean
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.RecursiveCandidates
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! The joint zero recurrence uses the fixed weaker-threshold failure lists. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
theorem recursive_joint_zero_at {k r h : ℕ} {I : Type} [Fintype I]
|
| 13 |
+
(T : Tournament k) (A : GoodLabeling T r)
|
| 14 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r)
|
| 15 |
+
(q q' : Fin h) (hqq : q < q') (x : ((Fin k × Fin r) × I) → Bool)
|
| 16 |
+
(hx : recursiveFamily T A.label F q x = false)
|
| 17 |
+
(hx' : recursiveFamily T A.label F q' x = false) :
|
| 18 |
+
jointSensitivityAt (recursiveFamily T A.label F q) (recursiveFamily T A.label F q') x ≤
|
| 19 |
+
16 * sideSensitivity F false + 3 * jointSensitivity F true := by
|
| 20 |
+
let TC := targetCandidates T A.label F q x
|
| 21 |
+
let GC := gateCandidates T A.label F q x
|
| 22 |
+
let w := gateWitness T A.label F q x
|
| 23 |
+
let U := TC.biUnion fun i => childChanges F (Fin.last h) x i (targetWitness F x hr i)
|
| 24 |
+
let V := GC.biUnion fun i => childJointChanges F (gateIndex q') (gateIndex q) x (w i) (A.label i (w i))
|
| 25 |
+
have hsub : (Finset.univ.filter fun p =>
|
| 26 |
+
recursiveFamily T A.label F q (flip x {p}) ≠ recursiveFamily T A.label F q x ∧
|
| 27 |
+
recursiveFamily T A.label F q' (flip x {p}) ≠ recursiveFamily T A.label F q' x) ⊆ U ∪ V := by
|
| 28 |
+
rintro ⟨⟨j, c⟩, a⟩ hp
|
| 29 |
+
have hchange := (Finset.mem_filter.mp hp).2
|
| 30 |
+
have hon' : recursiveFamily T A.label F q' (flip x {((j, c), a)}) = true := by
|
| 31 |
+
cases hy : recursiveFamily T A.label F q' (flip x {((j, c), a)})
|
| 32 |
+
· exact False.elim (hchange.2 (hy.trans hx'.symm))
|
| 33 |
+
· rfl
|
| 34 |
+
obtain ⟨i, hi'⟩ := (recursiveFamily_eq_true_iff T A.label F q' _).mp hon'
|
| 35 |
+
have hi := rowClause_nested T A.label F hF hqq.le _ i hi'
|
| 36 |
+
have hioff := (recursiveFamily_eq_false_iff T A.label F q x).mp hx i
|
| 37 |
+
rcases rowClause_repair_cases T A.label F q x i j c a hioff hi with
|
| 38 |
+
⟨hit, hji, htoff, hton⟩ | ⟨hig, hij, rfl, hgon, hgoff⟩
|
| 39 |
+
· subst j
|
| 40 |
+
have hc := targetWitness_unique T A.label F q x hr i hit c htoff
|
| 41 |
+
apply Finset.mem_union_left
|
| 42 |
+
apply Finset.mem_biUnion.mpr
|
| 43 |
+
refine ⟨i, hit, ?_⟩
|
| 44 |
+
have hn : F (Fin.last h) (flip (recursiveChild x i c) {a}) ≠
|
| 45 |
+
F (Fin.last h) (recursiveChild x i c) := by simp [hton, htoff]
|
| 46 |
+
simpa [childChanges, hc] using hn
|
| 47 |
+
· have hj := gateWitness_unique T A.label F q x i hig j hij hgon
|
| 48 |
+
have hgon' := hF.accepts_of_le (gateIndex_strictAnti hqq).le hgon
|
| 49 |
+
have hgoff' := ((rowClause_eq_true_iff T A.label F q' _ i).mp hi').2 j hij
|
| 50 |
+
rw [recursiveChild_flip_same] at hgoff'
|
| 51 |
+
apply Finset.mem_union_right
|
| 52 |
+
apply Finset.mem_biUnion.mpr
|
| 53 |
+
refine ⟨i, hig, ?_⟩
|
| 54 |
+
have hn :
|
| 55 |
+
F (gateIndex q') (flip (recursiveChild x j (A.label i j)) {a}) ≠
|
| 56 |
+
F (gateIndex q') (recursiveChild x j (A.label i j)) ∧
|
| 57 |
+
F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠
|
| 58 |
+
F (gateIndex q) (recursiveChild x j (A.label i j)) := by
|
| 59 |
+
simp [hgon, hgoff, hgon', hgoff']
|
| 60 |
+
simpa [childJointChanges, w, hj] using hn
|
| 61 |
+
have hU : U.card ≤ 16 * sideSensitivity F false := by
|
| 62 |
+
calc
|
| 63 |
+
U.card ≤ TC.card * sideSensitivity F false :=
|
| 64 |
+
card_biUnion_le_mul TC _ _ (fun i hi => by
|
| 65 |
+
rw [childChanges_card]
|
| 66 |
+
exact sensitivityAt_le_sideSensitivity F false _ _
|
| 67 |
+
(targetWitness_false T A.label F q x hr i hi))
|
| 68 |
+
_ ≤ 16 * sideSensitivity F false := Nat.mul_le_mul_right _
|
| 69 |
+
(Nat.le_of_lt (targetCandidates_card T A F hF q x hr))
|
| 70 |
+
have hV : V.card ≤ 3 * jointSensitivity F true := by
|
| 71 |
+
calc
|
| 72 |
+
V.card ≤ GC.card * jointSensitivity F true :=
|
| 73 |
+
card_biUnion_le_mul GC _ _ (fun i hi => by
|
| 74 |
+
rw [childJointChanges_card]
|
| 75 |
+
have hg := (gateWitness_spec T A.label F q x i hi).2
|
| 76 |
+
exact jointSensitivityAt_le_jointSensitivity F true _ _ _
|
| 77 |
+
(gateIndex_strictAnti hqq) (hF.accepts_of_le (gateIndex_strictAnti hqq).le hg) hg)
|
| 78 |
+
_ ≤ 3 * jointSensitivity F true := Nat.mul_le_mul_right _ (gateCandidates_card T A.label F hF q x)
|
| 79 |
+
calc
|
| 80 |
+
jointSensitivityAt (recursiveFamily T A.label F q) (recursiveFamily T A.label F q') x ≤
|
| 81 |
+
(U ∪ V).card := Finset.card_le_card hsub
|
| 82 |
+
_ ≤ U.card + V.card := Finset.card_union_le _ _
|
| 83 |
+
_ ≤ _ := Nat.add_le_add hU hV
|
| 84 |
+
|
| 85 |
+
theorem recursive_joint_zero {k r h : ℕ} {I : Type} [Fintype I]
|
| 86 |
+
(T : Tournament k) (A : GoodLabeling T r)
|
| 87 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) :
|
| 88 |
+
jointSensitivity (recursiveFamily T A.label F) false ≤
|
| 89 |
+
16 * sideSensitivity F false + 3 * jointSensitivity F true := by
|
| 90 |
+
apply jointSensitivity_le
|
| 91 |
+
exact fun q q' x hqq hx hx' => recursive_joint_zero_at T A F hF hr q q' hqq x hx hx'
|
| 92 |
+
|
| 93 |
+
end Paper320
|
| 94 |
+
|
| 95 |
+
end
|
| 96 |
+
|
| 97 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/RecursiveOne.lean
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.RecursiveSets
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! The two recurrences for inputs at which the parent predicates accept. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
theorem recursive_sensitivity_one_at {k r h : ℕ} {I : Type} [Fintype I]
|
| 13 |
+
(T : Tournament k) (label : Fin k → Fin k → Fin r)
|
| 14 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (o : ℕ)
|
| 15 |
+
(ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o)
|
| 16 |
+
(q : Fin h) (x : ((Fin k × Fin r) × I) → Bool)
|
| 17 |
+
(hx : recursiveFamily T label F q x = true) :
|
| 18 |
+
sensitivityAt (recursiveFamily T label F q) x ≤
|
| 19 |
+
o * sideSensitivity F false + r * sideSensitivity F true := by
|
| 20 |
+
obtain ⟨i, hi⟩ := (recursiveFamily_eq_true_iff T label F q x).mp hx
|
| 21 |
+
have hcond := (rowClause_eq_true_iff T label F q x i).mp hi
|
| 22 |
+
let U := Finset.univ.biUnion fun c => childChanges F (Fin.last h) x i c
|
| 23 |
+
let V := (Finset.univ.filter (T.Adj i)).biUnion fun j =>
|
| 24 |
+
childChanges F (gateIndex q) x j (label i j)
|
| 25 |
+
have hsub : (Finset.univ.filter fun p =>
|
| 26 |
+
recursiveFamily T label F q (flip x {p}) ≠ recursiveFamily T label F q x) ⊆ U ∪ V := by
|
| 27 |
+
rintro ⟨⟨j, c⟩, a⟩ hp
|
| 28 |
+
have hchange := (Finset.mem_filter.mp hp).2
|
| 29 |
+
have hf : recursiveFamily T label F q (flip x {((j, c), a)}) = false := by
|
| 30 |
+
cases hy : recursiveFamily T label F q (flip x {((j, c), a)})
|
| 31 |
+
· rfl
|
| 32 |
+
· exact False.elim (hchange (hy.trans hx.symm))
|
| 33 |
+
have hif := (recursiveFamily_eq_false_iff T label F q _).mp hf i
|
| 34 |
+
have hic : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by
|
| 35 |
+
simp [hi, hif]
|
| 36 |
+
rcases rowClause_flip_change T label F q x i j c a hic with ⟨rfl, ht⟩ | ⟨hij, rfl, hg⟩
|
| 37 |
+
· apply Finset.mem_union_left
|
| 38 |
+
apply Finset.mem_biUnion.mpr
|
| 39 |
+
exact ⟨c, Finset.mem_univ _, by simpa [childChanges] using ht⟩
|
| 40 |
+
· apply Finset.mem_union_right
|
| 41 |
+
apply Finset.mem_biUnion.mpr
|
| 42 |
+
exact ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hij⟩,
|
| 43 |
+
by simpa [childChanges] using hg⟩
|
| 44 |
+
have hU : U.card ≤ r * sideSensitivity F true := by
|
| 45 |
+
simpa [U] using card_biUnion_le_mul Finset.univ
|
| 46 |
+
(fun c => childChanges F (Fin.last h) x i c) (sideSensitivity F true)
|
| 47 |
+
(fun c _ => by
|
| 48 |
+
rw [childChanges_card]
|
| 49 |
+
exact sensitivityAt_le_sideSensitivity F true _ _ (hcond.1 c))
|
| 50 |
+
have hV : V.card ≤ o * sideSensitivity F false := by
|
| 51 |
+
simpa only [V, ho i] using card_biUnion_le_mul (Finset.univ.filter (T.Adj i))
|
| 52 |
+
(fun j => childChanges F (gateIndex q) x j (label i j)) (sideSensitivity F false)
|
| 53 |
+
(fun j hj => by
|
| 54 |
+
rw [childChanges_card]
|
| 55 |
+
exact sensitivityAt_le_sideSensitivity F false _ _
|
| 56 |
+
(hcond.2 j (Finset.mem_filter.mp hj).2))
|
| 57 |
+
calc
|
| 58 |
+
sensitivityAt (recursiveFamily T label F q) x ≤ (U ∪ V).card := Finset.card_le_card hsub
|
| 59 |
+
_ ≤ U.card + V.card := Finset.card_union_le _ _
|
| 60 |
+
_ ≤ r * sideSensitivity F true + o * sideSensitivity F false := Nat.add_le_add hU hV
|
| 61 |
+
_ = _ := Nat.add_comm _ _
|
| 62 |
+
|
| 63 |
+
theorem recursive_side_one {k r h : ℕ} {I : Type} [Fintype I]
|
| 64 |
+
(T : Tournament k) (label : Fin k → Fin k → Fin r)
|
| 65 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (o : ℕ)
|
| 66 |
+
(ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) :
|
| 67 |
+
sideSensitivity (recursiveFamily T label F) true ≤
|
| 68 |
+
o * sideSensitivity F false + r * sideSensitivity F true := by
|
| 69 |
+
apply sideSensitivity_le
|
| 70 |
+
exact fun q x hx => recursive_sensitivity_one_at T label F o ho q x hx
|
| 71 |
+
|
| 72 |
+
theorem recursive_joint_one_at {k r h : ℕ} {I : Type} [Fintype I]
|
| 73 |
+
(T : Tournament k) (label : Fin k → Fin k → Fin r)
|
| 74 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (o : ℕ)
|
| 75 |
+
(ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o)
|
| 76 |
+
(q q' : Fin h) (hqq : q < q') (x : ((Fin k × Fin r) × I) → Bool)
|
| 77 |
+
(hx : recursiveFamily T label F q x = true)
|
| 78 |
+
(hx' : recursiveFamily T label F q' x = true) :
|
| 79 |
+
jointSensitivityAt (recursiveFamily T label F q) (recursiveFamily T label F q') x ≤
|
| 80 |
+
o * jointSensitivity F false + r * sideSensitivity F true := by
|
| 81 |
+
obtain ⟨i, hi'⟩ := (recursiveFamily_eq_true_iff T label F q' x).mp hx'
|
| 82 |
+
have hi := rowClause_nested T label F hF hqq.le x i hi'
|
| 83 |
+
have hcond := (rowClause_eq_true_iff T label F q x i).mp hi
|
| 84 |
+
have hcond' := (rowClause_eq_true_iff T label F q' x i).mp hi'
|
| 85 |
+
let U := Finset.univ.biUnion fun c => childChanges F (Fin.last h) x i c
|
| 86 |
+
let V := (Finset.univ.filter (T.Adj i)).biUnion fun j =>
|
| 87 |
+
childJointChanges F (gateIndex q') (gateIndex q) x j (label i j)
|
| 88 |
+
have hsub : (Finset.univ.filter fun p =>
|
| 89 |
+
recursiveFamily T label F q (flip x {p}) ≠ recursiveFamily T label F q x ∧
|
| 90 |
+
recursiveFamily T label F q' (flip x {p}) ≠ recursiveFamily T label F q' x) ⊆ U ∪ V := by
|
| 91 |
+
rintro ⟨⟨j, c⟩, a⟩ hp
|
| 92 |
+
have hchange := (Finset.mem_filter.mp hp).2
|
| 93 |
+
have hf : recursiveFamily T label F q (flip x {((j, c), a)}) = false := by
|
| 94 |
+
cases hy : recursiveFamily T label F q (flip x {((j, c), a)})
|
| 95 |
+
· rfl
|
| 96 |
+
· exact False.elim (hchange.1 (hy.trans hx.symm))
|
| 97 |
+
have hf' : recursiveFamily T label F q' (flip x {((j, c), a)}) = false := by
|
| 98 |
+
cases hy : recursiveFamily T label F q' (flip x {((j, c), a)})
|
| 99 |
+
· rfl
|
| 100 |
+
· exact False.elim (hchange.2 (hy.trans hx'.symm))
|
| 101 |
+
have hif := (recursiveFamily_eq_false_iff T label F q _).mp hf i
|
| 102 |
+
have hif' := (recursiveFamily_eq_false_iff T label F q' _).mp hf' i
|
| 103 |
+
have hic : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by
|
| 104 |
+
simp [hi, hif]
|
| 105 |
+
have hic' : rowClause T label F q' (flip x {((j, c), a)}) i ≠ rowClause T label F q' x i := by
|
| 106 |
+
simp [hi', hif']
|
| 107 |
+
rcases rowClause_joint_flip_change T label F q q' x i j c a hic hic' with
|
| 108 |
+
⟨rfl, ht⟩ | ⟨hij, rfl, hg, hg'⟩
|
| 109 |
+
· apply Finset.mem_union_left
|
| 110 |
+
apply Finset.mem_biUnion.mpr
|
| 111 |
+
exact ⟨c, Finset.mem_univ _, by simpa [childChanges] using ht⟩
|
| 112 |
+
· apply Finset.mem_union_right
|
| 113 |
+
apply Finset.mem_biUnion.mpr
|
| 114 |
+
exact ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hij⟩,
|
| 115 |
+
by simpa [childJointChanges] using And.intro hg' hg⟩
|
| 116 |
+
have hU : U.card ≤ r * sideSensitivity F true := by
|
| 117 |
+
simpa [U] using card_biUnion_le_mul Finset.univ
|
| 118 |
+
(fun c => childChanges F (Fin.last h) x i c) (sideSensitivity F true)
|
| 119 |
+
(fun c _ => by
|
| 120 |
+
rw [childChanges_card]
|
| 121 |
+
exact sensitivityAt_le_sideSensitivity F true _ _ (hcond.1 c))
|
| 122 |
+
have hV : V.card ≤ o * jointSensitivity F false := by
|
| 123 |
+
simpa only [V, ho i] using card_biUnion_le_mul (Finset.univ.filter (T.Adj i))
|
| 124 |
+
(fun j => childJointChanges F (gateIndex q') (gateIndex q) x j (label i j))
|
| 125 |
+
(jointSensitivity F false) (fun j hj => by
|
| 126 |
+
have hij := (Finset.mem_filter.mp hj).2
|
| 127 |
+
rw [childJointChanges_card]
|
| 128 |
+
exact jointSensitivityAt_le_jointSensitivity F false _ _ _
|
| 129 |
+
(gateIndex_strictAnti hqq) (hcond'.2 j hij) (hcond.2 j hij))
|
| 130 |
+
calc
|
| 131 |
+
jointSensitivityAt (recursiveFamily T label F q) (recursiveFamily T label F q') x ≤
|
| 132 |
+
(U ∪ V).card := Finset.card_le_card hsub
|
| 133 |
+
_ ≤ U.card + V.card := Finset.card_union_le _ _
|
| 134 |
+
_ ≤ r * sideSensitivity F true + o * jointSensitivity F false := Nat.add_le_add hU hV
|
| 135 |
+
_ = _ := Nat.add_comm _ _
|
| 136 |
+
|
| 137 |
+
theorem recursive_joint_one {k r h : ℕ} {I : Type} [Fintype I]
|
| 138 |
+
(T : Tournament k) (label : Fin k → Fin k → Fin r)
|
| 139 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (o : ℕ)
|
| 140 |
+
(ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) :
|
| 141 |
+
jointSensitivity (recursiveFamily T label F) true ≤
|
| 142 |
+
o * jointSensitivity F false + r * sideSensitivity F true := by
|
| 143 |
+
apply jointSensitivity_le
|
| 144 |
+
exact fun q q' x hqq hx hx' => recursive_joint_one_at T label F hF o ho q q' hqq x hx hx'
|
| 145 |
+
|
| 146 |
+
end Paper320
|
| 147 |
+
|
| 148 |
+
end
|
| 149 |
+
|
| 150 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/RecursiveProfiles.lean
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.Model
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! The side and joint profiles count literal flips of the same raw input. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
/-- Acceptance at a stronger index implies acceptance at every weaker index. -/
|
| 13 |
+
structure NestedFamily {h : ℕ} {I : Type}
|
| 14 |
+
(F : Fin h → (I → Bool) → Bool) : Prop where
|
| 15 |
+
accepts_of_le : ∀ {q q' : Fin h} {x}, q ≤ q' → F q' x = true → F q x = true
|
| 16 |
+
|
| 17 |
+
theorem NestedFamily.rejects_of_le {h : ℕ} {I : Type}
|
| 18 |
+
{F : Fin h → (I → Bool) → Bool} (hF : NestedFamily F)
|
| 19 |
+
{q q' : Fin h} {x} (hqq : q ≤ q') (hx : F q x = false) :
|
| 20 |
+
F q' x = false := by
|
| 21 |
+
cases h' : F q' x
|
| 22 |
+
· rfl
|
| 23 |
+
· have := hF.accepts_of_le hqq h'
|
| 24 |
+
simp [hx] at this
|
| 25 |
+
|
| 26 |
+
/-- The number of coordinates whose one-bit flip changes both predicates. -/
|
| 27 |
+
def jointSensitivityAt {I : Type} [Fintype I]
|
| 28 |
+
(f g : (I → Bool) → Bool) (x : I → Bool) : ℕ :=
|
| 29 |
+
(Finset.univ.filter fun i =>
|
| 30 |
+
f (flip x {i}) ≠ f x ∧ g (flip x {i}) ≠ g x).card
|
| 31 |
+
|
| 32 |
+
/-- Maximum sensitivity over all indices and inputs with the indicated output. -/
|
| 33 |
+
def sideSensitivity {h : ℕ} {I : Type} [Fintype I]
|
| 34 |
+
(F : Fin h → (I → Bool) → Bool) (b : Bool) : ℕ :=
|
| 35 |
+
Finset.univ.sup fun q => Finset.univ.sup fun x =>
|
| 36 |
+
if F q x = b then sensitivityAt (F q) x else 0
|
| 37 |
+
|
| 38 |
+
/-- Maximum same-input, same-bit joint sensitivity over two distinct ordered indices. -/
|
| 39 |
+
def jointSensitivity {h : ℕ} {I : Type} [Fintype I]
|
| 40 |
+
(F : Fin h → (I → Bool) → Bool) (b : Bool) : ℕ :=
|
| 41 |
+
Finset.univ.sup fun q => Finset.univ.sup fun q' => Finset.univ.sup fun x =>
|
| 42 |
+
if q < q' ∧ F q x = b ∧ F q' x = b then
|
| 43 |
+
jointSensitivityAt (F q) (F q') x else 0
|
| 44 |
+
|
| 45 |
+
theorem sensitivityAt_le_sideSensitivity {h : ℕ} {I : Type} [Fintype I]
|
| 46 |
+
(F : Fin h → (I → Bool) → Bool) (b : Bool) (q : Fin h) (x : I → Bool)
|
| 47 |
+
(hx : F q x = b) : sensitivityAt (F q) x ≤ sideSensitivity F b := by
|
| 48 |
+
apply Finset.le_sup_of_le (Finset.mem_univ q)
|
| 49 |
+
apply Finset.le_sup_of_le (Finset.mem_univ x)
|
| 50 |
+
simp [hx]
|
| 51 |
+
|
| 52 |
+
theorem sideSensitivity_le {h : ℕ} {I : Type} [Fintype I]
|
| 53 |
+
(F : Fin h → (I → Bool) → Bool) (b : Bool) (B : ℕ)
|
| 54 |
+
(hB : ∀ q x, F q x = b → sensitivityAt (F q) x ≤ B) :
|
| 55 |
+
sideSensitivity F b ≤ B := by
|
| 56 |
+
apply Finset.sup_le
|
| 57 |
+
intro q _
|
| 58 |
+
apply Finset.sup_le
|
| 59 |
+
intro x _
|
| 60 |
+
split_ifs with hx
|
| 61 |
+
· exact hB q x hx
|
| 62 |
+
· exact Nat.zero_le _
|
| 63 |
+
|
| 64 |
+
theorem jointSensitivityAt_le_jointSensitivity {h : ℕ} {I : Type} [Fintype I]
|
| 65 |
+
(F : Fin h → (I → Bool) → Bool) (b : Bool) (q q' : Fin h) (x : I → Bool)
|
| 66 |
+
(hqq : q < q') (hx : F q x = b) (hx' : F q' x = b) :
|
| 67 |
+
jointSensitivityAt (F q) (F q') x ≤ jointSensitivity F b := by
|
| 68 |
+
apply Finset.le_sup_of_le (Finset.mem_univ q)
|
| 69 |
+
apply Finset.le_sup_of_le (Finset.mem_univ q')
|
| 70 |
+
apply Finset.le_sup_of_le (Finset.mem_univ x)
|
| 71 |
+
simp [hqq, hx, hx']
|
| 72 |
+
|
| 73 |
+
theorem jointSensitivity_le {h : ℕ} {I : Type} [Fintype I]
|
| 74 |
+
(F : Fin h → (I → Bool) → Bool) (b : Bool) (B : ℕ)
|
| 75 |
+
(hB : ∀ q q' x, q < q' → F q x = b → F q' x = b →
|
| 76 |
+
jointSensitivityAt (F q) (F q') x ≤ B) : jointSensitivity F b ≤ B := by
|
| 77 |
+
apply Finset.sup_le
|
| 78 |
+
intro q _
|
| 79 |
+
apply Finset.sup_le
|
| 80 |
+
intro q' _
|
| 81 |
+
apply Finset.sup_le
|
| 82 |
+
intro x _
|
| 83 |
+
split_ifs with hx
|
| 84 |
+
· exact hB q q' x hx.1 hx.2.1 hx.2.2
|
| 85 |
+
· exact Nat.zero_le _
|
| 86 |
+
|
| 87 |
+
theorem jointSensitivityAt_le_left {I : Type} [Fintype I]
|
| 88 |
+
(f g : (I → Bool) → Bool) (x : I → Bool) :
|
| 89 |
+
jointSensitivityAt f g x ≤ sensitivityAt f x := by
|
| 90 |
+
apply Finset.card_le_card
|
| 91 |
+
intro i hi
|
| 92 |
+
exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hi).2.1⟩
|
| 93 |
+
|
| 94 |
+
theorem jointSensitivityAt_comm {I : Type} [Fintype I]
|
| 95 |
+
(f g : (I → Bool) → Bool) (x : I → Bool) :
|
| 96 |
+
jointSensitivityAt f g x = jointSensitivityAt g f x := by
|
| 97 |
+
simp only [jointSensitivityAt, and_comm]
|
| 98 |
+
|
| 99 |
+
theorem jointSensitivity_one {I : Type} [Fintype I]
|
| 100 |
+
(F : Fin 1 → (I → Bool) → Bool) (b : Bool) : jointSensitivity F b = 0 := by
|
| 101 |
+
apply Nat.eq_zero_of_le_zero
|
| 102 |
+
apply jointSensitivity_le
|
| 103 |
+
intro q q' x hqq _ _
|
| 104 |
+
exact False.elim (by omega)
|
| 105 |
+
|
| 106 |
+
end Paper320
|
| 107 |
+
|
| 108 |
+
end
|
| 109 |
+
|
| 110 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/RecursiveRepair.lean
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.RecursiveFailures
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! A successful raw-bit flip repairs the unique initial failed condition. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
theorem repaired_target_location {k r h : ℕ} {I : Type} (T : Tournament k)
|
| 13 |
+
(label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool)
|
| 14 |
+
(q : Fin h) (x : ((Fin k × Fin r) × I) → Bool)
|
| 15 |
+
(i j : Fin k) (c c' : Fin r) (a : I)
|
| 16 |
+
(hf : rowClause T label F q (flip x {((j, c), a)}) i = true)
|
| 17 |
+
(hz : F (Fin.last h) (recursiveChild x i c') = false) : (i, c') = (j, c) := by
|
| 18 |
+
by_contra hne
|
| 19 |
+
have ht := ((rowClause_eq_true_iff T label F q _ i).mp hf).1 c'
|
| 20 |
+
rw [recursiveChild_flip_other x j i c c' a hne, hz] at ht
|
| 21 |
+
exact Bool.false_ne_true ht
|
| 22 |
+
|
| 23 |
+
theorem repaired_gate_location {k r h : ℕ} {I : Type} (T : Tournament k)
|
| 24 |
+
(label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool)
|
| 25 |
+
(q : Fin h) (x : ((Fin k × Fin r) × I) → Bool)
|
| 26 |
+
(i j j' : Fin k) (c : Fin r) (a : I)
|
| 27 |
+
(hf : rowClause T label F q (flip x {((j, c), a)}) i = true)
|
| 28 |
+
(hij' : T.Adj i j') (hon : F (gateIndex q) (recursiveChild x j' (label i j')) = true) :
|
| 29 |
+
(j', label i j') = (j, c) := by
|
| 30 |
+
by_contra hne
|
| 31 |
+
have hg := ((rowClause_eq_true_iff T label F q _ i).mp hf).2 j' hij'
|
| 32 |
+
rw [recursiveChild_flip_other x j j' c (label i j') a hne, hon] at hg
|
| 33 |
+
exact Bool.false_ne_true hg.symm
|
| 34 |
+
|
| 35 |
+
theorem rowClause_repair_cases {k r h : ℕ} {I : Type} (T : Tournament k)
|
| 36 |
+
(label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool)
|
| 37 |
+
(q : Fin h) (x : ((Fin k × Fin r) × I) → Bool)
|
| 38 |
+
(i j : Fin k) (c : Fin r) (a : I)
|
| 39 |
+
(hi : rowClause T label F q x i = false)
|
| 40 |
+
(hf : rowClause T label F q (flip x {((j, c), a)}) i = true) :
|
| 41 |
+
(i ∈ targetCandidates T label F q x ∧ j = i ∧
|
| 42 |
+
F (Fin.last h) (recursiveChild x j c) = false ∧
|
| 43 |
+
F (Fin.last h) (flip (recursiveChild x j c) {a}) = true) ∨
|
| 44 |
+
(i ∈ gateCandidates T label F q x ∧ T.Adj i j ∧ c = label i j ∧
|
| 45 |
+
F (gateIndex q) (recursiveChild x j c) = true ∧
|
| 46 |
+
F (gateIndex q) (flip (recursiveChild x j c) {a}) = false) := by
|
| 47 |
+
have hchange : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by
|
| 48 |
+
simp [hi, hf]
|
| 49 |
+
rcases rowClause_flip_change T label F q x i j c a hchange with
|
| 50 |
+
⟨hji, ht⟩ | ⟨hij, rfl, hg⟩
|
| 51 |
+
· subst j
|
| 52 |
+
have hton := ((rowClause_eq_true_iff T label F q _ i).mp hf).1 c
|
| 53 |
+
rw [recursiveChild_flip_same] at hton
|
| 54 |
+
have htoff : F (Fin.last h) (recursiveChild x i c) = false := by
|
| 55 |
+
cases hc : F (Fin.last h) (recursiveChild x i c)
|
| 56 |
+
· rfl
|
| 57 |
+
· exact False.elim (ht (hton.trans hc.symm))
|
| 58 |
+
have htargets : targetFailures F x i = {c} := by
|
| 59 |
+
ext c'
|
| 60 |
+
simp only [targetFailures, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton]
|
| 61 |
+
constructor
|
| 62 |
+
· intro hfalse
|
| 63 |
+
exact congrArg Prod.snd (repaired_target_location T label F q x i i c c' a hf hfalse)
|
| 64 |
+
· rintro rfl
|
| 65 |
+
exact htoff
|
| 66 |
+
have hgates : gateFailures T label F q x i = ∅ := by
|
| 67 |
+
apply Finset.eq_empty_iff_forall_notMem.mpr
|
| 68 |
+
intro j' hj'
|
| 69 |
+
have h := (Finset.mem_filter.mp hj').2
|
| 70 |
+
have heq := repaired_gate_location T label F q x i i j' c a hf h.1 h.2
|
| 71 |
+
exact T.ne_of_adj h.1 (congrArg Prod.fst heq).symm
|
| 72 |
+
have hmem : i ∈ targetCandidates T label F q x := by
|
| 73 |
+
simp [targetCandidates, htargets, hgates]
|
| 74 |
+
exact Or.inl ⟨hmem, rfl, htoff, hton⟩
|
| 75 |
+
· have hgoff := ((rowClause_eq_true_iff T label F q _ i).mp hf).2 j hij
|
| 76 |
+
rw [recursiveChild_flip_same] at hgoff
|
| 77 |
+
have hgon : F (gateIndex q) (recursiveChild x j (label i j)) = true := by
|
| 78 |
+
cases hc : F (gateIndex q) (recursiveChild x j (label i j))
|
| 79 |
+
· exact False.elim (hg (hgoff.trans hc.symm))
|
| 80 |
+
· rfl
|
| 81 |
+
have htargets : targetFailures F x i = ∅ := by
|
| 82 |
+
apply Finset.eq_empty_iff_forall_notMem.mpr
|
| 83 |
+
intro c' hc'
|
| 84 |
+
have heq := repaired_target_location T label F q x i j (label i j) c' a hf
|
| 85 |
+
(Finset.mem_filter.mp hc').2
|
| 86 |
+
exact T.ne_of_adj hij (congrArg Prod.fst heq)
|
| 87 |
+
have hgates : gateFailures T label F q x i = {j} := by
|
| 88 |
+
ext j'
|
| 89 |
+
simp only [gateFailures, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton]
|
| 90 |
+
constructor
|
| 91 |
+
· rintro ⟨hij', hon⟩
|
| 92 |
+
exact congrArg Prod.fst (repaired_gate_location T label F q x i j j' (label i j) a hf hij' hon)
|
| 93 |
+
· rintro rfl
|
| 94 |
+
exact ⟨hij, hgon⟩
|
| 95 |
+
have hmem : i ∈ gateCandidates T label F q x := by
|
| 96 |
+
simp [gateCandidates, htargets, hgates]
|
| 97 |
+
exact Or.inr ⟨hmem, hij, rfl, hgon, hgoff⟩
|
| 98 |
+
|
| 99 |
+
end Paper320
|
| 100 |
+
|
| 101 |
+
end
|
| 102 |
+
|
| 103 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/RecursiveSets.lean
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.RecursiveFlips
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! Finite sets of changing raw coordinates inside an individual child. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
def childLift {J I : Type} (j : J) (A : Finset I) : Finset (J × I) :=
|
| 13 |
+
A.map ⟨fun a => (j, a), fun _ _ h => congrArg (fun p : J × I => p.2) h⟩
|
| 14 |
+
|
| 15 |
+
@[simp] theorem mem_childLift {J I : Type} (j : J) (A : Finset I) (p : J × I) :
|
| 16 |
+
p ∈ childLift j A ↔ p.1 = j ∧ p.2 ∈ A := by
|
| 17 |
+
rcases p with ⟨k, a⟩
|
| 18 |
+
unfold childLift
|
| 19 |
+
rw [Finset.mem_map]
|
| 20 |
+
constructor
|
| 21 |
+
· rintro ⟨b, hb, hp⟩
|
| 22 |
+
change (j, b) = (k, a) at hp
|
| 23 |
+
cases hp
|
| 24 |
+
exact ⟨rfl, hb⟩
|
| 25 |
+
· rintro ⟨rfl, ha⟩
|
| 26 |
+
exact ⟨a, ha, rfl⟩
|
| 27 |
+
|
| 28 |
+
@[simp] theorem childLift_card {J I : Type} (j : J) (A : Finset I) :
|
| 29 |
+
(childLift j A).card = A.card := Finset.card_map _
|
| 30 |
+
|
| 31 |
+
def childChanges {k r h : ℕ} {I : Type} [Fintype I]
|
| 32 |
+
(F : Fin h → (I → Bool) → Bool) (q : Fin h)
|
| 33 |
+
(x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) :
|
| 34 |
+
Finset ((Fin k × Fin r) × I) :=
|
| 35 |
+
childLift (j, c) (Finset.univ.filter fun a =>
|
| 36 |
+
F q (flip (recursiveChild x j c) {a}) ≠ F q (recursiveChild x j c))
|
| 37 |
+
|
| 38 |
+
def childJointChanges {k r h : ℕ} {I : Type} [Fintype I]
|
| 39 |
+
(F : Fin h → (I → Bool) → Bool) (q q' : Fin h)
|
| 40 |
+
(x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) :
|
| 41 |
+
Finset ((Fin k × Fin r) × I) :=
|
| 42 |
+
childLift (j, c) (Finset.univ.filter fun a =>
|
| 43 |
+
F q (flip (recursiveChild x j c) {a}) ≠ F q (recursiveChild x j c) ∧
|
| 44 |
+
F q' (flip (recursiveChild x j c) {a}) ≠ F q' (recursiveChild x j c))
|
| 45 |
+
|
| 46 |
+
@[simp] theorem childChanges_card {k r h : ℕ} {I : Type} [Fintype I]
|
| 47 |
+
(F : Fin h → (I → Bool) → Bool) (q : Fin h)
|
| 48 |
+
(x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) :
|
| 49 |
+
(childChanges F q x j c).card = sensitivityAt (F q) (recursiveChild x j c) := by
|
| 50 |
+
simp [childChanges, sensitivityAt]
|
| 51 |
+
|
| 52 |
+
@[simp] theorem childJointChanges_card {k r h : ℕ} {I : Type} [Fintype I]
|
| 53 |
+
(F : Fin h → (I → Bool) → Bool) (q q' : Fin h)
|
| 54 |
+
(x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) :
|
| 55 |
+
(childJointChanges F q q' x j c).card =
|
| 56 |
+
jointSensitivityAt (F q) (F q') (recursiveChild x j c) := by
|
| 57 |
+
simp [childJointChanges, jointSensitivityAt]
|
| 58 |
+
|
| 59 |
+
theorem card_biUnion_le_mul {J I : Type} [DecidableEq I] (A : Finset J) (B : J → Finset I) (n : ℕ)
|
| 60 |
+
(hn : ∀ j ∈ A, (B j).card ≤ n) : (A.biUnion B).card ≤ A.card * n := by
|
| 61 |
+
calc
|
| 62 |
+
(A.biUnion B).card ≤ ∑ j ∈ A, (B j).card := Finset.card_biUnion_le
|
| 63 |
+
_ ≤ ∑ _j ∈ A, n := Finset.sum_le_sum hn
|
| 64 |
+
_ = A.card * n := by simp
|
| 65 |
+
|
| 66 |
+
theorem rowClause_joint_flip_change {k r h : ℕ} {I : Type} (T : Tournament k)
|
| 67 |
+
(label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool)
|
| 68 |
+
(q q' : Fin h) (x : ((Fin k × Fin r) × I) → Bool)
|
| 69 |
+
(i j : Fin k) (c : Fin r) (a : I)
|
| 70 |
+
(hc : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i)
|
| 71 |
+
(hc' : rowClause T label F q' (flip x {((j, c), a)}) i ≠ rowClause T label F q' x i) :
|
| 72 |
+
(j = i ∧ F (Fin.last h) (flip (recursiveChild x j c) {a}) ≠
|
| 73 |
+
F (Fin.last h) (recursiveChild x j c)) ∨
|
| 74 |
+
(T.Adj i j ∧ c = label i j ∧
|
| 75 |
+
F (gateIndex q) (flip (recursiveChild x j c) {a}) ≠
|
| 76 |
+
F (gateIndex q) (recursiveChild x j c) ∧
|
| 77 |
+
F (gateIndex q') (flip (recursiveChild x j c) {a}) ≠
|
| 78 |
+
F (gateIndex q') (recursiveChild x j c)) := by
|
| 79 |
+
rcases rowClause_flip_change T label F q x i j c a hc with ht | ⟨hij, hcl, hq⟩
|
| 80 |
+
· exact Or.inl ht
|
| 81 |
+
· rcases rowClause_flip_change T label F q' x i j c a hc' with ht | hg
|
| 82 |
+
· exact False.elim ((T.ne_of_adj hij) ht.1.symm)
|
| 83 |
+
· exact Or.inr ⟨hij, hcl, hq, hg.2.2⟩
|
| 84 |
+
|
| 85 |
+
end Paper320
|
| 86 |
+
|
| 87 |
+
end
|
| 88 |
+
|
| 89 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/RecursiveZero.lean
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.RecursiveCandidates
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! The zero-side recurrence separates the unique possible gate-list sink. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
theorem recursive_sensitivity_zero_at {k r h : ℕ} {I : Type} [Fintype I]
|
| 13 |
+
(T : Tournament k) (A : GoodLabeling T r)
|
| 14 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r)
|
| 15 |
+
(q : Fin h) (x : ((Fin k × Fin r) × I) → Bool)
|
| 16 |
+
(hx : recursiveFamily T A.label F q x = false) :
|
| 17 |
+
sensitivityAt (recursiveFamily T A.label F q) x ≤
|
| 18 |
+
16 * sideSensitivity F false + sideSensitivity F true + 3 * jointSensitivity F true := by
|
| 19 |
+
let TC := targetCandidates T A.label F q x
|
| 20 |
+
let GC := gateCandidates T A.label F q x
|
| 21 |
+
let SC := gateSinks T A.label F q x
|
| 22 |
+
let NC := GC \ SC
|
| 23 |
+
let w := gateWitness T A.label F q x
|
| 24 |
+
let U := TC.biUnion fun i => childChanges F (Fin.last h) x i (targetWitness F x hr i)
|
| 25 |
+
let V := NC.biUnion fun i => childJointChanges F (gateIndex q) (Fin.last h) x (w i) (A.label i (w i))
|
| 26 |
+
let W := SC.biUnion fun i => childChanges F (gateIndex q) x (w i) (A.label i (w i))
|
| 27 |
+
have hsub : (Finset.univ.filter fun p =>
|
| 28 |
+
recursiveFamily T A.label F q (flip x {p}) ≠ recursiveFamily T A.label F q x) ⊆ U ∪ (V ∪ W) := by
|
| 29 |
+
rintro ⟨⟨j, c⟩, a⟩ hp
|
| 30 |
+
have hchange := (Finset.mem_filter.mp hp).2
|
| 31 |
+
have hon : recursiveFamily T A.label F q (flip x {((j, c), a)}) = true := by
|
| 32 |
+
cases hy : recursiveFamily T A.label F q (flip x {((j, c), a)})
|
| 33 |
+
· exact False.elim (hchange (hy.trans hx.symm))
|
| 34 |
+
· rfl
|
| 35 |
+
obtain ⟨i, hi⟩ := (recursiveFamily_eq_true_iff T A.label F q _).mp hon
|
| 36 |
+
have hioff := (recursiveFamily_eq_false_iff T A.label F q x).mp hx i
|
| 37 |
+
rcases rowClause_repair_cases T A.label F q x i j c a hioff hi with
|
| 38 |
+
⟨hit, hji, htoff, hton⟩ | ⟨hig, hij, rfl, hgon, hgoff⟩
|
| 39 |
+
· subst j
|
| 40 |
+
have hc := targetWitness_unique T A.label F q x hr i hit c htoff
|
| 41 |
+
apply Finset.mem_union_left
|
| 42 |
+
apply Finset.mem_biUnion.mpr
|
| 43 |
+
refine ⟨i, hit, ?_⟩
|
| 44 |
+
have hn : F (Fin.last h) (flip (recursiveChild x i c) {a}) ≠
|
| 45 |
+
F (Fin.last h) (recursiveChild x i c) := by simp [hton, htoff]
|
| 46 |
+
simpa [childChanges, hc] using hn
|
| 47 |
+
· have hj := gateWitness_unique T A.label F q x i hig j hij hgon
|
| 48 |
+
apply Finset.mem_union_right
|
| 49 |
+
by_cases hs : i ∈ SC
|
| 50 |
+
· apply Finset.mem_union_right
|
| 51 |
+
apply Finset.mem_biUnion.mpr
|
| 52 |
+
refine ⟨i, hs, ?_⟩
|
| 53 |
+
have hn : F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠
|
| 54 |
+
F (gateIndex q) (recursiveChild x j (A.label i j)) := by simp [hgon, hgoff]
|
| 55 |
+
simpa [childChanges, w, hj] using hn
|
| 56 |
+
· have hwg := nonsink_gateWitness_mem T A.label F hF q x i hig hs
|
| 57 |
+
have hjg : j ∈ gateCandidates T A.label F q x := by simpa [hj] using hwg
|
| 58 |
+
have hton := (targetFailures_empty_iff F x j).mp (Finset.mem_filter.mp hjg).2.1 (A.label i j)
|
| 59 |
+
have htoff := hF.rejects_of_le (gateIndex_lt_last q).le hgoff
|
| 60 |
+
apply Finset.mem_union_left
|
| 61 |
+
apply Finset.mem_biUnion.mpr
|
| 62 |
+
refine ⟨i, Finset.mem_sdiff.mpr ⟨hig, hs⟩, ?_⟩
|
| 63 |
+
have hn :
|
| 64 |
+
F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠
|
| 65 |
+
F (gateIndex q) (recursiveChild x j (A.label i j)) ∧
|
| 66 |
+
F (Fin.last h) (flip (recursiveChild x j (A.label i j)) {a}) ≠
|
| 67 |
+
F (Fin.last h) (recursiveChild x j (A.label i j)) := by
|
| 68 |
+
simp [hgon, hgoff, hton, htoff]
|
| 69 |
+
simpa [childJointChanges, w, hj] using hn
|
| 70 |
+
have hU : U.card ≤ 16 * sideSensitivity F false := by
|
| 71 |
+
calc
|
| 72 |
+
U.card ≤ TC.card * sideSensitivity F false :=
|
| 73 |
+
card_biUnion_le_mul TC _ _ (fun i hi => by
|
| 74 |
+
rw [childChanges_card]
|
| 75 |
+
exact sensitivityAt_le_sideSensitivity F false _ _
|
| 76 |
+
(targetWitness_false T A.label F q x hr i hi))
|
| 77 |
+
_ ≤ 16 * sideSensitivity F false := Nat.mul_le_mul_right _
|
| 78 |
+
(Nat.le_of_lt (targetCandidates_card T A F hF q x hr))
|
| 79 |
+
have hV : V.card ≤ 3 * jointSensitivity F true := by
|
| 80 |
+
calc
|
| 81 |
+
V.card ≤ NC.card * jointSensitivity F true :=
|
| 82 |
+
card_biUnion_le_mul NC _ _ (fun i hi => by
|
| 83 |
+
have hg := Finset.mem_sdiff.mp hi
|
| 84 |
+
have hw := nonsink_gateWitness_mem T A.label F hF q x i hg.1 hg.2
|
| 85 |
+
have hgate := (gateWitness_spec T A.label F q x i hg.1).2
|
| 86 |
+
have htarget := (targetFailures_empty_iff F x _).mp (Finset.mem_filter.mp hw).2.1
|
| 87 |
+
(A.label i (w i))
|
| 88 |
+
rw [childJointChanges_card]
|
| 89 |
+
exact jointSensitivityAt_le_jointSensitivity F true _ _ _ (gateIndex_lt_last q) hgate htarget)
|
| 90 |
+
_ ≤ GC.card * jointSensitivity F true := Nat.mul_le_mul_right _ (Finset.card_le_card Finset.sdiff_subset)
|
| 91 |
+
_ ≤ 3 * jointSensitivity F true := Nat.mul_le_mul_right _ (gateCandidates_card T A.label F hF q x)
|
| 92 |
+
have hW : W.card ≤ sideSensitivity F true := by
|
| 93 |
+
calc
|
| 94 |
+
W.card ≤ SC.card * sideSensitivity F true :=
|
| 95 |
+
card_biUnion_le_mul SC _ _ (fun i hi => by
|
| 96 |
+
rw [childChanges_card]
|
| 97 |
+
exact sensitivityAt_le_sideSensitivity F true _ _
|
| 98 |
+
(gateWitness_spec T A.label F q x i (Finset.mem_filter.mp hi).1).2)
|
| 99 |
+
_ ≤ 1 * sideSensitivity F true := Nat.mul_le_mul_right _ (gateSinks_card T A.label F q x)
|
| 100 |
+
_ = _ := Nat.one_mul _
|
| 101 |
+
calc
|
| 102 |
+
sensitivityAt (recursiveFamily T A.label F q) x ≤ (U ∪ (V ∪ W)).card := Finset.card_le_card hsub
|
| 103 |
+
_ ≤ U.card + (V ∪ W).card := Finset.card_union_le _ _
|
| 104 |
+
_ ≤ U.card + (V.card + W.card) := Nat.add_le_add_left (Finset.card_union_le _ _) _
|
| 105 |
+
_ ≤ 16 * sideSensitivity F false + (3 * jointSensitivity F true + sideSensitivity F true) :=
|
| 106 |
+
Nat.add_le_add hU (Nat.add_le_add hV hW)
|
| 107 |
+
_ = _ := by omega
|
| 108 |
+
|
| 109 |
+
theorem recursive_side_zero {k r h : ℕ} {I : Type} [Fintype I]
|
| 110 |
+
(T : Tournament k) (A : GoodLabeling T r)
|
| 111 |
+
(F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) :
|
| 112 |
+
sideSensitivity (recursiveFamily T A.label F) false ≤
|
| 113 |
+
16 * sideSensitivity F false + sideSensitivity F true + 3 * jointSensitivity F true := by
|
| 114 |
+
apply sideSensitivity_le
|
| 115 |
+
exact fun q x hx => recursive_sensitivity_zero_at T A F hF hr q x hx
|
| 116 |
+
|
| 117 |
+
end Paper320
|
| 118 |
+
|
| 119 |
+
end
|
| 120 |
+
|
| 121 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/Reindex.lean
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.Basic
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! Coordinate equivalences preserve the two literal Boolean complexity measures. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
variable {I J : Type}
|
| 13 |
+
|
| 14 |
+
def reindex (e : I ≃ J) (f : (I → Bool) → Bool) : (J → Bool) → Bool :=
|
| 15 |
+
fun x => f (fun i => x (e i))
|
| 16 |
+
|
| 17 |
+
theorem flip_reindex (e : I ≃ J) (x : J → Bool) (B : Finset I) :
|
| 18 |
+
(fun i => flip x (B.map e.toEmbedding) (e i)) =
|
| 19 |
+
flip (fun i => x (e i)) B := by
|
| 20 |
+
funext i
|
| 21 |
+
simp [flip]
|
| 22 |
+
|
| 23 |
+
theorem flip_reindex_singleton (e : I ≃ J) (x : J → Bool) (i : I) :
|
| 24 |
+
(fun a => flip x {e i} (e a)) = flip (fun a => x (e a)) {i} := by
|
| 25 |
+
simpa using flip_reindex e x {i}
|
| 26 |
+
|
| 27 |
+
@[simp] theorem reindex_symm (e : I ≃ J) (f : (I → Bool) → Bool) :
|
| 28 |
+
reindex e.symm (reindex e f) = f := by
|
| 29 |
+
funext x
|
| 30 |
+
simp [reindex]
|
| 31 |
+
|
| 32 |
+
section Finite
|
| 33 |
+
variable [Fintype I] [Fintype J]
|
| 34 |
+
|
| 35 |
+
theorem sensitivityAt_reindex (e : I ≃ J) (f : (I → Bool) → Bool) (x : J → Bool) :
|
| 36 |
+
sensitivityAt (reindex e f) x = sensitivityAt f (fun i => x (e i)) := by
|
| 37 |
+
have hs : (Finset.univ.filter fun j =>
|
| 38 |
+
reindex e f (flip x {j}) ≠ reindex e f x).map e.symm.toEmbedding =
|
| 39 |
+
Finset.univ.filter (fun i =>
|
| 40 |
+
f (flip (fun a => x (e a)) {i}) ≠ f (fun a => x (e a))) := by
|
| 41 |
+
ext i
|
| 42 |
+
simp only [Finset.mem_map_equiv, Equiv.symm_symm, Finset.mem_filter,
|
| 43 |
+
Finset.mem_univ, true_and]
|
| 44 |
+
change f (fun a => flip x {e i} (e a)) ≠ f (fun a => x (e a)) ↔ _
|
| 45 |
+
rw [flip_reindex_singleton]
|
| 46 |
+
simpa only [sensitivityAt, Finset.card_map] using congrArg Finset.card hs
|
| 47 |
+
|
| 48 |
+
theorem sensitivity_reindex (e : I ≃ J) (f : (I → Bool) → Bool) :
|
| 49 |
+
sensitivity (reindex e f) = sensitivity f := by
|
| 50 |
+
apply Nat.le_antisymm
|
| 51 |
+
· apply sensitivity_le
|
| 52 |
+
intro x
|
| 53 |
+
rw [sensitivityAt_reindex]
|
| 54 |
+
exact sensitivityAt_le_sensitivity f _
|
| 55 |
+
· apply sensitivity_le
|
| 56 |
+
intro x
|
| 57 |
+
have h := sensitivityAt_le_sensitivity (reindex e f) (fun j => x (e.symm j))
|
| 58 |
+
rw [sensitivityAt_reindex] at h
|
| 59 |
+
simpa only [Equiv.symm_apply_apply] using h
|
| 60 |
+
|
| 61 |
+
theorem blockSensitivityAt_le_reindex (e : I ≃ J) (f : (I → Bool) → Bool)
|
| 62 |
+
(x : J → Bool) :
|
| 63 |
+
blockSensitivityAt f (fun i => x (e i)) ≤ blockSensitivityAt (reindex e f) x := by
|
| 64 |
+
apply blockSensitivityAt_le
|
| 65 |
+
intro blocks hd hb
|
| 66 |
+
have h := le_blockSensitivityAt_of_family (reindex e f) x
|
| 67 |
+
(fun B : blocks => B.val.map e.toEmbedding)
|
| 68 |
+
(fun B => (hb B.val B.property).1.map (f := e.toEmbedding))
|
| 69 |
+
(by
|
| 70 |
+
intro A B hAB
|
| 71 |
+
apply (Finset.disjoint_map e.toEmbedding).mpr
|
| 72 |
+
exact hd A.val A.property B.val B.property (fun h => hAB (Subtype.ext h)))
|
| 73 |
+
(by
|
| 74 |
+
intro B
|
| 75 |
+
change f (fun i => flip x (B.val.map e.toEmbedding) (e i)) ≠ _
|
| 76 |
+
rw [flip_reindex]
|
| 77 |
+
exact (hb B.val B.property).2)
|
| 78 |
+
simpa only [Fintype.card_coe] using h
|
| 79 |
+
|
| 80 |
+
theorem blockSensitivityAt_reindex (e : I ≃ J) (f : (I → Bool) → Bool)
|
| 81 |
+
(x : J → Bool) :
|
| 82 |
+
blockSensitivityAt (reindex e f) x = blockSensitivityAt f (fun i => x (e i)) := by
|
| 83 |
+
apply Nat.le_antisymm
|
| 84 |
+
· have h := blockSensitivityAt_le_reindex e.symm (reindex e f) (fun i => x (e i))
|
| 85 |
+
simpa only [Equiv.apply_symm_apply, reindex_symm] using h
|
| 86 |
+
· exact blockSensitivityAt_le_reindex e f x
|
| 87 |
+
|
| 88 |
+
theorem blockSensitivity_reindex (e : I ≃ J) (f : (I → Bool) → Bool) :
|
| 89 |
+
blockSensitivity (reindex e f) = blockSensitivity f := by
|
| 90 |
+
apply Nat.le_antisymm
|
| 91 |
+
· apply blockSensitivity_le
|
| 92 |
+
intro x
|
| 93 |
+
rw [blockSensitivityAt_reindex]
|
| 94 |
+
exact blockSensitivityAt_le_blockSensitivity f _
|
| 95 |
+
· apply blockSensitivity_le
|
| 96 |
+
intro x
|
| 97 |
+
have h := blockSensitivityAt_le_blockSensitivity (reindex e f) (fun j => x (e.symm j))
|
| 98 |
+
rw [blockSensitivityAt_reindex] at h
|
| 99 |
+
simpa only [Equiv.symm_apply_apply] using h
|
| 100 |
+
|
| 101 |
+
end Finite
|
| 102 |
+
end Paper320
|
| 103 |
+
|
| 104 |
+
end
|
| 105 |
+
|
| 106 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/ScalarBounds.lean
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! Scalar bounds for the two coupled sensitivity profiles. -/
|
| 6 |
+
|
| 7 |
+
namespace Paper320
|
| 8 |
+
|
| 9 |
+
theorem geometric_error_le {d n : ℕ} (hn : n ≤ d) {ε L : ℝ}
|
| 10 |
+
(hε : 0 ≤ ε) (hL : 0 ≤ L) (hbudget : ε * 3 ^ (d + 1) ≤ 2) :
|
| 11 |
+
(3 / 2 : ℝ) * ε * L * (3 ^ n - 1) ≤ L := by
|
| 12 |
+
have hp : (3 : ℝ) ^ (n + 1) ≤ 3 ^ (d + 1) :=
|
| 13 |
+
pow_le_pow_right₀ (by norm_num) (Nat.succ_le_succ hn)
|
| 14 |
+
have hb := (mul_le_mul_of_nonneg_left hp hε).trans hbudget
|
| 15 |
+
have hm := mul_le_mul_of_nonneg_right hb hL
|
| 16 |
+
rw [pow_succ] at hm
|
| 17 |
+
nlinarith [mul_nonneg hε hL]
|
| 18 |
+
|
| 19 |
+
theorem coupled_profiles_bound (d : ℕ) (u v : ℕ → ℝ) (ε L : ℝ)
|
| 20 |
+
(hε : 0 ≤ ε) (hL : 0 ≤ L) (hbudget : ε * 3 ^ (d + 1) ≤ 2)
|
| 21 |
+
(hu0 : u 0 ≤ L) (hv0 : v 0 ≤ 0)
|
| 22 |
+
(hu : ∀ n < d, u (n + 1) ≤ (1 + ε) * u n + 3 * v n)
|
| 23 |
+
(hv : ∀ n < d, v (n + 1) ≤ ε * u n + 3 * v n) :
|
| 24 |
+
∀ n ≤ d, u n ≤ 2 * L ∧ v n ≤ ε * L * (3 ^ n - 1) := by
|
| 25 |
+
have strong : ∀ n ≤ d,
|
| 26 |
+
u n ≤ L + (3 / 2 : ℝ) * ε * L * (3 ^ n - 1) ∧
|
| 27 |
+
v n ≤ ε * L * (3 ^ n - 1) := by
|
| 28 |
+
intro n
|
| 29 |
+
induction n with
|
| 30 |
+
| zero =>
|
| 31 |
+
intro _
|
| 32 |
+
simpa using And.intro hu0 hv0
|
| 33 |
+
| succ n ih =>
|
| 34 |
+
intro hn
|
| 35 |
+
have hnd : n ≤ d := by omega
|
| 36 |
+
obtain ⟨hun, hvn⟩ := ih hnd
|
| 37 |
+
have he := geometric_error_le hnd hε hL hbudget
|
| 38 |
+
have hun' : u n ≤ 2 * L := by linarith
|
| 39 |
+
have heu := mul_le_mul_of_nonneg_left hun' hε
|
| 40 |
+
have hnu := hu n (by omega)
|
| 41 |
+
have hnv := hv n (by omega)
|
| 42 |
+
constructor
|
| 43 |
+
· rw [pow_succ]
|
| 44 |
+
nlinarith [mul_nonneg hε hL]
|
| 45 |
+
· rw [pow_succ]
|
| 46 |
+
nlinarith
|
| 47 |
+
intro n hn
|
| 48 |
+
obtain ⟨hun, hvn⟩ := strong n hn
|
| 49 |
+
have he := geometric_error_le hn hε hL hbudget
|
| 50 |
+
exact ⟨by linarith, hvn⟩
|
| 51 |
+
|
| 52 |
+
end Paper320
|
| 53 |
+
|
| 54 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/SeedAmplification.lean
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.ConstructedSeed
|
| 2 |
+
import OAI.Combinatorics.Sensitivity.PowerAmplification
|
| 3 |
+
import OAI.Combinatorics.Sensitivity.SeparationArithmetic
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! The depth-nine seed gives a fixed exponent and explicit ratios. -/
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
open scoped Classical
|
| 11 |
+
|
| 12 |
+
namespace Paper320
|
| 13 |
+
|
| 14 |
+
theorem constructed_power_family :
|
| 15 |
+
∃ α : ℝ, 2 < α ∧
|
| 16 |
+
∃ (n : ℕ → ℕ) (F : ∀ m : ℕ, (Fin (n m) → Bool) → Bool),
|
| 17 |
+
(∀ m : ℕ,
|
| 18 |
+
0 < n m ∧ F m (fun _ => false) = false ∧
|
| 19 |
+
(∃ x y, F m x ≠ F m y) ∧
|
| 20 |
+
(sensitivity (F m) : ℝ) ^ α ≤ (blockSensitivityAt (F m) (fun _ => false) : ℝ) ∧
|
| 21 |
+
((128 : ℝ) / 121) ^ m ≤
|
| 22 |
+
(blockSensitivity (F m) : ℝ) / (sensitivity (F m) : ℝ) ^ 2) ∧
|
| 23 |
+
Filter.Tendsto
|
| 24 |
+
(fun m : ℕ => (blockSensitivityAt (F m) (fun _ => false) : ℝ))
|
| 25 |
+
Filter.atTop Filter.atTop := by
|
| 26 |
+
let M : ℕ := 9 ^ 10
|
| 27 |
+
have hM : 0 < M := by dsimp [M]; positivity
|
| 28 |
+
obtain ⟨f, _, hf, _, hs, hb⟩ := exists_constructed_seed 9 M (by norm_num) (by rfl)
|
| 29 |
+
change sensitivity f ≤ 22 * M ^ 10 at hs
|
| 30 |
+
obtain ⟨hA, hB⟩ := depth_nine_seed_gap M hM
|
| 31 |
+
obtain ⟨hα, hall, hlim⟩ := power_amplification f hf (22 * M ^ 10)
|
| 32 |
+
(M ^ 2 * (2 * M ^ 2 + 1) ^ 9) hs hb hA hB
|
| 33 |
+
refine ⟨_, hα, _, (fun m => iterateFin f m), ?_, hlim⟩
|
| 34 |
+
intro m
|
| 35 |
+
obtain ⟨hn, hzero, hnc, hpow, hratio⟩ := hall m
|
| 36 |
+
refine ⟨hn, hzero, hnc, hpow, ?_⟩
|
| 37 |
+
apply le_trans _ hratio
|
| 38 |
+
apply pow_le_pow_left₀ (by norm_num)
|
| 39 |
+
have hMr : (0 : ℝ) < M := by exact_mod_cast hM
|
| 40 |
+
simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one]
|
| 41 |
+
using depth_nine_seed_ratio hMr
|
| 42 |
+
|
| 43 |
+
end Paper320
|
| 44 |
+
|
| 45 |
+
end
|
| 46 |
+
|
| 47 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/Separation.lean
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.SeedAmplification
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! Quantitative, unbounded quadratic, and fixed-power separations of sensitivity. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
theorem quantitative_separation (d : ℕ) (hd : 1 ≤ d) :
|
| 13 |
+
∃ (n : ℕ) (f : (Fin n → Bool) → Bool),
|
| 14 |
+
0 < n ∧ f (fun _ => false) = false ∧
|
| 15 |
+
(∃ x y : Fin n → Bool, f x ≠ f y) ∧
|
| 16 |
+
(2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤
|
| 17 |
+
(blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by
|
| 18 |
+
let M : ℕ := 9 ^ (d + 1)
|
| 19 |
+
have hM : 0 < M := by dsimp [M]; positivity
|
| 20 |
+
obtain ⟨f, hn, hf, hnc, hs, hb⟩ := exists_constructed_seed d M hd (by rfl)
|
| 21 |
+
exact ⟨_, f, hn, hf, hnc, quantitative_ratio_of_bounds f d M hM hnc hs hb⟩
|
| 22 |
+
|
| 23 |
+
theorem unbounded_quadratic_separation (C : ℝ) (hC : 0 < C) :
|
| 24 |
+
∃ (n : ℕ) (f : (Fin n → Bool) → Bool),
|
| 25 |
+
0 < n ∧ f (fun _ => false) = false ∧
|
| 26 |
+
(∃ x y : Fin n → Bool, f x ≠ f y) ∧
|
| 27 |
+
C * (sensitivity f : ℝ) ^ 2 < (blockSensitivity f : ℝ) := by
|
| 28 |
+
obtain ⟨d, hd, hlarge⟩ := ((Filter.eventually_ge_atTop (1 : ℕ)).and
|
| 29 |
+
(quantitative_ratio_tendsto.eventually_gt_atTop (max C 0))).exists
|
| 30 |
+
rw [max_eq_left hC.le] at hlarge
|
| 31 |
+
obtain ⟨n, f, hn, hf, hnc, hratio⟩ := quantitative_separation d hd
|
| 32 |
+
have hs : (0 : ℝ) < sensitivity f := by
|
| 33 |
+
exact_mod_cast sensitivity_pos_of_nonconstant f hnc
|
| 34 |
+
exact ⟨n, f, hn, hf, hnc, (lt_div_iff₀ (pow_pos hs 2)).mp (hlarge.trans_le hratio)⟩
|
| 35 |
+
|
| 36 |
+
theorem fixed_power_separation :
|
| 37 |
+
∃ α : ℝ, 2 < α ∧
|
| 38 |
+
∃ (n : ℕ → ℕ) (F : ∀ m : ℕ, (Fin (n m) → Bool) → Bool),
|
| 39 |
+
(∀ m : ℕ, 1 ≤ m →
|
| 40 |
+
0 < n m ∧ F m (fun _ => false) = false ∧
|
| 41 |
+
(∃ x y : Fin (n m) → Bool, F m x ≠ F m y) ∧
|
| 42 |
+
(sensitivity (F m) : ℝ) ^ α ≤
|
| 43 |
+
(blockSensitivityAt (F m) (fun _ => false) : ℝ)) ∧
|
| 44 |
+
Filter.Tendsto
|
| 45 |
+
(fun m : ℕ => (blockSensitivityAt (F m) (fun _ => false) : ℝ))
|
| 46 |
+
Filter.atTop Filter.atTop := by
|
| 47 |
+
obtain ⟨α, hα, n, F, hall, hlim⟩ := constructed_power_family
|
| 48 |
+
refine ⟨α, hα, n, F, ?_, hlim⟩
|
| 49 |
+
intro m _
|
| 50 |
+
obtain ⟨hn, hf, hnc, hpow, _⟩ := hall m
|
| 51 |
+
exact ⟨hn, hf, hnc, hpow⟩
|
| 52 |
+
|
| 53 |
+
end Paper320
|
| 54 |
+
|
| 55 |
+
end
|
| 56 |
+
|
| 57 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/SeparationArithmetic.lean
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.Basic
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! The exact final ratio, the depth-nine seed gap, and exponential divergence. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open Filter
|
| 9 |
+
open scoped Topology
|
| 10 |
+
|
| 11 |
+
namespace Paper320
|
| 12 |
+
|
| 13 |
+
theorem seed_ratio_identity (d : ℕ) {L M k : ℝ} (hL : L ≠ 0) (hM : M ≠ 0) :
|
| 14 |
+
(M ^ 2 * k ^ d) / (2 * L * M ^ (d + 1)) ^ 2 =
|
| 15 |
+
(k / M ^ 2) ^ d / (4 * L ^ 2) := by
|
| 16 |
+
have hp : (M ^ 2) ^ d = (M ^ d) ^ 2 := by
|
| 17 |
+
rw [← pow_mul, ← pow_mul, Nat.mul_comm 2 d]
|
| 18 |
+
rw [div_pow, hp, pow_succ]
|
| 19 |
+
field_simp
|
| 20 |
+
ring
|
| 21 |
+
|
| 22 |
+
theorem seed_ratio_lower (d : ℕ) {M : ℝ} (hM : 0 < M) :
|
| 23 |
+
(2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤
|
| 24 |
+
(M ^ 2 * (2 * M ^ 2 + 1) ^ d) /
|
| 25 |
+
(2 * ((d : ℝ) + 2) * M ^ (d + 1)) ^ 2 := by
|
| 26 |
+
rw [seed_ratio_identity d (by positivity) (ne_of_gt hM)]
|
| 27 |
+
have hk : 2 ≤ (2 * M ^ 2 + 1) / M ^ 2 := by
|
| 28 |
+
apply (le_div_iff₀ (pow_pos hM 2)).mpr
|
| 29 |
+
linarith
|
| 30 |
+
exact div_le_div_of_nonneg_right (pow_le_pow_left₀ (by norm_num) hk d) (by positivity)
|
| 31 |
+
|
| 32 |
+
theorem ratio_of_bounds {I : Type} [Fintype I] (f : (I → Bool) → Bool)
|
| 33 |
+
(s b : ℝ) (hpos : 0 < (sensitivity f : ℝ))
|
| 34 |
+
(hs : (sensitivity f : ℝ) ≤ s) (hb : b ≤ (blockSensitivityAt f (fun _ => false) : ℝ))
|
| 35 |
+
(hb0 : 0 ≤ b) :
|
| 36 |
+
b / s ^ 2 ≤ (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by
|
| 37 |
+
have hsp : 0 < s := lt_of_lt_of_le hpos hs
|
| 38 |
+
apply (le_div_iff₀ (pow_pos hpos 2)).mpr
|
| 39 |
+
calc
|
| 40 |
+
_ ≤ (b / s ^ 2) * s ^ 2 :=
|
| 41 |
+
mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hpos.le hs 2) (div_nonneg hb0 (sq_nonneg s))
|
| 42 |
+
_ = b := div_mul_cancel₀ _ (ne_of_gt (pow_pos hsp 2))
|
| 43 |
+
_ ≤ (blockSensitivityAt f (fun _ => false) : ℝ) := hb
|
| 44 |
+
_ ≤ (blockSensitivity f : ℝ) := by
|
| 45 |
+
exact_mod_cast blockSensitivityAt_le_blockSensitivity f (fun _ => false)
|
| 46 |
+
|
| 47 |
+
theorem quantitative_ratio_of_bounds {I : Type} [Fintype I]
|
| 48 |
+
(f : (I → Bool) → Bool) (d M : ℕ) (hM : 0 < M)
|
| 49 |
+
(hnc : ∃ x y, f x ≠ f y)
|
| 50 |
+
(hs : sensitivity f ≤ 2 * (d + 2) * M ^ (d + 1))
|
| 51 |
+
(hb : M ^ 2 * (2 * M ^ 2 + 1) ^ d ≤ blockSensitivityAt f (fun _ => false)) :
|
| 52 |
+
(2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤
|
| 53 |
+
(blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by
|
| 54 |
+
have hMr : 0 < (M : ℝ) := by exact_mod_cast hM
|
| 55 |
+
apply (seed_ratio_lower d hMr).trans
|
| 56 |
+
apply ratio_of_bounds
|
| 57 |
+
· exact_mod_cast sensitivity_pos_of_nonconstant f hnc
|
| 58 |
+
· exact_mod_cast hs
|
| 59 |
+
· exact_mod_cast hb
|
| 60 |
+
· positivity
|
| 61 |
+
|
| 62 |
+
theorem depth_nine_ratio :
|
| 63 |
+
(2 : ℝ) ^ 9 / (4 * ((9 : ℝ) + 2) ^ 2) = 128 / 121 := by norm_num
|
| 64 |
+
|
| 65 |
+
theorem depth_nine_ratio_gt_one : (1 : ℝ) < 128 / 121 := by norm_num
|
| 66 |
+
|
| 67 |
+
theorem depth_nine_seed_ratio {M : ℝ} (hM : 0 < M) :
|
| 68 |
+
(128 : ℝ) / 121 ≤ M ^ 2 * (2 * M ^ 2 + 1) ^ 9 / (22 * M ^ 10) ^ 2 := by
|
| 69 |
+
have h := seed_ratio_lower 9 hM
|
| 70 |
+
norm_num at h ⊢
|
| 71 |
+
exact h
|
| 72 |
+
|
| 73 |
+
theorem depth_nine_seed_gap (M : ℕ) (hM : 0 < M) :
|
| 74 |
+
1 < 22 * M ^ 10 ∧ (22 * M ^ 10) ^ 2 < M ^ 2 * (2 * M ^ 2 + 1) ^ 9 := by
|
| 75 |
+
constructor
|
| 76 |
+
· have hp := pow_pos hM 10
|
| 77 |
+
omega
|
| 78 |
+
· have hp := pow_pos hM 20
|
| 79 |
+
have hmono : M ^ 2 * (2 * M ^ 2) ^ 9 ≤ M ^ 2 * (2 * M ^ 2 + 1) ^ 9 := by
|
| 80 |
+
gcongr
|
| 81 |
+
omega
|
| 82 |
+
calc
|
| 83 |
+
_ = 484 * M ^ 20 := by ring
|
| 84 |
+
_ < 512 * M ^ 20 := by omega
|
| 85 |
+
_ = M ^ 2 * (2 * M ^ 2) ^ 9 := by ring
|
| 86 |
+
_ ≤ _ := hmono
|
| 87 |
+
|
| 88 |
+
theorem quantitative_ratio_tendsto :
|
| 89 |
+
Tendsto (fun d : ℕ => (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2)) atTop atTop := by
|
| 90 |
+
have hb := (tendsto_pow_const_div_const_pow_of_one_lt 2 (by norm_num : (1 : ℝ) < 2)).comp
|
| 91 |
+
(tendsto_add_atTop_nat 2)
|
| 92 |
+
have hz : Tendsto (fun d : ℕ => 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d)
|
| 93 |
+
atTop (𝓝 0) := by
|
| 94 |
+
have h := hb.const_mul (16 : ℝ)
|
| 95 |
+
convert h using 1
|
| 96 |
+
· funext d
|
| 97 |
+
simp only [Function.comp_apply]
|
| 98 |
+
push_cast
|
| 99 |
+
rw [pow_add]
|
| 100 |
+
norm_num
|
| 101 |
+
ring
|
| 102 |
+
· simp
|
| 103 |
+
have hr : Tendsto (fun d : ℕ => 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d)
|
| 104 |
+
atTop (𝓝[>] (0 : ℝ)) := by
|
| 105 |
+
apply tendsto_nhdsWithin_iff.mpr
|
| 106 |
+
refine ⟨hz, Filter.Eventually.of_forall ?_⟩
|
| 107 |
+
intro d
|
| 108 |
+
change 0 < 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d
|
| 109 |
+
positivity
|
| 110 |
+
simpa only [Function.comp_def, inv_div] using tendsto_inv_nhdsGT_zero.comp hr
|
| 111 |
+
|
| 112 |
+
end Paper320
|
| 113 |
+
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/Tournament.lean
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib.Combinatorics.Digraph.Basic
|
| 2 |
+
import Mathlib.Data.Finset.Card
|
| 3 |
+
import Mathlib.Data.Finset.Prod
|
| 4 |
+
import Mathlib.Data.Finset.Powerset
|
| 5 |
+
import Mathlib.Data.Fintype.BigOperators
|
| 6 |
+
|
| 7 |
+
namespace OAI
|
| 8 |
+
|
| 9 |
+
/-! Finite tournaments and the target-constant labeling condition. -/
|
| 10 |
+
|
| 11 |
+
noncomputable section
|
| 12 |
+
open scoped Classical
|
| 13 |
+
|
| 14 |
+
namespace Paper320
|
| 15 |
+
|
| 16 |
+
structure Tournament (k : ℕ) extends Digraph (Fin k) where
|
| 17 |
+
loopless : ∀ i, ¬ Adj i i
|
| 18 |
+
edge_compl : ∀ {i j}, i ≠ j → (Adj i j ↔ ¬ Adj j i)
|
| 19 |
+
|
| 20 |
+
structure RegularTournament (M : ℕ) extends Tournament (2 * M^2 + 1) where
|
| 21 |
+
outdegree : ∀ i, (Finset.univ.filter (Adj i)).card = M^2
|
| 22 |
+
|
| 23 |
+
structure GoodLabeling {k : ℕ} (T : Tournament k) (r : ℕ) where
|
| 24 |
+
label : Fin k → Fin k → Fin r
|
| 25 |
+
good : ∀ I : Finset (Fin k), I.card = 16 → ∀ m : Fin k → Fin r,
|
| 26 |
+
∃ i ∈ I, ∃ j ∈ I, T.Adj i j ∧ label i j ≠ m j
|
| 27 |
+
|
| 28 |
+
namespace Tournament
|
| 29 |
+
variable {k : ℕ} (T : Tournament k)
|
| 30 |
+
|
| 31 |
+
theorem ne_of_adj {i j : Fin k} (h : T.Adj i j) : i ≠ j := by
|
| 32 |
+
rintro rfl
|
| 33 |
+
exact T.loopless i h
|
| 34 |
+
|
| 35 |
+
theorem not_adj_reverse {i j : Fin k} (h : T.Adj i j) : ¬ T.Adj j i :=
|
| 36 |
+
(T.edge_compl (T.ne_of_adj h)).mp h
|
| 37 |
+
|
| 38 |
+
theorem adj_or_reverse {i j : Fin k} (h : i ≠ j) : T.Adj i j ∨ T.Adj j i := by
|
| 39 |
+
by_cases hh : T.Adj j i
|
| 40 |
+
· exact Or.inr hh
|
| 41 |
+
· exact Or.inl ((T.edge_compl h).mpr hh)
|
| 42 |
+
|
| 43 |
+
theorem internal_sink_unique {I : Finset (Fin k)} {i j : Fin k}
|
| 44 |
+
(hi : i ∈ I) (hj : j ∈ I)
|
| 45 |
+
(hsi : ∀ v ∈ I, ¬ T.Adj i v) (hsj : ∀ v ∈ I, ¬ T.Adj j v) : i = j := by
|
| 46 |
+
by_contra h
|
| 47 |
+
rcases T.adj_or_reverse h with hh | hh
|
| 48 |
+
· exact hsi j hj hh
|
| 49 |
+
· exact hsj i hi hh
|
| 50 |
+
|
| 51 |
+
end Tournament
|
| 52 |
+
|
| 53 |
+
namespace GoodLabeling
|
| 54 |
+
variable {k r : ℕ} {T : Tournament k} (A : GoodLabeling T r)
|
| 55 |
+
|
| 56 |
+
theorem good_implies_card_lt_sixteen (I : Finset (Fin k)) (m : Fin k → Fin r)
|
| 57 |
+
(h : ∀ i ∈ I, ∀ j ∈ I, T.Adj i j → A.label i j = m j) : I.card < 16 := by
|
| 58 |
+
by_contra hn
|
| 59 |
+
obtain ⟨J, hJI, hJ⟩ := Finset.exists_subset_card_eq (show 16 ≤ I.card by omega)
|
| 60 |
+
obtain ⟨i, hi, j, hj, hij, hne⟩ := A.good J hJ m
|
| 61 |
+
exact hne (h i (hJI hi) j (hJI hj) hij)
|
| 62 |
+
|
| 63 |
+
end GoodLabeling
|
| 64 |
+
end Paper320
|
| 65 |
+
|
| 66 |
+
end
|
| 67 |
+
|
| 68 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/TournamentCounts.lean
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.Tournament
|
| 2 |
+
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
|
| 3 |
+
import Mathlib.Algebra.Order.BigOperators.Group.Finset
|
| 4 |
+
import Mathlib.Tactic.Linarith
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
/-! The exact internal edge count and the small gate-candidate bound. -/
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
open scoped Classical BigOperators
|
| 12 |
+
|
| 13 |
+
namespace Paper320.Tournament
|
| 14 |
+
variable {k : ℕ} (T : Tournament k)
|
| 15 |
+
|
| 16 |
+
def internalEdges (I : Finset (Fin k)) : Finset (Fin k × Fin k) :=
|
| 17 |
+
(I ×ˢ I).filter fun p => T.Adj p.1 p.2
|
| 18 |
+
|
| 19 |
+
theorem card_internalEdges (I : Finset (Fin k)) :
|
| 20 |
+
(T.internalEdges I).card = I.card.choose 2 := by
|
| 21 |
+
let U := T.internalEdges I
|
| 22 |
+
let V := (I ×ˢ I).filter fun p => T.Adj p.2 p.1
|
| 23 |
+
have hd : Disjoint U V := by
|
| 24 |
+
apply Finset.disjoint_left.mpr
|
| 25 |
+
intro p hp hq
|
| 26 |
+
exact T.not_adj_reverse (Finset.mem_filter.mp hp).2 (Finset.mem_filter.mp hq).2
|
| 27 |
+
have hu : U.disjUnion V hd = I.offDiag := by
|
| 28 |
+
ext ⟨i,j⟩
|
| 29 |
+
simp only [Finset.mem_disjUnion, U, V, internalEdges, Finset.mem_filter,
|
| 30 |
+
Finset.mem_product, Finset.mem_offDiag]
|
| 31 |
+
constructor
|
| 32 |
+
· rintro (⟨⟨hi,hj⟩,h⟩ | ⟨⟨hi,hj⟩,h⟩)
|
| 33 |
+
· exact ⟨hi,hj,T.ne_of_adj h⟩
|
| 34 |
+
· exact ⟨hi,hj,(T.ne_of_adj h).symm⟩
|
| 35 |
+
· rintro ⟨hi,hj,hne⟩
|
| 36 |
+
exact (T.adj_or_reverse hne).imp (fun h => ⟨⟨hi,hj⟩,h⟩) (fun h => ⟨⟨hi,hj⟩,h⟩)
|
| 37 |
+
have hs : U.card = V.card := Finset.card_equiv (Equiv.prodComm (Fin k) (Fin k)) (by
|
| 38 |
+
intro p
|
| 39 |
+
simp only [U,V,internalEdges,Finset.mem_filter,Finset.mem_product,Equiv.prodComm_apply]
|
| 40 |
+
tauto)
|
| 41 |
+
have hc := congrArg Finset.card hu
|
| 42 |
+
rw [Finset.card_disjUnion, ← hs, Finset.offDiag_card] at hc
|
| 43 |
+
rw [Nat.choose_two_right, Nat.mul_sub_one]
|
| 44 |
+
change U.card = _
|
| 45 |
+
omega
|
| 46 |
+
|
| 47 |
+
theorem sum_outdegree_eq (I : Finset (Fin k)) :
|
| 48 |
+
∑ i ∈ I, (I.filter (T.Adj i)).card = (T.internalEdges I).card := by
|
| 49 |
+
simp only [internalEdges, Finset.card_eq_sum_ones, Finset.sum_filter, Finset.sum_product]
|
| 50 |
+
|
| 51 |
+
theorem card_le_three_of_outdegree_le_one (I : Finset (Fin k))
|
| 52 |
+
(h : ∀ i ∈ I, (I.filter (T.Adj i)).card ≤ 1) : I.card ≤ 3 := by
|
| 53 |
+
have hsum := Finset.sum_le_sum h
|
| 54 |
+
have hc : I.card.choose 2 ≤ I.card := by
|
| 55 |
+
rw [← T.card_internalEdges, ← T.sum_outdegree_eq]
|
| 56 |
+
simpa only [Finset.sum_const_nat, mul_one] using hsum
|
| 57 |
+
have hdouble : I.card * (I.card - 1) ≤ 2 * I.card + 1 := by
|
| 58 |
+
rw [Nat.choose_two_right] at hc
|
| 59 |
+
omega
|
| 60 |
+
by_contra hn
|
| 61 |
+
have h4 : 4 ≤ I.card := by omega
|
| 62 |
+
have ht : I.card - 1 + 1 = I.card := by omega
|
| 63 |
+
nlinarith
|
| 64 |
+
|
| 65 |
+
end Paper320.Tournament
|
| 66 |
+
|
| 67 |
+
end
|
| 68 |
+
|
| 69 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/TournamentCyclic.lean
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.Tournament
|
| 2 |
+
import Mathlib.Algebra.Group.Fin.Basic
|
| 3 |
+
import Mathlib.Algebra.Group.Units.Equiv
|
| 4 |
+
import Mathlib.Order.Interval.Finset.Fin
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
/-! The literal regular tournament on an odd cyclic set. -/
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
open scoped Classical
|
| 12 |
+
|
| 13 |
+
namespace Paper320
|
| 14 |
+
|
| 15 |
+
def cyclicTournament (a : ℕ) : Tournament (2*a+1) where
|
| 16 |
+
Adj i j := 0 < (j-i).val ∧ (j-i).val ≤ a
|
| 17 |
+
loopless i := by simp
|
| 18 |
+
edge_compl := by
|
| 19 |
+
intro i j hij
|
| 20 |
+
have hδ : j-i ≠ 0 := sub_ne_zero.mpr hij.symm
|
| 21 |
+
have hp : 0 < (j-i).val := Nat.pos_of_ne_zero (Fin.val_ne_zero_iff.mpr hδ)
|
| 22 |
+
have hb := (j-i).isLt
|
| 23 |
+
have hn : (i-j).val = 2*a+1-(j-i).val := by
|
| 24 |
+
rw [← neg_sub j i, Fin.val_neg, ite_eq_right hδ]
|
| 25 |
+
change (0 < (j-i).val ∧ (j-i).val ≤ a) ↔ ¬ (0 < (i-j).val ∧ (i-j).val ≤ a)
|
| 26 |
+
rw [hn]
|
| 27 |
+
omega
|
| 28 |
+
|
| 29 |
+
theorem cyclicTournament_outdegree (a : ℕ) (i : Fin (2*a+1)) :
|
| 30 |
+
(Finset.univ.filter ((cyclicTournament a).Adj i)).card = a := by
|
| 31 |
+
let z : Fin (2*a+1) := 0
|
| 32 |
+
let b : Fin (2*a+1) := ⟨a, by omega⟩
|
| 33 |
+
have he : (Finset.Ioc z b).card =
|
| 34 |
+
(Finset.univ.filter ((cyclicTournament a).Adj i)).card :=
|
| 35 |
+
Finset.card_equiv (Equiv.addLeft i) (by
|
| 36 |
+
intro x
|
| 37 |
+
simp only [Finset.mem_Ioc, Finset.mem_filter, Finset.mem_univ, true_and]
|
| 38 |
+
change (0 < x.val ∧ x.val ≤ a) ↔
|
| 39 |
+
(0 < ((i+x)-i).val ∧ ((i+x)-i).val ≤ a)
|
| 40 |
+
rw [add_sub_cancel_left])
|
| 41 |
+
rw [← he, Fin.card_Ioc]
|
| 42 |
+
change a - 0 = a
|
| 43 |
+
exact Nat.sub_zero a
|
| 44 |
+
|
| 45 |
+
def regularCyclicTournament (M : ℕ) : RegularTournament M where
|
| 46 |
+
toTournament := cyclicTournament (M^2)
|
| 47 |
+
outdegree := cyclicTournament_outdegree (M^2)
|
| 48 |
+
|
| 49 |
+
end Paper320
|
| 50 |
+
|
| 51 |
+
end
|
| 52 |
+
|
| 53 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/Tower.lean
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.Recursive
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! An indexed tower of the literal recursive construction and its common blocks. -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
open scoped Classical
|
| 9 |
+
|
| 10 |
+
namespace Paper320
|
| 11 |
+
|
| 12 |
+
def TowerCoordinates (k r : ℕ) (I : Type) : ℕ → Type
|
| 13 |
+
| 0 => I
|
| 14 |
+
| n + 1 => (Fin k × Fin r) × TowerCoordinates k r I n
|
| 15 |
+
|
| 16 |
+
instance towerCoordinatesFintype (k r : ℕ) (I : Type) [Fintype I] :
|
| 17 |
+
(n : ℕ) → Fintype (TowerCoordinates k r I n)
|
| 18 |
+
| 0 => inferInstanceAs (Fintype I)
|
| 19 |
+
| n + 1 => by
|
| 20 |
+
letI := towerCoordinatesFintype k r I n
|
| 21 |
+
exact inferInstanceAs (Fintype ((Fin k × Fin r) × TowerCoordinates k r I n))
|
| 22 |
+
|
| 23 |
+
def TowerBlockIndex (k : ℕ) (K : Type) : ℕ → Type
|
| 24 |
+
| 0 => K
|
| 25 |
+
| n + 1 => Fin k × TowerBlockIndex k K n
|
| 26 |
+
|
| 27 |
+
instance towerBlockIndexFintype (k : ℕ) (K : Type) [Fintype K] :
|
| 28 |
+
(n : ℕ) → Fintype (TowerBlockIndex k K n)
|
| 29 |
+
| 0 => inferInstanceAs (Fintype K)
|
| 30 |
+
| n + 1 => by
|
| 31 |
+
letI := towerBlockIndexFintype k K n
|
| 32 |
+
exact inferInstanceAs (Fintype (Fin k × TowerBlockIndex k K n))
|
| 33 |
+
|
| 34 |
+
def towerFamily {k r : ℕ} {I : Type} (T : Tournament k)
|
| 35 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) :
|
| 36 |
+
(n h : ℕ) → Fin h → (TowerCoordinates k r I n → Bool) → Bool
|
| 37 |
+
| 0, h => base h
|
| 38 |
+
| n + 1, h => recursiveFamily T label (towerFamily T label base n (h + 1))
|
| 39 |
+
|
| 40 |
+
def towerBlocks {k r : ℕ} {I K : Type} (blocks : K → Finset I) :
|
| 41 |
+
(n : ℕ) → TowerBlockIndex k K n → Finset (TowerCoordinates k r I n)
|
| 42 |
+
| 0, b => blocks b
|
| 43 |
+
| n + 1, b => rowLift b.1 (towerBlocks blocks n b.2)
|
| 44 |
+
|
| 45 |
+
/-- Extend a prescribed initial family to unused index counts without adding assumptions. -/
|
| 46 |
+
def baseExtension {I : Type} (D : ℕ) (F : Fin D → (I → Bool) → Bool)
|
| 47 |
+
(h : ℕ) (q : Fin h) (x : I → Bool) : Bool :=
|
| 48 |
+
if he : h = D then F (Fin.cast he q) x else false
|
| 49 |
+
|
| 50 |
+
@[simp] theorem baseExtension_same {I : Type} (D : ℕ) (F : Fin D → (I → Bool) → Bool) :
|
| 51 |
+
baseExtension D F D = F := by
|
| 52 |
+
funext q x
|
| 53 |
+
simp [baseExtension]
|
| 54 |
+
|
| 55 |
+
theorem tower_coordinates_card {k r : ℕ} {I : Type} [Fintype I] (n : ℕ) :
|
| 56 |
+
Fintype.card (TowerCoordinates k r I n) = (k * r) ^ n * Fintype.card I := by
|
| 57 |
+
induction n with
|
| 58 |
+
| zero =>
|
| 59 |
+
change Fintype.card I = (k * r) ^ 0 * Fintype.card I
|
| 60 |
+
simp
|
| 61 |
+
| succ n ih =>
|
| 62 |
+
change Fintype.card ((Fin k × Fin r) × TowerCoordinates k r I n) = _
|
| 63 |
+
simp only [Fintype.card_prod, Fintype.card_fin, ih, pow_succ]
|
| 64 |
+
ring
|
| 65 |
+
|
| 66 |
+
theorem tower_block_index_card {k : ℕ} {K : Type} [Fintype K] (n : ℕ) :
|
| 67 |
+
Fintype.card (TowerBlockIndex k K n) = k ^ n * Fintype.card K := by
|
| 68 |
+
induction n with
|
| 69 |
+
| zero =>
|
| 70 |
+
change Fintype.card K = k ^ 0 * Fintype.card K
|
| 71 |
+
simp
|
| 72 |
+
| succ n ih =>
|
| 73 |
+
change Fintype.card (Fin k × TowerBlockIndex k K n) = _
|
| 74 |
+
simp only [Fintype.card_prod, Fintype.card_fin, ih, pow_succ]
|
| 75 |
+
ring
|
| 76 |
+
|
| 77 |
+
theorem towerBlocks_card {k r : ℕ} {I K : Type} (blocks : K → Finset I)
|
| 78 |
+
(L : ℕ) (hL : ∀ b, (blocks b).card = L) (n : ℕ) (b : TowerBlockIndex k K n) :
|
| 79 |
+
(towerBlocks (r := r) blocks n b).card = r ^ n * L := by
|
| 80 |
+
induction n with
|
| 81 |
+
| zero =>
|
| 82 |
+
change (blocks b).card = r ^ 0 * L
|
| 83 |
+
simpa only [pow_zero, one_mul] using hL b
|
| 84 |
+
| succ n ih =>
|
| 85 |
+
change (rowLift b.1 (towerBlocks blocks n b.2)).card = _
|
| 86 |
+
rw [rowLift_card, ih]
|
| 87 |
+
ring
|
| 88 |
+
|
| 89 |
+
theorem towerBlocks_nonempty {k r : ℕ} {I K : Type} (blocks : K → Finset I)
|
| 90 |
+
(hr : 0 < r) (hne : ∀ b, (blocks b).Nonempty) (n : ℕ) (b : TowerBlockIndex k K n) :
|
| 91 |
+
(towerBlocks (r := r) blocks n b).Nonempty := by
|
| 92 |
+
induction n with
|
| 93 |
+
| zero => exact hne b
|
| 94 |
+
| succ n ih => exact rowLift_nonempty b.1 _ hr (ih b.2)
|
| 95 |
+
|
| 96 |
+
theorem towerBlocks_pairwise {k r : ℕ} {I K : Type} (blocks : K → Finset I)
|
| 97 |
+
(hd : Pairwise fun a b => Disjoint (blocks a) (blocks b)) (n : ℕ) :
|
| 98 |
+
Pairwise fun a b => Disjoint (towerBlocks (k := k) (r := r) blocks n a) (towerBlocks blocks n b) := by
|
| 99 |
+
induction n with
|
| 100 |
+
| zero => exact hd
|
| 101 |
+
| succ n ih => exact rowLift_family_disjoint (towerBlocks blocks n) ih
|
| 102 |
+
|
| 103 |
+
theorem towerFamily_nested {k r : ℕ} {I : Type} (T : Tournament k)
|
| 104 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 105 |
+
(n h : ℕ) (hbase : NestedFamily (base (h + n))) :
|
| 106 |
+
NestedFamily (towerFamily T label base n h) := by
|
| 107 |
+
induction n generalizing h with
|
| 108 |
+
| zero =>
|
| 109 |
+
change NestedFamily (base h)
|
| 110 |
+
simpa only [Nat.add_zero] using hbase
|
| 111 |
+
| succ n ih =>
|
| 112 |
+
apply recursiveFamily_nested
|
| 113 |
+
apply ih
|
| 114 |
+
have he : (h + 1) + n = h + (n + 1) := by omega
|
| 115 |
+
rw [he]
|
| 116 |
+
exact hbase
|
| 117 |
+
|
| 118 |
+
theorem towerFamily_zero {k r : ℕ} {I : Type} (T : Tournament k)
|
| 119 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 120 |
+
(hr : 0 < r) (n h : ℕ) (hbase : ∀ q, base (h + n) q (fun _ => false) = false) :
|
| 121 |
+
∀ q, towerFamily T label base n h q (fun _ => false) = false := by
|
| 122 |
+
induction n generalizing h with
|
| 123 |
+
| zero =>
|
| 124 |
+
change ∀ q, base h q (fun _ => false) = false
|
| 125 |
+
simpa only [Nat.add_zero] using hbase
|
| 126 |
+
| succ n ih =>
|
| 127 |
+
apply recursiveFamily_zero T label _ hr
|
| 128 |
+
apply ih
|
| 129 |
+
have he : (h + 1) + n = h + (n + 1) := by omega
|
| 130 |
+
rw [he]
|
| 131 |
+
exact hbase
|
| 132 |
+
|
| 133 |
+
theorem towerFamily_blocks {k r : ℕ} {I K : Type} (T : Tournament k)
|
| 134 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 135 |
+
(blocks : K → Finset I) (hr : 0 < r) (n h : ℕ)
|
| 136 |
+
(hzero : ∀ q, base (h + n) q (fun _ => false) = false)
|
| 137 |
+
(hblocks : ∀ b q, base (h + n) q (flip (fun _ => false) (blocks b)) = true) :
|
| 138 |
+
∀ b q, towerFamily T label base n h q
|
| 139 |
+
(flip (fun _ => false) (towerBlocks blocks n b)) = true := by
|
| 140 |
+
induction n generalizing h with
|
| 141 |
+
| zero =>
|
| 142 |
+
change ∀ b q, base h q (flip (fun _ => false) (blocks b)) = true
|
| 143 |
+
simpa only [Nat.add_zero] using hblocks
|
| 144 |
+
| succ n ih =>
|
| 145 |
+
intro b q
|
| 146 |
+
have he : (h + 1) + n = h + (n + 1) := by omega
|
| 147 |
+
have hz : ∀ q, base ((h + 1) + n) q (fun _ => false) = false := by
|
| 148 |
+
rw [he]
|
| 149 |
+
exact hzero
|
| 150 |
+
have hb : ∀ b q, base ((h + 1) + n) q (flip (fun _ => false) (blocks b)) = true := by
|
| 151 |
+
rw [he]
|
| 152 |
+
exact hblocks
|
| 153 |
+
exact recursiveFamily_rowLift T label _
|
| 154 |
+
(towerFamily_zero T label base hr n (h + 1) hz)
|
| 155 |
+
(towerBlocks blocks n b.2) (ih (h + 1) hz hb b.2) b.1 q
|
| 156 |
+
|
| 157 |
+
end Paper320
|
| 158 |
+
|
| 159 |
+
end
|
| 160 |
+
|
| 161 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/TowerProfiles.lean
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.Tower
|
| 2 |
+
import OAI.Combinatorics.Sensitivity.RecursiveChildren
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! The fixed-initial-height profiles and their exact four recurrences. -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped Classical
|
| 10 |
+
|
| 11 |
+
namespace Paper320
|
| 12 |
+
|
| 13 |
+
def towerSide {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k)
|
| 14 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 15 |
+
(D n : ℕ) (b : Bool) : ℕ :=
|
| 16 |
+
sideSensitivity (towerFamily T label base n (D - n)) b
|
| 17 |
+
|
| 18 |
+
def towerJoint {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k)
|
| 19 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 20 |
+
(D n : ℕ) (b : Bool) : ℕ :=
|
| 21 |
+
jointSensitivity (towerFamily T label base n (D - n)) b
|
| 22 |
+
|
| 23 |
+
@[simp] theorem towerSide_zero {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k)
|
| 24 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 25 |
+
(D : ℕ) (b : Bool) : towerSide T label base D 0 b = sideSensitivity (base D) b := by
|
| 26 |
+
rfl
|
| 27 |
+
|
| 28 |
+
@[simp] theorem towerJoint_zero {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k)
|
| 29 |
+
(label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 30 |
+
(D : ℕ) (b : Bool) : towerJoint T label base D 0 b = jointSensitivity (base D) b := by
|
| 31 |
+
rfl
|
| 32 |
+
|
| 33 |
+
theorem tower_four_recurrences {M r : ℕ} {I : Type} [Fintype I]
|
| 34 |
+
(T : RegularTournament M) (A : GoodLabeling T.toTournament r)
|
| 35 |
+
(base : (h : ℕ) → Fin h → (I → Bool) → Bool)
|
| 36 |
+
(D n : ℕ) (hn : n < D) (hr : 0 < r) (hbase : NestedFamily (base D)) :
|
| 37 |
+
(towerSide T.toTournament A.label base D (n + 1) true ≤
|
| 38 |
+
M ^ 2 * towerSide T.toTournament A.label base D n false +
|
| 39 |
+
r * towerSide T.toTournament A.label base D n true) ∧
|
| 40 |
+
(towerJoint T.toTournament A.label base D (n + 1) true ≤
|
| 41 |
+
M ^ 2 * towerJoint T.toTournament A.label base D n false +
|
| 42 |
+
r * towerSide T.toTournament A.label base D n true) ∧
|
| 43 |
+
(towerSide T.toTournament A.label base D (n + 1) false ≤
|
| 44 |
+
16 * towerSide T.toTournament A.label base D n false +
|
| 45 |
+
towerSide T.toTournament A.label base D n true +
|
| 46 |
+
3 * towerJoint T.toTournament A.label base D n true) ∧
|
| 47 |
+
(towerJoint T.toTournament A.label base D (n + 1) false ≤
|
| 48 |
+
16 * towerSide T.toTournament A.label base D n false +
|
| 49 |
+
3 * towerJoint T.toTournament A.label base D n true) := by
|
| 50 |
+
have he : (D - (n + 1) + 1) + n = D := by omega
|
| 51 |
+
have hf : NestedFamily (towerFamily T.toTournament A.label base n (D - (n + 1) + 1)) := by
|
| 52 |
+
apply towerFamily_nested
|
| 53 |
+
rwa [he]
|
| 54 |
+
have H := recursive_four_recurrences T A
|
| 55 |
+
(towerFamily T.toTournament A.label base n (D - (n + 1) + 1)) hf hr
|
| 56 |
+
dsimp only at H
|
| 57 |
+
change (sideSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) true ≤ _) ∧
|
| 58 |
+
(jointSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) true ≤ _) ∧
|
| 59 |
+
(sideSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) false ≤ _) ∧
|
| 60 |
+
(jointSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) false ≤ _) at H
|
| 61 |
+
have hcount : D - (n + 1) + 1 = D - n := by omega
|
| 62 |
+
rw [hcount] at H
|
| 63 |
+
exact H
|
| 64 |
+
|
| 65 |
+
theorem towerBlocks_family_card {k r : ℕ} {I K : Type} [Fintype K]
|
| 66 |
+
(blocks : K → Finset I) (hr : 0 < r) (hne : ∀ b, (blocks b).Nonempty)
|
| 67 |
+
(hd : Pairwise fun a b => Disjoint (blocks a) (blocks b)) (n : ℕ) :
|
| 68 |
+
(Finset.univ.image (towerBlocks (k := k) (r := r) blocks n)).card = k ^ n * Fintype.card K := by
|
| 69 |
+
have hinj : Function.Injective (towerBlocks (k := k) (r := r) blocks n) := by
|
| 70 |
+
intro a b hab
|
| 71 |
+
by_contra hneab
|
| 72 |
+
obtain ⟨i, hi⟩ := towerBlocks_nonempty blocks hr hne n a
|
| 73 |
+
exact Finset.disjoint_left.mp (towerBlocks_pairwise blocks hd n hneab) hi (by simpa [← hab] using hi)
|
| 74 |
+
rw [Finset.card_image_of_injective _ hinj, Finset.card_univ, tower_block_index_card]
|
| 75 |
+
|
| 76 |
+
end Paper320
|
| 77 |
+
|
| 78 |
+
end
|
| 79 |
+
|
| 80 |
+
end OAI
|
lean/OAI/Combinatorics/Sensitivity/UniformCoordinates.lean
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import OAI.Combinatorics.Sensitivity.FixedCoordinates
|
| 2 |
+
import Mathlib.Probability.Distributions.Uniform
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! The exact probability of prescribed values under uniform independent labels. -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped Classical
|
| 10 |
+
|
| 11 |
+
namespace Paper320
|
| 12 |
+
|
| 13 |
+
theorem uniform_fixedCoordinates_probability {α β : Type} [Fintype α] [Fintype β]
|
| 14 |
+
[DecidableEq α] [Nonempty β] (s : Finset α) (v : α → β) :
|
| 15 |
+
((PMF.uniformOfFintype (α → β)).toOuterMeasure
|
| 16 |
+
{f | ∀ i ∈ s, f i = v i}).toReal = 1 / (Fintype.card β : ℝ)^s.card := by
|
| 17 |
+
rw [PMF.toOuterMeasure_uniformOfFintype_apply]
|
| 18 |
+
simp only [ENNReal.toReal_div, ENNReal.toReal_natCast]
|
| 19 |
+
rw [Fintype.card_subtype]
|
| 20 |
+
simp only [Set.mem_ofPred_eq]
|
| 21 |
+
rw [card_fixedCoordinates, Fintype.card_fun]
|
| 22 |
+
simp only [Nat.cast_pow]
|
| 23 |
+
have hp : (Fintype.card β : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero (α := β)
|
| 24 |
+
rw [div_eq_div_iff (pow_ne_zero _ hp) (pow_ne_zero _ hp), one_mul,
|
| 25 |
+
← pow_add, Nat.sub_add_cancel (Finset.card_le_univ s)]
|
| 26 |
+
|
| 27 |
+
end Paper320
|
| 28 |
+
|
| 29 |
+
end
|
| 30 |
+
|
| 31 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Bounds/FromConstruction.lean
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Bounds.Lower
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! Two-sided Ramsey bounds and the logarithmic limit from a prime-field construction. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
namespace SharpLogRamsey
|
| 10 |
+
|
| 11 |
+
theorem mainLimit_of_mainBounds (s : ℕ) (h : MainBounds s) : MainLimit s := by
|
| 12 |
+
obtain ⟨C,hC,h⟩ := h
|
| 13 |
+
have hlog : Filter.Tendsto (fun t : ℕ => Real.log (t:ℝ)) Filter.atTop Filter.atTop :=
|
| 14 |
+
Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop
|
| 15 |
+
have hloglog : Filter.Tendsto (fun t : ℕ => Real.log (Real.log (t:ℝ)))
|
| 16 |
+
Filter.atTop Filter.atTop := Real.tendsto_log_atTop.comp hlog
|
| 17 |
+
apply Metric.tendsto_atTop.mpr
|
| 18 |
+
intro ε hε
|
| 19 |
+
obtain ⟨t₀,ht₀⟩ := h (ε/2) (by positivity)
|
| 20 |
+
obtain ⟨t₁,ht₁⟩ := Filter.eventually_atTop.mp
|
| 21 |
+
(hloglog.eventually (Filter.eventually_gt_atTop (max 0 (2*|Real.log C|/ε))))
|
| 22 |
+
refine ⟨max (max t₀ t₁) 2, fun t ht => ?_⟩
|
| 23 |
+
have htl : t₀≤t := (le_max_left t₀ t₁).trans ((le_max_left _ _).trans ht)
|
| 24 |
+
have htll : t₁≤t := (le_max_right t₀ t₁).trans ((le_max_left _ _).trans ht)
|
| 25 |
+
have ht2 : 2≤t := (le_max_right _ _).trans ht
|
| 26 |
+
have htp : (0:ℝ)<t := by exact_mod_cast (by omega : 0<t)
|
| 27 |
+
have hlt : 0<Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1<t))
|
| 28 |
+
have hll0 : 0<Real.log (Real.log (t:ℝ)) := (le_max_left _ _).trans_lt (ht₁ t htll)
|
| 29 |
+
have hllbig : 2*|Real.log C|/ε<Real.log (Real.log (t:ℝ)) :=
|
| 30 |
+
(le_max_right _ _).trans_lt (ht₁ t htll)
|
| 31 |
+
obtain ⟨hl,hu⟩ := ht₀ t htl
|
| 32 |
+
have hp : 0<(t:ℝ)^(s-1)/Real.rpow (Real.log (t:ℝ)) ((s-2:ℕ)+(ε/2)) :=
|
| 33 |
+
div_pos (pow_pos htp _) (Real.rpow_pos_of_pos hlt _)
|
| 34 |
+
have hr : 0<(ramsey s t:ℝ) := hp.trans_le hl
|
| 35 |
+
have hl' := Real.log_le_log hp hl
|
| 36 |
+
change Real.log ((t:ℝ)^(s-1)/(Real.log (t:ℝ))^(((s-2:ℕ):ℝ)+ε/2)) ≤ Real.log (ramsey s t:ℝ) at hl'
|
| 37 |
+
rw [Real.log_div (pow_ne_zero (s-1) (ne_of_gt htp))
|
| 38 |
+
(ne_of_gt (Real.rpow_pos_of_pos hlt (((s-2:ℕ):ℝ)+(ε/2)))), Real.log_pow,Real.log_rpow hlt] at hl'
|
| 39 |
+
have hu' := Real.log_le_log hr hu
|
| 40 |
+
rw [Real.log_div (mul_ne_zero (ne_of_gt hC) (pow_ne_zero (s-1) (ne_of_gt htp)))
|
| 41 |
+
(pow_ne_zero (s-2) (ne_of_gt hlt)), Real.log_mul (ne_of_gt hC)
|
| 42 |
+
(pow_ne_zero (s-1) (ne_of_gt htp)),Real.log_pow,Real.log_pow] at hu'
|
| 43 |
+
have herr : |Real.log C| < (ε/2)*Real.log (Real.log (t:ℝ)) := by
|
| 44 |
+
have he := (div_lt_iff₀ hε).mp hllbig
|
| 45 |
+
nlinarith
|
| 46 |
+
have hlow : ((s-2:ℕ):ℝ)-ε/2 <
|
| 47 |
+
(((s-1:ℕ):ℝ)*Real.log (t:ℝ)-Real.log (ramsey s t:ℝ))/
|
| 48 |
+
Real.log (Real.log (t:ℝ)) := by
|
| 49 |
+
apply (lt_div_iff₀ hll0).mpr
|
| 50 |
+
have habs := le_abs_self (Real.log C)
|
| 51 |
+
nlinarith
|
| 52 |
+
have hupp : (((s-1:ℕ):ℝ)*Real.log (t:ℝ)-Real.log (ramsey s t:ℝ))/
|
| 53 |
+
Real.log (Real.log (t:ℝ)) ≤ ((s-2:ℕ):ℝ)+ε/2 := by
|
| 54 |
+
apply (div_le_iff₀ hll0).mpr
|
| 55 |
+
nlinarith
|
| 56 |
+
rw [Real.dist_eq,abs_lt]
|
| 57 |
+
constructor <;> linarith
|
| 58 |
+
end SharpLogRamsey
|
| 59 |
+
|
| 60 |
+
namespace SharpLogRamsey
|
| 61 |
+
|
| 62 |
+
theorem main_of_primeConstruction (s : ℕ) (hs : 6 ≤ s)
|
| 63 |
+
(hprime : LowerTransfer.PrimeConstruction (s-1)) : MainBounds s ∧ MainLimit s := by
|
| 64 |
+
have hb : MainBounds s := by
|
| 65 |
+
obtain ⟨C,hC,t₀,ht₀⟩ := Upper.ramsey_upper (by omega : 3 ≤ s)
|
| 66 |
+
refine ⟨C,hC,fun ε hε => ?_⟩
|
| 67 |
+
have hl := LowerTransfer.all_epsilon_lower (s-1) (by omega) hprime ε hε
|
| 68 |
+
have he : s-1+1=s := by omega
|
| 69 |
+
have he' : s-1-1=s-2 := by omega
|
| 70 |
+
rw [he,he'] at hl
|
| 71 |
+
obtain ⟨t₁,ht₁⟩ := Filter.eventually_atTop.mp hl
|
| 72 |
+
exact ⟨max t₀ t₁,fun t ht => ⟨ht₁ t ((le_max_right _ _).trans ht),
|
| 73 |
+
ht₀ t ((le_max_left _ _).trans ht)⟩⟩
|
| 74 |
+
exact ⟨hb,mainLimit_of_mainBounds s hb⟩
|
| 75 |
+
end SharpLogRamsey
|
| 76 |
+
|
| 77 |
+
end
|
| 78 |
+
|
| 79 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Bounds/Lower.lean
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Bounds.SamplingParameter
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! Transfer of finite prime-field graph constructions to all sufficiently large orders. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
namespace SharpLogRamsey.LowerTransfer
|
| 10 |
+
open Filter Real
|
| 11 |
+
open scoped Topology
|
| 12 |
+
noncomputable section
|
| 13 |
+
|
| 14 |
+
def PrimeConstruction (d : ℕ) : Prop :=
|
| 15 |
+
∀ η : ℝ, 0 < η → η < 1/10 → ∀ᶠ q : ℕ in atTop,
|
| 16 |
+
q.Prime → ∃ G : SimpleGraph (Fin ⌊(q:ℝ)^d * Real.log q⌋₊),
|
| 17 |
+
G.CliqueFree (d+1) ∧ G.indepNum < ⌊(q:ℝ) * (Real.log q)^(1+η)⌋₊
|
| 18 |
+
|
| 19 |
+
theorem prime_interval (x : ℝ) (hx : 4 ≤ x) :
|
| 20 |
+
∃ q : ℕ, q.Prime ∧ x/4 ≤ q ∧ (q:ℝ) ≤ x := by
|
| 21 |
+
let n := ⌊x/2⌋₊
|
| 22 |
+
have hn : 1 ≤ n := (Nat.one_le_floor_iff _).mpr (by linarith)
|
| 23 |
+
obtain ⟨q,hq,hnq,hqn⟩ := Nat.exists_prime_lt_and_le_two_mul n (by omega)
|
| 24 |
+
refine ⟨q,hq,?_,?_⟩
|
| 25 |
+
· have hnf := Nat.lt_floor_add_one (x/2)
|
| 26 |
+
have hnqr : (n:ℝ)+1 ≤ q := by exact_mod_cast hnq
|
| 27 |
+
dsimp [n] at hnqr
|
| 28 |
+
linarith
|
| 29 |
+
· have hnf := Nat.floor_le (show 0≤x/2 by linarith)
|
| 30 |
+
have hqn' : (q:ℝ) ≤ 2*n := by exact_mod_cast hqn
|
| 31 |
+
dsimp [n] at hqn'
|
| 32 |
+
linarith
|
| 33 |
+
|
| 34 |
+
theorem witness_bound (d q t : ℕ) (η : ℝ) (hd : 1≤d) (ht : 1≤t)
|
| 35 |
+
(G : SimpleGraph (Fin ⌊(q:ℝ)^d * Real.log q⌋₊))
|
| 36 |
+
(hG : G.CliqueFree (d+1))
|
| 37 |
+
(hI : G.indepNum < ⌊(q:ℝ)*(Real.log q)^(1+η)⌋₊)
|
| 38 |
+
(hqt : (q:ℝ)*(Real.log q)^(1+η) ≤ t) :
|
| 39 |
+
(q:ℝ)^d * Real.log q < (ramsey (d+1) t : ℝ) := by
|
| 40 |
+
have hk : ⌊(q:ℝ)*(Real.log q)^(1+η)⌋₊ ≤ t := Nat.floor_le_of_le hqt
|
| 41 |
+
have hf : Gᶜ.CliqueFree t := by
|
| 42 |
+
intro A hA
|
| 43 |
+
have hi := G.isNClique_compl.mp hA
|
| 44 |
+
have hle := hi.isIndepSet.card_le_indepNum
|
| 45 |
+
have hc := hi.card_eq
|
| 46 |
+
omega
|
| 47 |
+
have hr := Foundation.order_lt_ramsey G (by omega) ht hG hf
|
| 48 |
+
simp only [Fintype.card_fin] at hr
|
| 49 |
+
have hr' : (⌊(q:ℝ)^d * Real.log q⌋₊ :ℝ)+1 ≤ ramsey (d+1) t := by
|
| 50 |
+
exact_mod_cast hr
|
| 51 |
+
exact (Nat.lt_floor_add_one _).trans_le hr'
|
| 52 |
+
|
| 53 |
+
theorem eventual_scale (η : ℝ) : ∀ᶠ t : ℝ in atTop,
|
| 54 |
+
1 < t ∧ 1 ≤ Real.log t ∧
|
| 55 |
+
4*t^((1:ℝ)/2) ≤ t/(Real.log t)^(1+η) := by
|
| 56 |
+
have h := (isLittleO_log_rpow_rpow_atTop (1+η) (show 0<(1:ℝ)/2 by norm_num)).bound
|
| 57 |
+
(show 0<(1:ℝ)/4 by norm_num)
|
| 58 |
+
filter_upwards [h,eventually_gt_atTop (1:ℝ),Real.tendsto_log_atTop.eventually_ge_atTop 1]
|
| 59 |
+
with t ht ht1 hl
|
| 60 |
+
refine ⟨ht1,hl,?_⟩
|
| 61 |
+
have ht0 : 0<t := by linarith
|
| 62 |
+
have hl0 : 0<Real.log t := by linarith
|
| 63 |
+
simp only [Real.norm_eq_abs,abs_of_pos (Real.rpow_pos_of_pos hl0 _),
|
| 64 |
+
abs_of_pos (Real.rpow_pos_of_pos ht0 _)] at ht
|
| 65 |
+
apply (le_div_iff₀ (Real.rpow_pos_of_pos hl0 _)).mpr
|
| 66 |
+
have hp : t^((1:ℝ)/2)*t^((1:ℝ)/2)=t := by
|
| 67 |
+
rw [←Real.rpow_add ht0]; norm_num
|
| 68 |
+
nlinarith [mul_le_mul_of_nonneg_left ht (Real.rpow_nonneg ht0.le ((1:ℝ)/2))]
|
| 69 |
+
|
| 70 |
+
theorem interval_bounds (η t q : ℝ) (hη : 0≤η) (ht : 1<t) (hl : 1≤Real.log t)
|
| 71 |
+
(hscale : 4*t^((1:ℝ)/2) ≤ t/(Real.log t)^(1+η))
|
| 72 |
+
(hqlo : (t/(Real.log t)^(1+η))/4 ≤ q)
|
| 73 |
+
(hqhi : q ≤ t/(Real.log t)^(1+η)) :
|
| 74 |
+
0<q ∧ Real.log t/2 ≤ Real.log q ∧
|
| 75 |
+
q*(Real.log q)^(1+η) ≤ t := by
|
| 76 |
+
have ht0 : 0<t := by linarith
|
| 77 |
+
have hl0 : 0<Real.log t := by linarith
|
| 78 |
+
have hp : 0<(Real.log t)^(1+η) := Real.rpow_pos_of_pos hl0 _
|
| 79 |
+
have hqs : t^((1:ℝ)/2)≤q := by linarith
|
| 80 |
+
have hq0 : 0<q := (Real.rpow_pos_of_pos ht0 _).trans_le hqs
|
| 81 |
+
refine ⟨hq0,?_,?_⟩
|
| 82 |
+
· have hlog := Real.log_le_log (Real.rpow_pos_of_pos ht0 _) hqs
|
| 83 |
+
rw [Real.log_rpow ht0] at hlog
|
| 84 |
+
linarith
|
| 85 |
+
· have hden : 1≤(Real.log t)^(1+η) := Real.one_le_rpow hl (by linarith)
|
| 86 |
+
have hqt : q≤t := hqhi.trans (div_le_self ht0.le hden)
|
| 87 |
+
have hq1 : 1≤q := (Real.one_le_rpow ht.le (by norm_num)).trans hqs
|
| 88 |
+
have hlogq : 0≤Real.log q := Real.log_nonneg hq1
|
| 89 |
+
have hpow : (Real.log q)^(1+η)≤(Real.log t)^(1+η) :=
|
| 90 |
+
Real.rpow_le_rpow hlogq (Real.log_le_log hq0 hqt) (by linarith)
|
| 91 |
+
calc
|
| 92 |
+
q*(Real.log q)^(1+η) ≤ q*(Real.log t)^(1+η) := mul_le_mul_of_nonneg_left hpow hq0.le
|
| 93 |
+
_ ≤ (t/(Real.log t)^(1+η))*(Real.log t)^(1+η) :=
|
| 94 |
+
mul_le_mul_of_nonneg_right hqhi hp.le
|
| 95 |
+
_ = t := div_mul_cancel₀ _ hp.ne'
|
| 96 |
+
|
| 97 |
+
theorem scalar_lower (d : ℕ) (hd : 1≤d) (η ε t q : ℝ)
|
| 98 |
+
(ht : 0≤t) (hl : 0<Real.log t) (hq : 0≤q)
|
| 99 |
+
(hqlo : (t/(Real.log t)^(1+η))/4 ≤ q)
|
| 100 |
+
(hlog : Real.log t/2 ≤ Real.log q)
|
| 101 |
+
(habsorb : 2*(4:ℝ)^d ≤ (Real.log t)^(ε-(d:ℝ)*η)) :
|
| 102 |
+
t^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) ≤ q^d*Real.log q := by
|
| 103 |
+
let a : ℝ := ((d-1:ℕ):ℝ)+(d:ℝ)*η
|
| 104 |
+
have he : (1+η)*(d:ℝ)=a+1 := by
|
| 105 |
+
dsimp [a]
|
| 106 |
+
rw [Nat.cast_sub hd]
|
| 107 |
+
norm_num
|
| 108 |
+
ring
|
| 109 |
+
have he' : ((d-1:ℕ):ℝ)+ε=a+(ε-(d:ℝ)*η) := by dsimp [a];ring
|
| 110 |
+
have hpow : ((Real.log t)^(1+η))^d=(Real.log t)^a*Real.log t := by
|
| 111 |
+
rw [←Real.rpow_natCast,←Real.rpow_mul hl.le,he,Real.rpow_add_one hl.ne']
|
| 112 |
+
have hp : 0<(Real.log t)^a := Real.rpow_pos_of_pos hl _
|
| 113 |
+
have hp' : 0<(Real.log t)^(ε-(d:ℝ)*η) := Real.rpow_pos_of_pos hl _
|
| 114 |
+
have h4 : 0<(4:ℝ)^d := by positivity
|
| 115 |
+
have hden : ((Real.log t)^a)*(2*(4:ℝ)^d) ≤
|
| 116 |
+
((Real.log t)^a)*(Real.log t)^(ε-(d:ℝ)*η) :=
|
| 117 |
+
mul_le_mul_of_nonneg_left habsorb hp.le
|
| 118 |
+
calc
|
| 119 |
+
t^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) =
|
| 120 |
+
t^d/((Real.log t)^a*(Real.log t)^(ε-(d:ℝ)*η)) := by rw [he',Real.rpow_add hl]
|
| 121 |
+
_ ≤ t^d/((Real.log t)^a*(2*(4:ℝ)^d)) :=
|
| 122 |
+
div_le_div_of_nonneg_left (pow_nonneg ht _) (by positivity) hden
|
| 123 |
+
_ = ((t/(Real.log t)^(1+η))/4)^d*(Real.log t/2) := by
|
| 124 |
+
rw [div_pow,div_pow,hpow]
|
| 125 |
+
field_simp
|
| 126 |
+
_ ≤ q^d*Real.log q := by
|
| 127 |
+
apply mul_le_mul
|
| 128 |
+
· exact pow_le_pow_left₀ (by positivity) hqlo _
|
| 129 |
+
· exact hlog
|
| 130 |
+
· positivity
|
| 131 |
+
· exact pow_nonneg hq _
|
| 132 |
+
|
| 133 |
+
theorem lower_from_prime_construction (d : ℕ) (hd : 1≤d) (hprime : PrimeConstruction d)
|
| 134 |
+
(η ε : ℝ) (hη : 0<η) (hη' : η<1/10) (hε : (d:ℝ)*η<ε) :
|
| 135 |
+
∀ᶠ t : ℕ in atTop,
|
| 136 |
+
(t:ℝ)^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) ≤ (ramsey (d+1) t :ℝ) := by
|
| 137 |
+
obtain ⟨q₀,hq₀⟩ := eventually_atTop.mp (hprime η hη hη')
|
| 138 |
+
have hcoef : ∀ᶠ t : ℝ in atTop,
|
| 139 |
+
2*(4:ℝ)^d ≤ (Real.log t)^(ε-(d:ℝ)*η) :=
|
| 140 |
+
((tendsto_rpow_atTop (by linarith : 0<ε-(d:ℝ)*η)).comp
|
| 141 |
+
Real.tendsto_log_atTop).eventually_ge_atTop _
|
| 142 |
+
have hsqr : ∀ᶠ t : ℝ in atTop, max 1 (q₀:ℝ) ≤ t^((1:ℝ)/2) :=
|
| 143 |
+
(tendsto_rpow_atTop (by norm_num : 0<(1:ℝ)/2)).eventually_ge_atTop _
|
| 144 |
+
have H : ∀ᶠ t : ℝ in atTop,
|
| 145 |
+
1<t ∧ 1≤Real.log t ∧ 4*t^((1:ℝ)/2)≤t/(Real.log t)^(1+η) ∧
|
| 146 |
+
max 1 (q₀:ℝ)≤t^((1:ℝ)/2) ∧
|
| 147 |
+
2*(4:ℝ)^d≤(Real.log t)^(ε-(d:ℝ)*η) := by
|
| 148 |
+
filter_upwards [eventual_scale η,hsqr,hcoef] with t ht hs hc
|
| 149 |
+
exact ⟨ht.1,ht.2.1,ht.2.2,hs,hc⟩
|
| 150 |
+
filter_upwards [tendsto_natCast_atTop_atTop.eventually H] with t ht
|
| 151 |
+
obtain ⟨ht1,hl,hs,hqmin,hcoef⟩ := ht
|
| 152 |
+
have hx4 : 4 ≤ (t:ℝ)/(Real.log t)^(1+η) := by
|
| 153 |
+
have := (le_max_left (1:ℝ) q₀).trans hqmin
|
| 154 |
+
linarith
|
| 155 |
+
obtain ⟨q,hq,hql,hqu⟩ := prime_interval _ hx4
|
| 156 |
+
have hq₀' : q₀≤q := by
|
| 157 |
+
have hreal : (q₀:ℝ)≤q := by
|
| 158 |
+
have := (le_max_right (1:ℝ) q₀).trans hqmin
|
| 159 |
+
linarith
|
| 160 |
+
exact_mod_cast hreal
|
| 161 |
+
obtain ⟨G,hG,hI⟩ := hq₀ q hq₀' hq
|
| 162 |
+
obtain ⟨hqpos,hlog,hsize⟩ := interval_bounds η t q hη.le ht1 hl hs hql hqu
|
| 163 |
+
have hr := witness_bound d q t η hd (by exact_mod_cast ht1.le) G hG hI hsize
|
| 164 |
+
exact (scalar_lower d hd η ε t q (by positivity) (by linarith) hqpos.le hql hlog hcoef).trans hr.le
|
| 165 |
+
|
| 166 |
+
theorem all_epsilon_lower (d : ℕ) (hd : 1≤d) (hprime : PrimeConstruction d)
|
| 167 |
+
(ε : ℝ) (hε : 0<ε) :
|
| 168 |
+
∀ᶠ t : ℕ in atTop,
|
| 169 |
+
(t:ℝ)^d/(Real.log t)^(((d-1:ℕ):ℝ)+ε) ≤ (ramsey (d+1) t :ℝ) := by
|
| 170 |
+
let η := min (1/20:ℝ) (ε/(2*(d:ℝ)))
|
| 171 |
+
have hd0 : 0<(d:ℝ) := by exact_mod_cast (show 0<d by omega)
|
| 172 |
+
have hη : 0<η := lt_min (by norm_num) (by positivity)
|
| 173 |
+
have hη' : η<1/10 := (min_le_left _ _).trans_lt (by norm_num)
|
| 174 |
+
have hηε : (d:ℝ)*η<ε := by
|
| 175 |
+
have h := mul_le_mul_of_nonneg_left (min_le_right (1/20:ℝ) (ε/(2*(d:ℝ)))) hd0.le
|
| 176 |
+
have he : (d:ℝ)*(ε/(2*(d:ℝ)))=ε/2 := by field_simp
|
| 177 |
+
rw [he] at h
|
| 178 |
+
exact h.trans_lt (by linarith)
|
| 179 |
+
exact lower_from_prime_construction d hd hprime η ε hη hη' hηε
|
| 180 |
+
|
| 181 |
+
end
|
| 182 |
+
end SharpLogRamsey.LowerTransfer
|
| 183 |
+
|
| 184 |
+
end
|
| 185 |
+
|
| 186 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Bounds/SamplingParameter.lean
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Bounds.SumFiberCenter
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! The off-diagonal Ramsey upper bound. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open scoped BigOperators Classical
|
| 10 |
+
open Finset
|
| 11 |
+
open scoped BigOperators Classical
|
| 12 |
+
open Finset
|
| 13 |
+
open scoped BigOperators Classical
|
| 14 |
+
open Finset
|
| 15 |
+
open scoped BigOperators
|
| 16 |
+
namespace SharpLogRamsey.Upper
|
| 17 |
+
theorem sampling_parameter {h m t : ℝ} (hh : 1 ≤ h) (hm : 1 ≤ m)
|
| 18 |
+
(ht : 65536 ≤ t) (hratio : m * Real.sqrt t ≤ h) :
|
| 19 |
+
∃ p : ℝ, 0 < p ∧ p ≤ 1 ∧ 1 ≤ p*h ∧ p^2*h*m ≤ 1/8 ∧
|
| 20 |
+
Real.log t ≤ 8 * Real.log (p*h) := by
|
| 21 |
+
have hh0 : 0 < h := by linarith
|
| 22 |
+
have hm0 : 0 < m := by linarith
|
| 23 |
+
have ht0 : 0 < t := by linarith
|
| 24 |
+
have hs : 0 < Real.sqrt (h*m) := Real.sqrt_pos.mpr (mul_pos hh0 hm0)
|
| 25 |
+
let p := 1 / (4 * Real.sqrt (h*m))
|
| 26 |
+
have hp : 0 < p := by dsimp [p]; positivity
|
| 27 |
+
have hs1 : 1 ≤ Real.sqrt (h*m) := by
|
| 28 |
+
rw [Real.le_sqrt (by norm_num) (by positivity)]
|
| 29 |
+
nlinarith
|
| 30 |
+
have hp1 : p ≤ 1 := by
|
| 31 |
+
dsimp [p]
|
| 32 |
+
apply (div_le_iff₀ (by positivity)).mpr
|
| 33 |
+
linarith
|
| 34 |
+
have hsq := Real.sq_sqrt (show 0 ≤ h*m by positivity)
|
| 35 |
+
have hmoment : p^2*h*m = 1/16 := by
|
| 36 |
+
dsimp [p]
|
| 37 |
+
field_simp
|
| 38 |
+
nlinarith
|
| 39 |
+
have hlog : Real.log (p*h) = (Real.log h - Real.log m)/2 - Real.log 4 := by
|
| 40 |
+
dsimp [p]
|
| 41 |
+
rw [Real.log_mul (by positivity) hh0.ne', Real.log_div (by norm_num) (by positivity),
|
| 42 |
+
Real.log_one, Real.log_mul (by norm_num) hs.ne', Real.log_sqrt (by positivity : 0 ≤ h*m),
|
| 43 |
+
Real.log_mul hh0.ne' hm0.ne']
|
| 44 |
+
ring
|
| 45 |
+
have hratio' := Real.log_le_log (mul_pos hm0 (Real.sqrt_pos.mpr ht0)) hratio
|
| 46 |
+
rw [Real.log_mul hm0.ne' (Real.sqrt_pos.mpr ht0).ne', Real.log_sqrt ht0.le] at hratio'
|
| 47 |
+
have htlog := Real.log_le_log (show (0:ℝ) < 65536 by norm_num) ht
|
| 48 |
+
have h65536 : Real.log (65536:ℝ) = 8 * Real.log 4 := by
|
| 49 |
+
rw [show (65536:ℝ) = 4^8 by norm_num, Real.log_pow]
|
| 50 |
+
norm_num
|
| 51 |
+
rw [h65536] at htlog
|
| 52 |
+
have hl : Real.log t ≤ 8 * Real.log (p*h) := by linarith
|
| 53 |
+
have hl0 : 0 ≤ Real.log (p*h) := by
|
| 54 |
+
have htl : 0 ≤ Real.log t := Real.log_nonneg (by linarith)
|
| 55 |
+
linarith
|
| 56 |
+
have hph : 1 ≤ p*h := by
|
| 57 |
+
exact (Real.log_nonneg_iff (by positivity)).mp hl0
|
| 58 |
+
exact ⟨p,hp,hp1,hph,by linarith,hl⟩
|
| 59 |
+
|
| 60 |
+
end SharpLogRamsey.Upper
|
| 61 |
+
|
| 62 |
+
namespace SharpLogRamsey.Upper
|
| 63 |
+
open Foundation Sampling
|
| 64 |
+
variable {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
|
| 65 |
+
|
| 66 |
+
theorem alteration_bound {h m t : ℕ} (ht : 1 ≤ t)
|
| 67 |
+
(hG : Gᶜ.CliqueFree t) (hdeg : ∀ x, G.degree x ≤ h)
|
| 68 |
+
(hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m)
|
| 69 |
+
{p : ℝ} (hp : 0 < p) (hp1 : p ≤ 1)
|
| 70 |
+
(hph : 1 ≤ p*h) (hmoment : p^2*h*m ≤ 1/8) :
|
| 71 |
+
(Fintype.card V : ℝ) * Real.log (p*h) ≤ 256 * t * h := by
|
| 72 |
+
let n : ℝ := Fintype.card V
|
| 73 |
+
have hn : 0 ≤ n := Nat.cast_nonneg _
|
| 74 |
+
have hhp : (0:ℝ) < h := by nlinarith
|
| 75 |
+
have hD : 0 < 12*p*h := by positivity
|
| 76 |
+
obtain ⟨U,hU,hUd,hUt⟩ := sample_prune G hp.le hp1 hD
|
| 77 |
+
have hsum : (∑ x : V, (G.degree x : ℝ)) ≤ n*h := by
|
| 78 |
+
calc
|
| 79 |
+
_ ≤ ∑ _x : V, (h : ℝ) := sum_le_sum (fun x _ => by exact_mod_cast hdeg x)
|
| 80 |
+
_ = n*h := by simp [n]
|
| 81 |
+
have htri : ((G.cliqueFinset 3).card : ℝ) ≤ n*h*m := by
|
| 82 |
+
dsimp [n]
|
| 83 |
+
exact_mod_cast triangle_count_le G hdeg hcommon
|
| 84 |
+
have hloss : p^2 * (∑ x : V, (G.degree x : ℝ)) / (12*p*h) ≤ n*p/12 := by
|
| 85 |
+
apply (div_le_iff₀ hD).mpr
|
| 86 |
+
calc
|
| 87 |
+
_ ≤ p^2*(n*h) := mul_le_mul_of_nonneg_left hsum (sq_nonneg _)
|
| 88 |
+
_ = n*p/12*(12*p*h) := by ring
|
| 89 |
+
have htri' : p^3 * ((G.cliqueFinset 3).card : ℝ) ≤ n*p/8 := by
|
| 90 |
+
calc
|
| 91 |
+
_ ≤ p^3*(n*h*m) := mul_le_mul_of_nonneg_left htri (by positivity)
|
| 92 |
+
_ = n*p*(p^2*h*m) := by ring
|
| 93 |
+
_ ≤ n*p*(1/8) := mul_le_mul_of_nonneg_left hmoment (by positivity)
|
| 94 |
+
_ = n*p/8 := by ring
|
| 95 |
+
have hUsize : 3/4*n*p ≤ (U.card : ℝ) := by dsimp [n] at *; linarith
|
| 96 |
+
have hlog : 0 ≤ Real.log (p*h) := Real.log_nonneg hph
|
| 97 |
+
by_cases hn0 : n = 0
|
| 98 |
+
· change n * _ ≤ _
|
| 99 |
+
rw [hn0, zero_mul]
|
| 100 |
+
positivity
|
| 101 |
+
have hnpos : 0 < n := lt_of_le_of_ne hn (Ne.symm hn0)
|
| 102 |
+
have hUpos : 0 < U.card := by
|
| 103 |
+
have hu : (0:ℝ) < U.card := lt_of_lt_of_le (by positivity) hUsize
|
| 104 |
+
exact_mod_cast hu
|
| 105 |
+
obtain ⟨x,hx⟩ := card_pos.mp hUpos
|
| 106 |
+
let : Nonempty (U : Set V) := ⟨⟨x,hx⟩⟩
|
| 107 |
+
have ha := TriangleFree.indepNum_lower_bound (G.induce (U : Set V)) hUt
|
| 108 |
+
(by nlinarith : (1:ℝ) ≤ 12*p*h) hUd
|
| 109 |
+
have hat : ((G.induce (U : Set V)).indepNum : ℝ) < t := by
|
| 110 |
+
exact_mod_cast indepNum_lt_of_cliqueFree_compl (G.induce (U : Set V))
|
| 111 |
+
(compl_cliqueFree_induce G hG _)
|
| 112 |
+
have ha' : (U.card : ℝ) * Real.log (12*p*h+1) < t*(8*(12*p*h+1)) := by
|
| 113 |
+
have H := ha.trans_lt hat
|
| 114 |
+
rw [div_lt_iff₀ (by positivity)] at H
|
| 115 |
+
have hc : Fintype.card (U : Set V) = U.card := Fintype.card_coe U
|
| 116 |
+
simpa only [hc] using H
|
| 117 |
+
have hl : Real.log (p*h) ≤ Real.log (12*p*h+1) :=
|
| 118 |
+
Real.log_le_log (by positivity) (by nlinarith)
|
| 119 |
+
have hu : (3/4*n*p) * Real.log (p*h) ≤
|
| 120 |
+
(U.card : ℝ) * Real.log (12*p*h+1) :=
|
| 121 |
+
mul_le_mul hUsize hl hlog (Nat.cast_nonneg _)
|
| 122 |
+
have hd : t*(8*(12*p*h+1)) ≤ 104*t*p*h := by
|
| 123 |
+
have ht0 : (0:ℝ) ≤ t := Nat.cast_nonneg _
|
| 124 |
+
nlinarith [mul_le_mul_of_nonneg_left hph ht0]
|
| 125 |
+
have H := (hu.trans_lt ha').trans_le hd
|
| 126 |
+
have ht0 : (0:ℝ) ≤ t := Nat.cast_nonneg _
|
| 127 |
+
change n*Real.log (p*h) ≤ _
|
| 128 |
+
have : p*(n*Real.log (p*h)) ≤ p*(256*t*h) := by nlinarith
|
| 129 |
+
exact (mul_le_mul_iff_right₀ hp).mp this
|
| 130 |
+
|
| 131 |
+
theorem graph_recurrence (j : ℕ) {t : ℕ} (ht : 65536 ≤ t)
|
| 132 |
+
(hs : G.CliqueFree (j+4)) (hi : Gᶜ.CliqueFree t) :
|
| 133 |
+
(Fintype.card V : ℝ) ≤
|
| 134 |
+
t*((t:ℝ)^(j+1)*Real.sqrt t+1) +
|
| 135 |
+
2048*t*(ramsey (j+3) t)/Real.log t := by
|
| 136 |
+
let h := G.maxDegree
|
| 137 |
+
let m := ramsey (j+2) t
|
| 138 |
+
have ht1 : 1 ≤ t := by omega
|
| 139 |
+
have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega)
|
| 140 |
+
have hlog : 0 < Real.log t := Real.log_pos (by exact_mod_cast (show 1 < t by omega))
|
| 141 |
+
have hm1 : 1 ≤ m := ht1.trans (le_ramsey (by omega) ht1)
|
| 142 |
+
have hmb : (m : ℝ) ≤ (t:ℝ)^(j+1) := by
|
| 143 |
+
have H := ramsey_le_pow (s := j+2) (by omega) ht1
|
| 144 |
+
norm_num at H
|
| 145 |
+
exact_mod_cast H
|
| 146 |
+
have hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m := by
|
| 147 |
+
intro x y hxy
|
| 148 |
+
exact (order_lt_ramsey (G.induce (G.commonNeighbors x y)) (by omega) ht1
|
| 149 |
+
(cliqueFree_common G hs hxy) (compl_cliqueFree_induce G hi _)).le
|
| 150 |
+
have hdeg : ∀ x, G.degree x ≤ h := G.degree_le_maxDegree
|
| 151 |
+
have hhr : h ≤ ramsey (j+3) t := by
|
| 152 |
+
apply G.maxDegree_le_of_forall_degree_le
|
| 153 |
+
intro x
|
| 154 |
+
have H := order_lt_ramsey (G.induce (G.neighborSet x)) (by omega) ht1
|
| 155 |
+
(cliqueFree_neighbor G hs x) (compl_cliqueFree_induce G hi _)
|
| 156 |
+
rw [G.card_neighborSet_eq_degree] at H
|
| 157 |
+
exact H.le
|
| 158 |
+
have hright : 0 ≤ 2048*(t:ℝ)*(ramsey (j+3) t)/Real.log t := by positivity
|
| 159 |
+
by_cases hsmall : (h:ℝ) ≤ m*Real.sqrt t
|
| 160 |
+
· have hn := card_le_mul_indepNum G (B := h+1) (by intro x; exact Nat.add_le_add_right (hdeg x) 1)
|
| 161 |
+
have hia := indepNum_lt_of_cliqueFree_compl G hi
|
| 162 |
+
have Hnat : Fintype.card V ≤ (h+1)*t := hn.trans (Nat.mul_le_mul_left _ hia.le)
|
| 163 |
+
have H : (Fintype.card V : ℝ) ≤ ((h:ℝ)+1)*t := by exact_mod_cast Hnat
|
| 164 |
+
have hm' := mul_le_mul_of_nonneg_right hmb (Real.sqrt_nonneg (t:ℝ))
|
| 165 |
+
have H' := mul_le_mul_of_nonneg_right (add_le_add_right (hsmall.trans hm') 1) ht0.le
|
| 166 |
+
nlinarith
|
| 167 |
+
· have hh : (1:ℝ) ≤ h := by
|
| 168 |
+
have hsqrt : 1 ≤ Real.sqrt (t:ℝ) := by
|
| 169 |
+
rw [Real.le_sqrt (by norm_num) ht0.le]
|
| 170 |
+
exact_mod_cast ht1
|
| 171 |
+
have hm1' : (1:ℝ) ≤ m := by exact_mod_cast hm1
|
| 172 |
+
nlinarith
|
| 173 |
+
obtain ⟨p,hp,hp1,hph,hpm,hl⟩ := sampling_parameter hh (by exact_mod_cast hm1)
|
| 174 |
+
(by exact_mod_cast ht) (le_of_not_ge hsmall)
|
| 175 |
+
have hab := alteration_bound G ht1 hi hdeg hcommon hp hp1 hph hpm
|
| 176 |
+
have hn0 : (0:ℝ) ≤ Fintype.card V := Nat.cast_nonneg _
|
| 177 |
+
have H : (Fintype.card V : ℝ)*Real.log t ≤ 2048*t*h := by
|
| 178 |
+
nlinarith [mul_le_mul_of_nonneg_left hl hn0]
|
| 179 |
+
have H' : (Fintype.card V : ℝ) ≤ 2048*t*h/Real.log t :=
|
| 180 |
+
(le_div_iff₀ hlog).mpr H
|
| 181 |
+
have H'' : 2048*(t:ℝ)*h/Real.log t ≤ 2048*t*(ramsey (j+3) t)/Real.log t := by
|
| 182 |
+
apply div_le_div_of_nonneg_right _ hlog.le
|
| 183 |
+
exact mul_le_mul_of_nonneg_left (by exact_mod_cast hhr) (by positivity)
|
| 184 |
+
have hleft : 0 ≤ (t:ℝ)*((t:ℝ)^(j+1)*Real.sqrt t+1) := by positivity
|
| 185 |
+
linarith
|
| 186 |
+
|
| 187 |
+
theorem ramsey_recurrence (j : ℕ) {t : ℕ} (ht : 65536 ≤ t) :
|
| 188 |
+
(ramsey (j+4) t : ℝ) ≤
|
| 189 |
+
t*((t:ℝ)^(j+1)*Real.sqrt t+1) +
|
| 190 |
+
2048*t*(ramsey (j+3) t)/Real.log t + 1 := by
|
| 191 |
+
classical
|
| 192 |
+
obtain ⟨G,hG,hGi⟩ := exists_avoiding_pred (s := j+4) (by omega) (by omega : 2 ≤ t)
|
| 193 |
+
have H := graph_recurrence G j ht hG hGi
|
| 194 |
+
simp only [Fintype.card_fin] at H
|
| 195 |
+
have hr : 1 ≤ ramsey (j+4) t :=
|
| 196 |
+
(by omega : 1 ≤ t).trans (le_ramsey (by omega) (by omega))
|
| 197 |
+
rw [Nat.cast_sub hr, Nat.cast_one] at H
|
| 198 |
+
linarith
|
| 199 |
+
|
| 200 |
+
theorem ramsey_three {t : ℕ} (ht : 2 ≤ t) :
|
| 201 |
+
(ramsey 3 t : ℝ)*Real.log t ≤ 17*(t:ℝ)^2 := by
|
| 202 |
+
classical
|
| 203 |
+
obtain ⟨G,hG,hGi⟩ := exists_avoiding_pred (s := 3) (by omega) ht
|
| 204 |
+
have hr : 2 ≤ ramsey 3 t := ht.trans (le_ramsey (by omega) (by omega))
|
| 205 |
+
have hnon : 0 < ramsey 3 t - 1 := by omega
|
| 206 |
+
let : Nonempty (Fin (ramsey 3 t - 1)) := Fin.pos_iff_nonempty.mp hnon
|
| 207 |
+
have hd : ∀ x, (G.degree x : ℝ) ≤ t := by
|
| 208 |
+
intro x
|
| 209 |
+
have H := order_lt_ramsey (G.induce (G.neighborSet x)) (by omega : 2 ≤ 2)
|
| 210 |
+
(by omega : 1 ≤ t) (cliqueFree_neighbor G hG x) (compl_cliqueFree_induce G hGi _)
|
| 211 |
+
rw [G.card_neighborSet_eq_degree, ramsey_two (by omega)] at H
|
| 212 |
+
exact_mod_cast H.le
|
| 213 |
+
have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega)
|
| 214 |
+
have ht1 : (1:ℝ) ≤ t := by exact_mod_cast (show 1 ≤ t by omega)
|
| 215 |
+
have hl : 0 ≤ Real.log (t:ℝ) := Real.log_nonneg ht1
|
| 216 |
+
have H := TriangleFree.indepNum_lower_bound G hG ht1 hd
|
| 217 |
+
have hi : (G.indepNum : ℝ) < t := by
|
| 218 |
+
exact_mod_cast indepNum_lt_of_cliqueFree_compl G hGi
|
| 219 |
+
have H' := H.trans_lt hi
|
| 220 |
+
rw [div_lt_iff₀ (by positivity)] at H'
|
| 221 |
+
have hc : (Fintype.card (Fin (ramsey 3 t - 1)) : ℝ) = (ramsey 3 t : ℝ)-1 := by
|
| 222 |
+
rw [Fintype.card_fin, Nat.cast_sub (by omega), Nat.cast_one]
|
| 223 |
+
rw [hc] at H'
|
| 224 |
+
have hl' : Real.log (t:ℝ) ≤ Real.log ((t:ℝ)+1) := Real.log_le_log ht0 (by linarith)
|
| 225 |
+
have hn : 0 ≤ (ramsey 3 t : ℝ)-1 := by
|
| 226 |
+
have H : (2:ℝ) ≤ ramsey 3 t := by exact_mod_cast hr
|
| 227 |
+
linarith
|
| 228 |
+
have hh := mul_le_mul_of_nonneg_left hl' hn
|
| 229 |
+
have hlt := Real.log_le_self ht0.le
|
| 230 |
+
nlinarith [sq_nonneg ((t:ℝ)-1)]
|
| 231 |
+
|
| 232 |
+
open Filter in
|
| 233 |
+
theorem eventually_log_pow_le_sqrt (j : ℕ) :
|
| 234 |
+
∀ᶠ t : ℕ in atTop, (Real.log (t:ℝ))^j ≤ Real.sqrt t := by
|
| 235 |
+
have H := (isLittleO_log_rpow_rpow_atTop (j:ℝ) (by norm_num : (0:ℝ)<1/2)).bound
|
| 236 |
+
(by norm_num : (0:ℝ)<1)
|
| 237 |
+
have Hn := tendsto_natCast_atTop_atTop.eventually H
|
| 238 |
+
filter_upwards [Hn, eventually_ge_atTop (1:ℕ)] with t ht ht1
|
| 239 |
+
have hlog := Real.log_nonneg (show (1:ℝ) ≤ t by exact_mod_cast ht1)
|
| 240 |
+
simpa only [Real.rpow_natCast, Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hlog _),
|
| 241 |
+
← Real.sqrt_eq_rpow, abs_of_nonneg (Real.sqrt_nonneg _), one_mul] using ht
|
| 242 |
+
|
| 243 |
+
open Filter in
|
| 244 |
+
|
| 245 |
+
theorem ramsey_upper_scaled (j : ℕ) :
|
| 246 |
+
∃ C : ℝ, 0 < C ∧ ∀ᶠ t : ℕ in atTop,
|
| 247 |
+
(ramsey (j+3) t : ℝ)*(Real.log (t:ℝ))^(j+1) ≤ C*(t:ℝ)^(j+2) := by
|
| 248 |
+
induction j with
|
| 249 |
+
| zero =>
|
| 250 |
+
refine ⟨17, by norm_num, ?_⟩
|
| 251 |
+
filter_upwards [eventually_ge_atTop (2:ℕ)] with t ht
|
| 252 |
+
simpa using ramsey_three ht
|
| 253 |
+
| succ j ih =>
|
| 254 |
+
obtain ⟨C,hC,hCb⟩ := ih
|
| 255 |
+
refine ⟨3+2048*C, by positivity, ?_⟩
|
| 256 |
+
filter_upwards [hCb, eventually_log_pow_le_sqrt (j+2),
|
| 257 |
+
eventually_ge_atTop (65536:ℕ)] with t hCt hL ht
|
| 258 |
+
have ht1 : (1:ℝ) ≤ t := by exact_mod_cast (show 1 ≤ t by omega)
|
| 259 |
+
have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega)
|
| 260 |
+
have hl : 0 < Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (show 1 < t by omega))
|
| 261 |
+
have hs := Real.sqrt_nonneg (t:ℝ)
|
| 262 |
+
have hs2 := Real.sq_sqrt ht0.le
|
| 263 |
+
have hst : Real.sqrt (t:ℝ) ≤ t := by
|
| 264 |
+
rw [Real.sqrt_le_iff]
|
| 265 |
+
exact ⟨ht0.le, by nlinarith⟩
|
| 266 |
+
have hpow : (t:ℝ)^2 ≤ (t:ℝ)^(j+3) := pow_le_pow_right₀ ht1 (by omega)
|
| 267 |
+
have hsmall : (t*((t:ℝ)^(j+1)*Real.sqrt t+1)+1)*(Real.log (t:ℝ))^(j+2) ≤
|
| 268 |
+
3*(t:ℝ)^(j+3) := by
|
| 269 |
+
calc
|
| 270 |
+
_ ≤ (t*((t:ℝ)^(j+1)*Real.sqrt t+1)+1)*Real.sqrt t :=
|
| 271 |
+
mul_le_mul_of_nonneg_left hL (by positivity)
|
| 272 |
+
_ = (t:ℝ)^(j+1)*t*(Real.sqrt t)^2+(t+1)*Real.sqrt t := by ring
|
| 273 |
+
_ = (t:ℝ)^(j+3)+(t+1)*Real.sqrt t := by
|
| 274 |
+
rw [hs2]
|
| 275 |
+
simp only [pow_succ]
|
| 276 |
+
_ ≤ (t:ℝ)^(j+3)+2*(t:ℝ)^2 := by
|
| 277 |
+
have H := mul_le_mul_of_nonneg_left hst (by positivity : (0:ℝ) ≤ t+1)
|
| 278 |
+
nlinarith
|
| 279 |
+
_ ≤ 3*(t:ℝ)^(j+3) := by linarith
|
| 280 |
+
have hmain : (2048*t*(ramsey (j+3) t)/Real.log t)*(Real.log (t:ℝ))^(j+2) ≤
|
| 281 |
+
(2048*C)*(t:ℝ)^(j+3) := by
|
| 282 |
+
calc
|
| 283 |
+
_ = 2048*t*((ramsey (j+3) t : ℝ)*(Real.log (t:ℝ))^(j+1)) := by
|
| 284 |
+
rw [show j+2 = (j+1)+1 from by omega, pow_succ]
|
| 285 |
+
field_simp
|
| 286 |
+
_ ≤ 2048*t*(C*(t:ℝ)^(j+2)) :=
|
| 287 |
+
mul_le_mul_of_nonneg_left hCt (by positivity)
|
| 288 |
+
_ = (2048*C)*(t:ℝ)^(j+3) := by
|
| 289 |
+
rw [show j+3 = (j+2)+1 from by omega, pow_succ]; ring
|
| 290 |
+
have H := mul_le_mul_of_nonneg_right (ramsey_recurrence j ht)
|
| 291 |
+
(pow_nonneg hl.le (j+2))
|
| 292 |
+
linear_combination H + hsmall + hmain
|
| 293 |
+
|
| 294 |
+
open Filter in
|
| 295 |
+
theorem ramsey_upper {s : ℕ} (hs : 3 ≤ s) :
|
| 296 |
+
∃ C : ℝ, 0 < C ∧ ∃ t₀ : ℕ, ∀ t : ℕ, t₀ ≤ t →
|
| 297 |
+
(ramsey s t : ℝ) ≤ C*(t:ℝ)^(s-1)/(Real.log (t:ℝ))^(s-2) := by
|
| 298 |
+
obtain ⟨j,rfl⟩ := Nat.exists_eq_add_of_le hs
|
| 299 |
+
obtain ⟨C,hC,hCb⟩ := ramsey_upper_scaled j
|
| 300 |
+
refine ⟨C,hC,?_⟩
|
| 301 |
+
have H : ∀ᶠ t : ℕ in atTop,
|
| 302 |
+
(ramsey (3+j) t : ℝ) ≤ C*(t:ℝ)^(3+j-1)/(Real.log (t:ℝ))^(3+j-2) := by
|
| 303 |
+
filter_upwards [hCb, eventually_ge_atTop (2:ℕ)] with t ht ht2
|
| 304 |
+
have hl : 0 < Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (show 1 < t by omega))
|
| 305 |
+
apply (le_div_iff₀ (pow_pos hl _)).mpr
|
| 306 |
+
simpa [show 3+j = j+3 from by omega] using ht
|
| 307 |
+
exact eventually_atTop.mp H
|
| 308 |
+
|
| 309 |
+
end SharpLogRamsey.Upper
|
| 310 |
+
|
| 311 |
+
end
|
| 312 |
+
|
| 313 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Bounds/SumFiberCenter.lean
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Construction.FiniteStreamTail
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Bounds.Upper
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! The off-diagonal Ramsey upper bound. -/
|
| 8 |
+
|
| 9 |
+
section
|
| 10 |
+
open scoped BigOperators Classical
|
| 11 |
+
open Finset
|
| 12 |
+
open scoped BigOperators Classical
|
| 13 |
+
open Finset
|
| 14 |
+
namespace SharpLogRamsey.TriangleFree
|
| 15 |
+
variable {V : Type*} [Fintype V] [DecidableEq V]
|
| 16 |
+
variable (G : SimpleGraph V)
|
| 17 |
+
theorem sum_fiber_center (htri : G.CliqueFree 3) {x : V} {J : Finset V}
|
| 18 |
+
(hJ : Admissible G x J) : ∑ S ∈ fiber G x J, (if x ∈ S then (1:ℝ) else 0) = 1 := by
|
| 19 |
+
rw [sum_fiber G htri hJ]
|
| 20 |
+
simp only [mem_insert_self, ite_true]
|
| 21 |
+
have hx : ∀ K ∈ (available G x J).powerset, x ∉ J ∪ K := by
|
| 22 |
+
intro K hK h
|
| 23 |
+
rcases mem_union.mp h with hx | hx
|
| 24 |
+
· exact admissible_not_center G hJ hx
|
| 25 |
+
· exact center_not_available G x J (mem_powerset.mp hK hx)
|
| 26 |
+
rw [sum_eq_zero (fun K hK => ite_eq_right (hx K hK)), add_zero]
|
| 27 |
+
|
| 28 |
+
theorem twice_sum_fiber_neighbors (htri : G.CliqueFree 3) {x : V} {J : Finset V}
|
| 29 |
+
(hJ : Admissible G x J) :
|
| 30 |
+
2 * (∑ S ∈ fiber G x J, ((S ∩ G.neighborFinset x).card : ℝ)) =
|
| 31 |
+
(available G x J).card * (2:ℝ)^(available G x J).card := by
|
| 32 |
+
rw [sum_fiber G htri hJ, center_neighbor_inter G hJ, card_empty, Nat.cast_zero,
|
| 33 |
+
zero_add]
|
| 34 |
+
have he : ∑ K ∈ (available G x J).powerset,
|
| 35 |
+
(((J ∪ K) ∩ G.neighborFinset x).card : ℝ) =
|
| 36 |
+
∑ K ∈ (available G x J).powerset, (K.card : ℝ) := by
|
| 37 |
+
apply sum_congr rfl
|
| 38 |
+
intro K hK
|
| 39 |
+
rw [extend_neighbor_inter G hJ (mem_powerset.mp hK)]
|
| 40 |
+
rw [he]
|
| 41 |
+
exact twice_sum_powerset_card (available G x J)
|
| 42 |
+
|
| 43 |
+
noncomputable def Z (x : V) (S : Finset V) : ℕ :=
|
| 44 |
+
(available G x (outside G x S)).card
|
| 45 |
+
|
| 46 |
+
theorem fiber_empty_of_not_admissible {x : V} {J : Finset V}
|
| 47 |
+
(hJ : ¬Admissible G x J) : fiber G x J = ∅ := by
|
| 48 |
+
apply eq_empty_iff_forall_notMem.mpr
|
| 49 |
+
intro S hS
|
| 50 |
+
obtain ⟨hS, hout⟩ := mem_filter.mp hS
|
| 51 |
+
exact hJ (hout ▸ admissible_outside G x hS)
|
| 52 |
+
|
| 53 |
+
theorem sum_fiber_Z (x : V) (J : Finset V) (f : ℕ → ℝ) :
|
| 54 |
+
∑ S ∈ fiber G x J, f (Z G x S) = (fiber G x J).card * f (available G x J).card := by
|
| 55 |
+
calc
|
| 56 |
+
_ = ∑ _S ∈ fiber G x J, f (available G x J).card := by
|
| 57 |
+
apply sum_congr rfl
|
| 58 |
+
intro S hS
|
| 59 |
+
simp only [Z, (mem_filter.mp hS).2]
|
| 60 |
+
_ = _ := by simp
|
| 61 |
+
|
| 62 |
+
theorem exp_neg_log_two_mul (z : ℕ) :
|
| 63 |
+
Real.exp (-(Real.log 2) * z) = ((2:ℝ)^z)⁻¹ := by
|
| 64 |
+
rw [show -(Real.log 2) * z = -((z:ℝ) * Real.log 2) by ring,
|
| 65 |
+
Real.exp_neg, Real.exp_nat_mul, Real.exp_log (by norm_num)]
|
| 66 |
+
|
| 67 |
+
theorem half_sum_exp_le_center (htri : G.CliqueFree 3) (x : V) :
|
| 68 |
+
(∑ S ∈ independentSets G, Real.exp (-Real.log 2 * Z G x S)) / 2 ≤
|
| 69 |
+
∑ S ∈ independentSets G, (if x ∈ S then (1:ℝ) else 0) := by
|
| 70 |
+
rw [← Finset.sum_fiberwise (independentSets G) (outside G x)
|
| 71 |
+
(fun S => Real.exp (-Real.log 2 * Z G x S)),
|
| 72 |
+
← Finset.sum_fiberwise (independentSets G) (outside G x)
|
| 73 |
+
(fun S => if x ∈ S then (1:ℝ) else 0), sum_div]
|
| 74 |
+
apply sum_le_sum
|
| 75 |
+
intro J _
|
| 76 |
+
change (∑ S ∈ fiber G x J, _) / 2 ≤ ∑ S ∈ fiber G x J, _
|
| 77 |
+
by_cases hJ : Admissible G x J
|
| 78 |
+
· rw [sum_fiber_Z G x J (fun z => Real.exp (-Real.log 2 * z)),
|
| 79 |
+
card_fiber G htri hJ, sum_fiber_center G htri hJ, exp_neg_log_two_mul]
|
| 80 |
+
push_cast
|
| 81 |
+
have hp : (1:ℝ) ≤ 2^(available G x J).card := one_le_pow₀ (by norm_num)
|
| 82 |
+
have hpp : (0:ℝ) < 2^(available G x J).card := by positivity
|
| 83 |
+
field_simp
|
| 84 |
+
nlinarith
|
| 85 |
+
· rw [fiber_empty_of_not_admissible G hJ]
|
| 86 |
+
simp
|
| 87 |
+
|
| 88 |
+
theorem sum_Z_le_four_neighbors (htri : G.CliqueFree 3) (x : V) :
|
| 89 |
+
(∑ S ∈ independentSets G, (Z G x S : ℝ)) ≤
|
| 90 |
+
4 * ∑ S ∈ independentSets G, ((S ∩ G.neighborFinset x).card : ℝ) := by
|
| 91 |
+
rw [← Finset.sum_fiberwise (independentSets G) (outside G x)
|
| 92 |
+
(fun S => (Z G x S : ℝ)),
|
| 93 |
+
← Finset.sum_fiberwise (independentSets G) (outside G x)
|
| 94 |
+
(fun S => ((S ∩ G.neighborFinset x).card : ℝ)), mul_sum]
|
| 95 |
+
apply sum_le_sum
|
| 96 |
+
intro J _
|
| 97 |
+
change (∑ S ∈ fiber G x J, _) ≤ 4 * ∑ S ∈ fiber G x J, _
|
| 98 |
+
by_cases hJ : Admissible G x J
|
| 99 |
+
· rw [sum_fiber_Z G x J (fun z => (z:ℝ)), card_fiber G htri hJ]
|
| 100 |
+
have hn := twice_sum_fiber_neighbors G htri hJ
|
| 101 |
+
have hp : (1:ℝ) ≤ 2^(available G x J).card := one_le_pow₀ (by norm_num)
|
| 102 |
+
have hz : (0:ℝ) ≤ (available G x J).card := by positivity
|
| 103 |
+
push_cast
|
| 104 |
+
nlinarith
|
| 105 |
+
· rw [fiber_empty_of_not_admissible G hJ]
|
| 106 |
+
simp
|
| 107 |
+
|
| 108 |
+
theorem sum_center (S : Finset V) :
|
| 109 |
+
(∑ x : V, if x ∈ S then (1:ℝ) else 0) = S.card := by
|
| 110 |
+
simp
|
| 111 |
+
|
| 112 |
+
theorem sum_neighbors (S : Finset V) :
|
| 113 |
+
(∑ x : V, ((S ∩ G.neighborFinset x).card : ℝ)) =
|
| 114 |
+
∑ v ∈ S, (G.degree v : ℝ) := by
|
| 115 |
+
calc
|
| 116 |
+
_ = ∑ x : V, ∑ v ∈ S, (if G.Adj x v then (1:ℝ) else 0) := by
|
| 117 |
+
apply sum_congr rfl
|
| 118 |
+
intro x _
|
| 119 |
+
rw [← sum_filter]
|
| 120 |
+
simp only [sum_const, nsmul_eq_mul, mul_one]
|
| 121 |
+
congr 2
|
| 122 |
+
ext v
|
| 123 |
+
simp []
|
| 124 |
+
_ = ∑ v ∈ S, ∑ x : V, (if G.Adj x v then (1:ℝ) else 0) := sum_comm
|
| 125 |
+
_ = _ := by
|
| 126 |
+
apply sum_congr rfl
|
| 127 |
+
intro v _
|
| 128 |
+
simp_rw [G.adj_comm]
|
| 129 |
+
rw [← sum_filter]
|
| 130 |
+
have he : univ.filter (G.Adj v) = G.neighborFinset v := by ext x; simp
|
| 131 |
+
rw [he]
|
| 132 |
+
simp
|
| 133 |
+
|
| 134 |
+
theorem exp_mean_le {α : Type*} (A : Finset α) (hA : A.Nonempty) (f : α → ℝ) :
|
| 135 |
+
Real.exp ((∑ i ∈ A, f i) / A.card) ≤ (∑ i ∈ A, Real.exp (f i)) / A.card := by
|
| 136 |
+
have hc : (0:ℝ) < A.card := by exact_mod_cast hA.card_pos
|
| 137 |
+
have hsum : ∑ _i ∈ A, ((A.card:ℝ)⁻¹) = 1 := by
|
| 138 |
+
simp [hc.ne']
|
| 139 |
+
have hj := convexOn_exp.map_sum_le (t := A) (w := fun _ => (A.card:ℝ)⁻¹)
|
| 140 |
+
(p := f) (fun _ _ => inv_nonneg.mpr hc.le) hsum (fun _ _ => Set.mem_univ _)
|
| 141 |
+
simp only [smul_eq_mul, ← mul_sum] at hj
|
| 142 |
+
simpa only [div_eq_mul_inv, mul_comm] using hj
|
| 143 |
+
|
| 144 |
+
theorem occupation_lower_bound {D μ : ℝ} (hD : 1 ≤ D) (hμ : 0 ≤ μ)
|
| 145 |
+
(hkey : Real.exp (-4 * D * μ * Real.log 2) ≤ 2 * μ) :
|
| 146 |
+
Real.log (D+1) / (8 * (D+1)) ≤ μ := by
|
| 147 |
+
by_contra! hbad
|
| 148 |
+
have hu : 0 < D + 1 := by linarith
|
| 149 |
+
have hlog : 0 < Real.log (D+1) := Real.log_pos (by linarith)
|
| 150 |
+
have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num)
|
| 151 |
+
have hl2' : Real.log 2 < 1 := by
|
| 152 |
+
convert Real.log_lt_sub_one_of_pos (x := (2:ℝ)) (by norm_num) (by norm_num) using 1 ; norm_num
|
| 153 |
+
have hb : 8 * (D+1) * μ < Real.log (D+1) := by
|
| 154 |
+
have := (lt_div_iff₀ (show 0 < 8*(D+1) by positivity)).mp hbad
|
| 155 |
+
nlinarith
|
| 156 |
+
have hDμ : 0 ≤ D * μ := mul_nonneg (by linarith) hμ
|
| 157 |
+
have he : -Real.log (D+1)/2 < -4 * D * μ * Real.log 2 := by
|
| 158 |
+
have hh := mul_le_mul_of_nonneg_left hl2'.le hDμ
|
| 159 |
+
nlinarith
|
| 160 |
+
have hlow : Real.exp (-Real.log (D+1)/2) < 2 * μ :=
|
| 161 |
+
(Real.exp_lt_exp.mpr he).trans_le hkey
|
| 162 |
+
have hid : (D+1) * Real.exp (-Real.log (D+1)/2) =
|
| 163 |
+
Real.exp (Real.log (D+1)/2) := by
|
| 164 |
+
conv_lhs => lhs; rw [← Real.exp_log hu]
|
| 165 |
+
rw [← Real.exp_add]
|
| 166 |
+
congr 1
|
| 167 |
+
ring
|
| 168 |
+
have hupper := Real.add_one_le_exp (Real.log (D+1)/2)
|
| 169 |
+
have hmul := mul_lt_mul_of_pos_left hlow (show 0 < 4*(D+1) by positivity)
|
| 170 |
+
nlinarith
|
| 171 |
+
|
| 172 |
+
theorem exists_occupation (htri : G.CliqueFree 3) [Nonempty V]
|
| 173 |
+
{D : ℝ} (hD : ∀ x, (G.degree x : ℝ) ≤ D) :
|
| 174 |
+
∃ μ : ℝ, 0 ≤ μ ∧ (Fintype.card V : ℝ) * μ ≤ G.indepNum ∧
|
| 175 |
+
Real.exp (-4 * D * μ * Real.log 2) ≤ 2 * μ := by
|
| 176 |
+
let A := independentSets G
|
| 177 |
+
let Ω := (univ : Finset V) ×ˢ A
|
| 178 |
+
let M : ℝ := ∑ S ∈ A, (S.card : ℝ)
|
| 179 |
+
let m : ℝ := (Fintype.card V : ℝ) * A.card
|
| 180 |
+
have hn : (0:ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos
|
| 181 |
+
have ha : (0:ℝ) < A.card := by exact_mod_cast (independentSets_nonempty G).card_pos
|
| 182 |
+
have hm : 0 < m := mul_pos hn ha
|
| 183 |
+
have hmcard : (Ω.card:ℝ) = m := by simp [Ω, m]
|
| 184 |
+
have hM : 0 ≤ M := sum_nonneg (fun _ _ => Nat.cast_nonneg _)
|
| 185 |
+
have he : (∑ a ∈ Ω, Real.exp (-Real.log 2 * Z G a.1 a.2)) ≤ 2*M := by
|
| 186 |
+
have hh := sum_le_sum (s := (univ : Finset V))
|
| 187 |
+
(fun x _ => half_sum_exp_le_center G htri x)
|
| 188 |
+
rw [← sum_div] at hh
|
| 189 |
+
have hcenter : (∑ x : V, ∑ S ∈ independentSets G,
|
| 190 |
+
(if x ∈ S then (1:ℝ) else 0)) = M := by
|
| 191 |
+
rw [sum_comm]
|
| 192 |
+
simp only [sum_center]
|
| 193 |
+
rfl
|
| 194 |
+
rw [hcenter] at hh
|
| 195 |
+
unfold Ω
|
| 196 |
+
rw [sum_product]
|
| 197 |
+
dsimp only
|
| 198 |
+
change (∑ x : V, ∑ S ∈ independentSets G, _) ≤ 2*M
|
| 199 |
+
linarith
|
| 200 |
+
have hz : (∑ a ∈ Ω, (Z G a.1 a.2 : ℝ)) ≤ 4*D*M := by
|
| 201 |
+
have hh := sum_le_sum (s := (univ : Finset V))
|
| 202 |
+
(fun x _ => sum_Z_le_four_neighbors G htri x)
|
| 203 |
+
rw [← mul_sum] at hh
|
| 204 |
+
have hneigh : (∑ x : V, ∑ S ∈ independentSets G,
|
| 205 |
+
((S ∩ G.neighborFinset x).card:ℝ)) =
|
| 206 |
+
∑ S ∈ independentSets G, ∑ v ∈ S, (G.degree v:ℝ) := by
|
| 207 |
+
rw [sum_comm]
|
| 208 |
+
simp_rw [sum_neighbors]
|
| 209 |
+
rw [hneigh] at hh
|
| 210 |
+
have hd : (∑ S ∈ independentSets G, ∑ v ∈ S, (G.degree v : ℝ)) ≤ D*M := by
|
| 211 |
+
calc
|
| 212 |
+
_ ≤ ∑ S ∈ independentSets G, ∑ _v ∈ S, D := by
|
| 213 |
+
apply sum_le_sum
|
| 214 |
+
intro S _
|
| 215 |
+
exact sum_le_sum (fun v _ => hD v)
|
| 216 |
+
_ = D*M := by simp [M, A, mul_sum, mul_comm]
|
| 217 |
+
unfold Ω
|
| 218 |
+
rw [sum_product]
|
| 219 |
+
dsimp only
|
| 220 |
+
change (∑ x : V, ∑ S ∈ independentSets G, _) ≤ 4*D*M
|
| 221 |
+
linarith
|
| 222 |
+
have hind : M ≤ (A.card:ℝ) * G.indepNum := by
|
| 223 |
+
calc
|
| 224 |
+
M ≤ ∑ _S ∈ A, (G.indepNum : ℝ) := by
|
| 225 |
+
apply sum_le_sum
|
| 226 |
+
intro S hS
|
| 227 |
+
exact_mod_cast (mem_independentSets G S |>.mp hS).card_le_indepNum
|
| 228 |
+
_ = _ := by simp
|
| 229 |
+
refine ⟨M/m, div_nonneg hM hm.le, ?_, ?_⟩
|
| 230 |
+
· rw [← mul_div_assoc]
|
| 231 |
+
apply (div_le_iff₀ hm).mpr
|
| 232 |
+
dsimp only [m]
|
| 233 |
+
nlinarith [mul_le_mul_of_nonneg_left hind hn.le]
|
| 234 |
+
· have hΩ : Ω.Nonempty := nonempty_product.mpr ⟨univ_nonempty, independentSets_nonempty G⟩
|
| 235 |
+
have hj := exp_mean_le Ω hΩ (fun a => -Real.log 2 * Z G a.1 a.2)
|
| 236 |
+
rw [hmcard, ← mul_sum] at hj
|
| 237 |
+
have hl : 0 ≤ Real.log 2 := (Real.log_pos (by norm_num : (1:ℝ)<2)).le
|
| 238 |
+
have hexp : Real.exp (-4*D*(M/m)*Real.log 2) ≤
|
| 239 |
+
Real.exp (-Real.log 2 * (∑ a ∈ Ω, (Z G a.1 a.2:ℝ)) / m) := by
|
| 240 |
+
apply Real.exp_le_exp.mpr
|
| 241 |
+
rw [show -4*D*(M/m)*Real.log 2 = (-4*D*M*Real.log 2)/m by ring]
|
| 242 |
+
apply (div_le_div_iff_of_pos_right hm).mpr
|
| 243 |
+
have hh := mul_le_mul_of_nonpos_left hz (neg_nonpos.mpr hl)
|
| 244 |
+
convert hh using 1 ; ring
|
| 245 |
+
have hfinal := hexp.trans hj
|
| 246 |
+
have hdiv := div_le_div_of_nonneg_right he hm.le
|
| 247 |
+
calc
|
| 248 |
+
_ ≤ (∑ a ∈ Ω, Real.exp (-Real.log 2 * Z G a.1 a.2))/m := hfinal
|
| 249 |
+
_ ≤ 2*M/m := hdiv
|
| 250 |
+
_ = 2*(M/m) := by ring
|
| 251 |
+
|
| 252 |
+
theorem indepNum_lower_bound (htri : G.CliqueFree 3) [Nonempty V]
|
| 253 |
+
{D : ℝ} (hD : 1 ≤ D) (hdeg : ∀ x, (G.degree x : ℝ) ≤ D) :
|
| 254 |
+
(Fintype.card V : ℝ) * Real.log (D+1) / (8*(D+1)) ≤ G.indepNum := by
|
| 255 |
+
obtain ⟨μ, hμ, hind, hkey⟩ := exists_occupation G htri hdeg
|
| 256 |
+
have hb := occupation_lower_bound hD hμ hkey
|
| 257 |
+
have hh := mul_le_mul_of_nonneg_left hb
|
| 258 |
+
(show (0:ℝ) ≤ Fintype.card V by positivity)
|
| 259 |
+
rw [← mul_div_assoc] at hh
|
| 260 |
+
exact hh.trans hind
|
| 261 |
+
|
| 262 |
+
end SharpLogRamsey.TriangleFree
|
| 263 |
+
|
| 264 |
+
open scoped BigOperators Classical
|
| 265 |
+
open Finset
|
| 266 |
+
namespace SharpLogRamsey.Sampling
|
| 267 |
+
variable {V : Type*} [Fintype V] [DecidableEq V]
|
| 268 |
+
|
| 269 |
+
variable (G : SimpleGraph V)
|
| 270 |
+
|
| 271 |
+
noncomputable def internalDegree (S : Finset V) (x : V) : ℕ :=
|
| 272 |
+
(S.filter (G.Adj x)).card
|
| 273 |
+
|
| 274 |
+
noncomputable def degreeMass (S : Finset V) : ℕ := ∑ x ∈ S, internalDegree G S x
|
| 275 |
+
|
| 276 |
+
theorem degreeMass_pair_sum (S : Finset V) :
|
| 277 |
+
(degreeMass G S : ℝ) = ∑ x : V, ∑ y : V,
|
| 278 |
+
if G.Adj x y then (if ({x,y} : Finset V) ⊆ S then 1 else 0) else 0 := by
|
| 279 |
+
have hi (x : V) : (∑ y : V,
|
| 280 |
+
if G.Adj x y then (if ({x,y} : Finset V) ⊆ S then (1:ℝ) else 0) else 0) =
|
| 281 |
+
if x ∈ S then (internalDegree G S x : ℝ) else 0 := by
|
| 282 |
+
by_cases hx : x ∈ S
|
| 283 |
+
· rw [ite_eq_left hx]
|
| 284 |
+
have he : S = univ.filter (· ∈ S) := by simp
|
| 285 |
+
change _ = ((S.filter (G.Adj x)).card : ℝ)
|
| 286 |
+
conv_rhs => rw [he]
|
| 287 |
+
rw [filter_filter, ← sum_boole]
|
| 288 |
+
apply sum_congr rfl
|
| 289 |
+
intro y _
|
| 290 |
+
simp only [insert_subset_iff, singleton_subset_iff, hx, true_and]
|
| 291 |
+
by_cases h : G.Adj x y <;> by_cases hy : y ∈ S <;> simp [h, hy]
|
| 292 |
+
· simp [insert_subset_iff, singleton_subset_iff, hx]
|
| 293 |
+
simp_rw [hi]
|
| 294 |
+
rw [← sum_filter]
|
| 295 |
+
simp [degreeMass, Nat.cast_sum]
|
| 296 |
+
|
| 297 |
+
theorem degreeMass_moment (p : ℝ) :
|
| 298 |
+
(∑ f : V → Bool, weight p f * degreeMass G (selected f)) =
|
| 299 |
+
p^2 * ∑ x : V, (G.degree x : ℝ) := by
|
| 300 |
+
simp_rw [degreeMass_pair_sum, mul_sum]
|
| 301 |
+
rw [sum_comm]
|
| 302 |
+
calc
|
| 303 |
+
_ = ∑ x : V, ∑ y : V, if G.Adj x y then p^2 else 0 := by
|
| 304 |
+
apply sum_congr rfl
|
| 305 |
+
intro x _
|
| 306 |
+
rw [sum_comm]
|
| 307 |
+
apply sum_congr rfl
|
| 308 |
+
intro y _
|
| 309 |
+
by_cases h : G.Adj x y
|
| 310 |
+
· simp only [ite_eq_left h]
|
| 311 |
+
rw [containment_moment]
|
| 312 |
+
simp [h.ne]
|
| 313 |
+
· simp [h]
|
| 314 |
+
_ = p^2 * ∑ x : V, (G.degree x : ℝ) := by
|
| 315 |
+
rw [mul_sum]
|
| 316 |
+
apply sum_congr rfl
|
| 317 |
+
intro x _
|
| 318 |
+
rw [← sum_filter]
|
| 319 |
+
simp [← G.card_neighborFinset_eq_degree, SimpleGraph.neighborFinset_def,
|
| 320 |
+
mul_comm]
|
| 321 |
+
_ = _ := by simp [mul_sum]
|
| 322 |
+
|
| 323 |
+
omit [Fintype V] in
|
| 324 |
+
|
| 325 |
+
theorem exists_avoid_family (F : Finset (Finset V))
|
| 326 |
+
(hF : ∀ A ∈ F, A.Nonempty) (S : Finset V) :
|
| 327 |
+
∃ U ⊆ S, S.card ≤ U.card + F.card ∧ ∀ A ∈ F, ¬ A ⊆ U := by
|
| 328 |
+
induction F using Finset.induction_on generalizing S with
|
| 329 |
+
| empty => exact ⟨S, Subset.rfl, by simp, by simp⟩
|
| 330 |
+
| @insert A F hAF ih =>
|
| 331 |
+
obtain ⟨U, hUS, hUcard, hU⟩ := ih (fun B hB => hF B (mem_insert_of_mem hB)) S
|
| 332 |
+
by_cases hAU : A ⊆ U
|
| 333 |
+
· obtain ⟨x, hx⟩ := hF A (mem_insert_self A F)
|
| 334 |
+
refine ⟨U.erase x, (erase_subset x U).trans hUS, ?_, ?_⟩
|
| 335 |
+
· have he := card_erase_of_mem (hAU hx)
|
| 336 |
+
rw [card_insert_of_notMem hAF]
|
| 337 |
+
omega
|
| 338 |
+
· intro B hB hBU
|
| 339 |
+
rcases mem_insert.mp hB with rfl | hB
|
| 340 |
+
· exact (notMem_erase x U) (hBU hx)
|
| 341 |
+
· exact hU B hB (hBU.trans (erase_subset x U))
|
| 342 |
+
· refine ⟨U, hUS, ?_, ?_⟩
|
| 343 |
+
· rw [card_insert_of_notMem hAF]
|
| 344 |
+
omega
|
| 345 |
+
· intro B hB hBU
|
| 346 |
+
rcases mem_insert.mp hB with rfl | hB
|
| 347 |
+
· exact hAU hBU
|
| 348 |
+
· exact hU B hB hBU
|
| 349 |
+
|
| 350 |
+
theorem prune (S : Finset V) {D : ℝ} (hD : 0 < D) :
|
| 351 |
+
∃ U ⊆ S,
|
| 352 |
+
(S.card : ℝ) - degreeMass G S / D - count (G.cliqueFinset 3) S ≤ U.card ∧
|
| 353 |
+
(∀ x ∈ U, (internalDegree G U x : ℝ) ≤ D) ∧
|
| 354 |
+
(G.induce (U : Set V)).CliqueFree 3 := by
|
| 355 |
+
let bad := S.filter (fun x => D < (internalDegree G S x : ℝ))
|
| 356 |
+
have hbad : (bad.card : ℝ) ≤ degreeMass G S / D := by
|
| 357 |
+
apply (le_div_iff₀ hD).mpr
|
| 358 |
+
calc
|
| 359 |
+
(bad.card : ℝ) * D = ∑ _x ∈ bad, D := by simp
|
| 360 |
+
_ ≤ ∑ x ∈ bad, (internalDegree G S x : ℝ) := by
|
| 361 |
+
exact sum_le_sum (fun x hx => (mem_filter.mp hx).2.le)
|
| 362 |
+
_ ≤ ∑ x ∈ S, (internalDegree G S x : ℝ) :=
|
| 363 |
+
sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (by intros; positivity)
|
| 364 |
+
_ = degreeMass G S := by simp [degreeMass, Nat.cast_sum]
|
| 365 |
+
let T := S \ bad
|
| 366 |
+
let F := (G.cliqueFinset 3).filter (· ⊆ S)
|
| 367 |
+
have hF : ∀ A ∈ F, A.Nonempty := by
|
| 368 |
+
intro A hA
|
| 369 |
+
have ha := (SimpleGraph.mem_cliqueFinset_iff.mp (mem_filter.mp hA).1).2
|
| 370 |
+
exact card_pos.mp (by omega)
|
| 371 |
+
obtain ⟨U, hUT, hcard, havoid⟩ := exists_avoid_family F hF T
|
| 372 |
+
have hUS : U ⊆ S := hUT.trans sdiff_subset
|
| 373 |
+
refine ⟨U, hUS, ?_, ?_, ?_⟩
|
| 374 |
+
· have hc : (S.card : ℝ) ≤ T.card + bad.card := by
|
| 375 |
+
exact_mod_cast card_le_card_sdiff_add_card
|
| 376 |
+
have hu : (T.card : ℝ) ≤ U.card + F.card := by exact_mod_cast hcard
|
| 377 |
+
change (S.card : ℝ) - degreeMass G S / D - F.card ≤ _
|
| 378 |
+
linarith
|
| 379 |
+
· intro x hx
|
| 380 |
+
have hxT := mem_sdiff.mp (hUT hx)
|
| 381 |
+
have hd : (internalDegree G S x : ℝ) ≤ D := by
|
| 382 |
+
by_contra! hh
|
| 383 |
+
exact hxT.2 (mem_filter.mpr ⟨hxT.1, hh⟩)
|
| 384 |
+
exact (Nat.cast_le.mpr (card_le_card (filter_subset_filter _ hUS))).trans hd
|
| 385 |
+
· rw [G.cliqueFree_induce_iff]
|
| 386 |
+
intro A hAU hA
|
| 387 |
+
have hAF : A ∈ F := mem_filter.mpr
|
| 388 |
+
⟨SimpleGraph.mem_cliqueFinset_iff.mpr hA, (show A ⊆ U from hAU).trans hUS⟩
|
| 389 |
+
exact havoid A hAF hAU
|
| 390 |
+
|
| 391 |
+
omit [Fintype V] [DecidableEq V] in
|
| 392 |
+
theorem induced_degree (U : Finset V) (x : (U : Set V)) :
|
| 393 |
+
(G.induce (U : Set V)).degree x = internalDegree G U x := by
|
| 394 |
+
rw [← SimpleGraph.card_neighborSet_eq_degree]
|
| 395 |
+
let e : ((G.induce (U : Set V)).neighborSet x) ≃
|
| 396 |
+
{y : V // y ∈ U.filter (G.Adj x)} :=
|
| 397 |
+
{ toFun := fun y => ⟨y.1, mem_filter.mpr ⟨y.1.2, y.2⟩⟩
|
| 398 |
+
invFun := fun y => ⟨⟨y.1, (mem_filter.mp y.2).1⟩, (mem_filter.mp y.2).2⟩
|
| 399 |
+
left_inv := by intro y; rfl
|
| 400 |
+
right_inv := by intro y; rfl }
|
| 401 |
+
exact (Fintype.card_congr e).trans (Fintype.card_coe (U.filter (G.Adj x)))
|
| 402 |
+
|
| 403 |
+
theorem sample_prune {p D : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) (hD : 0 < D) :
|
| 404 |
+
∃ U : Finset V,
|
| 405 |
+
p * Fintype.card V - p^2 * (∑ x, (G.degree x : ℝ)) / D -
|
| 406 |
+
p^3 * (G.cliqueFinset 3).card ≤ U.card ∧
|
| 407 |
+
(∀ x : (U : Set V), ((G.induce (U : Set V)).degree x : ℝ) ≤ D) ∧
|
| 408 |
+
(G.induce (U : Set V)).CliqueFree 3 := by
|
| 409 |
+
let X (f : V → Bool) : ℝ := (selected f).card -
|
| 410 |
+
degreeMass G (selected f) / D - count (G.cliqueFinset 3) (selected f)
|
| 411 |
+
have hmean : (∑ f, weight p f * X f) =
|
| 412 |
+
p * Fintype.card V - p^2 * (∑ x, (G.degree x : ℝ)) / D -
|
| 413 |
+
p^3 * (G.cliqueFinset 3).card := by
|
| 414 |
+
simp only [X, mul_sub, ← mul_div_assoc, sum_sub_distrib, ← sum_div]
|
| 415 |
+
rw [size_moment, degreeMass_moment, family_moment]
|
| 416 |
+
intro A hA
|
| 417 |
+
exact (SimpleGraph.mem_cliqueFinset_iff.mp hA).2
|
| 418 |
+
obtain ⟨f, hf⟩ := exists_ge_mean hp hp1 X
|
| 419 |
+
rw [hmean] at hf
|
| 420 |
+
obtain ⟨U, _hUS, hU, hdeg, htri⟩ := prune G (selected f) hD
|
| 421 |
+
refine ⟨U, hf.trans hU, ?_, htri⟩
|
| 422 |
+
intro x
|
| 423 |
+
rw [induced_degree]
|
| 424 |
+
exact hdeg x x.2
|
| 425 |
+
|
| 426 |
+
theorem triangle_count_le {h m : ℕ} (hdeg : ∀ x, G.degree x ≤ h)
|
| 427 |
+
(hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m) :
|
| 428 |
+
(G.cliqueFinset 3).card ≤ Fintype.card V * h * m := by
|
| 429 |
+
let T := Σ x : V, Σ y : G.neighborSet x, G.commonNeighbors x y
|
| 430 |
+
have hex (A : {A // A ∈ G.cliqueFinset 3}) :
|
| 431 |
+
∃ t : T, A.1 = {t.1, t.2.1.1, t.2.2.1} := by
|
| 432 |
+
obtain ⟨x,y,z,hxy,hxz,hyz,hA⟩ := SimpleGraph.is3Clique_iff.mp
|
| 433 |
+
(SimpleGraph.mem_cliqueFinset_iff.mp A.2)
|
| 434 |
+
exact ⟨⟨x, ⟨y,hxy⟩, ⟨z,hxz,hyz⟩⟩, hA⟩
|
| 435 |
+
choose f hf using hex
|
| 436 |
+
have hinj : Function.Injective f := by
|
| 437 |
+
intro A B hAB
|
| 438 |
+
apply Subtype.ext
|
| 439 |
+
rw [hf A, hf B, hAB]
|
| 440 |
+
calc
|
| 441 |
+
(G.cliqueFinset 3).card = Fintype.card {A // A ∈ G.cliqueFinset 3} := (Fintype.card_coe _).symm
|
| 442 |
+
_ ≤ Fintype.card T := Fintype.card_le_of_injective f hinj
|
| 443 |
+
_ = ∑ x : V, ∑ y : G.neighborSet x, Fintype.card (G.commonNeighbors x y) := by
|
| 444 |
+
simp [T, Fintype.card_sigma]
|
| 445 |
+
_ ≤ ∑ x : V, ∑ _y : G.neighborSet x, m := by
|
| 446 |
+
exact sum_le_sum (fun x _ => sum_le_sum (fun y _ => hcommon x y y.2))
|
| 447 |
+
_ ≤ ∑ _x : V, h*m := by
|
| 448 |
+
apply sum_le_sum
|
| 449 |
+
intro x _
|
| 450 |
+
simpa [G.card_neighborSet_eq_degree] using Nat.mul_le_mul_right m (hdeg x)
|
| 451 |
+
_ = Fintype.card V * h * m := by simp [mul_assoc]
|
| 452 |
+
|
| 453 |
+
end SharpLogRamsey.Sampling
|
| 454 |
+
|
| 455 |
+
open scoped BigOperators
|
| 456 |
+
namespace SharpLogRamsey.Upper
|
| 457 |
+
|
| 458 |
+
end SharpLogRamsey.Upper
|
| 459 |
+
end
|
| 460 |
+
|
| 461 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Bounds/Upper.lean
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Model
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Geometry.SpanPairLine
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! The off-diagonal Ramsey upper bound. -/
|
| 8 |
+
|
| 9 |
+
section
|
| 10 |
+
open scoped BigOperators Classical
|
| 11 |
+
open Finset
|
| 12 |
+
namespace SharpLogRamsey
|
| 13 |
+
|
| 14 |
+
namespace Foundation
|
| 15 |
+
variable {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
|
| 16 |
+
|
| 17 |
+
omit [Fintype V] [DecidableEq V] in
|
| 18 |
+
theorem indepNum_lt_of_cliqueFree_compl {t : ℕ} (ht : Gᶜ.CliqueFree t) :
|
| 19 |
+
G.indepNum < t := by
|
| 20 |
+
by_contra! h
|
| 21 |
+
obtain ⟨A, hA⟩ := G.exists_isNIndepSet_indepNum
|
| 22 |
+
exact (ht.mono h) A (G.isNClique_compl.mpr hA)
|
| 23 |
+
|
| 24 |
+
omit [DecidableEq V] in
|
| 25 |
+
theorem maximum_indep_dominates {A : Finset V} (hA : G.IsMaximumIndepSet A)
|
| 26 |
+
(x : V) : x ∈ A ∨ ∃ y ∈ A, G.Adj x y := by
|
| 27 |
+
by_contra! hn
|
| 28 |
+
have hi : G.IsIndepSet ((insert x A : Finset V) : Set V) := by
|
| 29 |
+
intro u hu v hv huv
|
| 30 |
+
simp only [mem_coe, mem_insert] at hu hv
|
| 31 |
+
rcases hu with rfl | hu <;> rcases hv with rfl | hv
|
| 32 |
+
· simp
|
| 33 |
+
· exact hn.2 v hv
|
| 34 |
+
· exact fun h => hn.2 u hu h.symm
|
| 35 |
+
· exact hA.1 hu hv huv
|
| 36 |
+
have hc := hA.2 (insert x A) hi
|
| 37 |
+
rw [card_insert_of_notMem hn.1] at hc
|
| 38 |
+
omega
|
| 39 |
+
|
| 40 |
+
theorem card_le_mul_indepNum {B : ℕ} (hdeg : ∀ x, G.degree x + 1 ≤ B) :
|
| 41 |
+
Fintype.card V ≤ B * G.indepNum := by
|
| 42 |
+
obtain ⟨A, hA⟩ := G.maximumIndepSet_exists
|
| 43 |
+
have hcover : (univ : Finset V) ⊆ A.biUnion (fun x => insert x (G.neighborFinset x)) := by
|
| 44 |
+
intro v _
|
| 45 |
+
obtain hv | ⟨x, hx, hadj⟩ := maximum_indep_dominates G hA v
|
| 46 |
+
· exact mem_biUnion.mpr ⟨v, hv, by simp⟩
|
| 47 |
+
· exact mem_biUnion.mpr ⟨x, hx, by simp [hadj.symm]⟩
|
| 48 |
+
calc
|
| 49 |
+
Fintype.card V = (univ : Finset V).card := (card_univ).symm
|
| 50 |
+
_ ≤ (A.biUnion (fun x => insert x (G.neighborFinset x))).card := card_le_card hcover
|
| 51 |
+
_ ≤ ∑ x ∈ A, (insert x (G.neighborFinset x)).card := card_biUnion_le
|
| 52 |
+
_ ≤ ∑ _x ∈ A, B := by
|
| 53 |
+
apply sum_le_sum
|
| 54 |
+
intro x _
|
| 55 |
+
simpa using hdeg x
|
| 56 |
+
_ = B * G.indepNum := by
|
| 57 |
+
simp [G.maximumIndepSet_card_eq_indepNum A hA, mul_comm]
|
| 58 |
+
|
| 59 |
+
omit [Fintype V] [DecidableEq V] in
|
| 60 |
+
theorem cliqueFree_neighbor {s : ℕ} (hs : G.CliqueFree (s+1)) (x : V) :
|
| 61 |
+
(G.induce (G.neighborSet x)).CliqueFree s := by
|
| 62 |
+
rw [G.cliqueFree_induce_iff]
|
| 63 |
+
have hc : G.CliqueFreeOn Set.univ (s+1) := (G.cliqueFreeOn_univ).mpr hs
|
| 64 |
+
simpa using SimpleGraph.CliqueFreeOn.of_succ G hc (a := x) (Set.mem_univ x)
|
| 65 |
+
|
| 66 |
+
omit [Fintype V] [DecidableEq V] in
|
| 67 |
+
theorem cliqueFree_induce {s : ℕ} (hs : G.CliqueFree s) (U : Set V) :
|
| 68 |
+
(G.induce U).CliqueFree s := by
|
| 69 |
+
rw [G.cliqueFree_induce_iff]
|
| 70 |
+
intro A _ hA
|
| 71 |
+
exact hs A hA
|
| 72 |
+
omit [Fintype V] [DecidableEq V] in
|
| 73 |
+
|
| 74 |
+
theorem compl_cliqueFree_induce {t : ℕ} (ht : Gᶜ.CliqueFree t) (U : Set V) :
|
| 75 |
+
(G.induce U)ᶜ.CliqueFree t := by
|
| 76 |
+
have he : (G.induce U)ᶜ = Gᶜ.induce U := by ext u v; simp [Subtype.val_inj]
|
| 77 |
+
rw [he]
|
| 78 |
+
exact cliqueFree_induce Gᶜ ht U
|
| 79 |
+
|
| 80 |
+
theorem order_avoiding_lt_pow (n : ℕ) {t : ℕ} (ht : 1 ≤ t) :
|
| 81 |
+
∀ {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V),
|
| 82 |
+
G.CliqueFree (n+2) → Gᶜ.CliqueFree t → Fintype.card V < t^(n+1) := by
|
| 83 |
+
induction n with
|
| 84 |
+
| zero =>
|
| 85 |
+
intro V _ _ G hs hi
|
| 86 |
+
have hg : G = ⊥ := G.cliqueFree_two.mp hs
|
| 87 |
+
have hn := card_le_mul_indepNum G (B := 1) (by intro x; simp [hg])
|
| 88 |
+
have hh := indepNum_lt_of_cliqueFree_compl G hi
|
| 89 |
+
simpa using hn.trans_lt (by simpa using hh)
|
| 90 |
+
| succ n ih =>
|
| 91 |
+
intro V _ _ G hs hi
|
| 92 |
+
have hd : ∀ x, G.degree x + 1 ≤ t^(n+1) := by
|
| 93 |
+
intro x
|
| 94 |
+
have hc := cliqueFree_neighbor G (s := n+2) (by simpa [Nat.add_assoc] using hs) x
|
| 95 |
+
have hci := compl_cliqueFree_induce G hi (G.neighborSet x)
|
| 96 |
+
have hh := ih (G.induce (G.neighborSet x)) hc hci
|
| 97 |
+
rw [G.card_neighborSet_eq_degree] at hh
|
| 98 |
+
omega
|
| 99 |
+
have hn := card_le_mul_indepNum G hd
|
| 100 |
+
have hi' := indepNum_lt_of_cliqueFree_compl G hi
|
| 101 |
+
have hp : 0 < t^(n+1) := pow_pos (by omega) _
|
| 102 |
+
have hm := Nat.mul_lt_mul_of_pos_left hi' hp
|
| 103 |
+
calc
|
| 104 |
+
Fintype.card V ≤ t^(n+1) * G.indepNum := hn
|
| 105 |
+
_ < t^(n+1) * t := hm
|
| 106 |
+
_ = t^(n+1+1) := (pow_succ _ _).symm
|
| 107 |
+
|
| 108 |
+
theorem ramseyProperty_pow (n : ℕ) {t : ℕ} (ht : 1 ≤ t) :
|
| 109 |
+
RamseyProperty (n+2) t (t^(n+1)) := by
|
| 110 |
+
intro G
|
| 111 |
+
by_cases hs : G.CliqueFree (n+2)
|
| 112 |
+
· right
|
| 113 |
+
by_contra! hi
|
| 114 |
+
have hh := order_avoiding_lt_pow n ht G hs hi
|
| 115 |
+
simp at hh
|
| 116 |
+
· left
|
| 117 |
+
simpa only [SimpleGraph.CliqueFree, not_forall, not_not] using hs
|
| 118 |
+
|
| 119 |
+
theorem ramseyProperty_nonempty {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) :
|
| 120 |
+
{N | RamseyProperty s t N}.Nonempty := by
|
| 121 |
+
obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le hs
|
| 122 |
+
exact ⟨t^(n+1), by simpa [Nat.add_comm] using ramseyProperty_pow n ht⟩
|
| 123 |
+
|
| 124 |
+
theorem ramsey_has_property {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) :
|
| 125 |
+
RamseyProperty s t (ramsey s t) := Nat.sInf_mem (ramseyProperty_nonempty hs ht)
|
| 126 |
+
|
| 127 |
+
omit [Fintype V] [DecidableEq V] in
|
| 128 |
+
theorem clique_map_embedding {U : Type*} (f : U ↪ V) {n : ℕ} {A : Finset U}
|
| 129 |
+
(hA : (G.comap f).IsNClique n A) : G.IsNClique n (A.map f) := by
|
| 130 |
+
constructor
|
| 131 |
+
· intro u hu v hv huv
|
| 132 |
+
obtain ⟨a, ha, rfl⟩ := mem_map.mp hu
|
| 133 |
+
obtain ⟨b, hb, rfl⟩ := mem_map.mp hv
|
| 134 |
+
exact hA.1 ha hb (fun h => huv (congrArg f h))
|
| 135 |
+
· simpa using hA.2
|
| 136 |
+
|
| 137 |
+
omit [Fintype V] [DecidableEq V] in
|
| 138 |
+
theorem compl_comap_embedding {U : Type*} (f : U ↪ V) :
|
| 139 |
+
(G.comap f)ᶜ = Gᶜ.comap f := by
|
| 140 |
+
ext u v
|
| 141 |
+
simp [SimpleGraph.comap_adj, f.injective.eq_iff]
|
| 142 |
+
|
| 143 |
+
omit [DecidableEq V] in
|
| 144 |
+
theorem property_for_finite_type {s t N : ℕ} (hN : RamseyProperty s t N)
|
| 145 |
+
(hcard : N ≤ Fintype.card V) :
|
| 146 |
+
(∃ A, G.IsNClique s A) ∨ (∃ B, Gᶜ.IsNClique t B) := by
|
| 147 |
+
obtain ⟨f⟩ := Function.Embedding.nonempty_of_card_le
|
| 148 |
+
(α := Fin N) (β := V) (by simpa using hcard)
|
| 149 |
+
obtain ⟨A, hA⟩ | ⟨B, hB⟩ := hN (G.comap f)
|
| 150 |
+
· exact Or.inl ⟨A.map f, clique_map_embedding G f hA⟩
|
| 151 |
+
· rw [compl_comap_embedding G f] at hB
|
| 152 |
+
exact Or.inr ⟨B.map f, clique_map_embedding Gᶜ f hB⟩
|
| 153 |
+
omit [DecidableEq V] in
|
| 154 |
+
|
| 155 |
+
theorem order_lt_ramsey {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t)
|
| 156 |
+
(hGs : G.CliqueFree s) (hGt : Gᶜ.CliqueFree t) :
|
| 157 |
+
Fintype.card V < ramsey s t := by
|
| 158 |
+
by_contra! h
|
| 159 |
+
obtain ⟨A, hA⟩ | ⟨B, hB⟩ := property_for_finite_type G (ramsey_has_property hs ht) h
|
| 160 |
+
· exact hGs A hA
|
| 161 |
+
· exact hGt B hB
|
| 162 |
+
|
| 163 |
+
theorem ramsey_le_of_property {s t N : ℕ} (hN : RamseyProperty s t N) :
|
| 164 |
+
ramsey s t ≤ N := Nat.sInf_le hN
|
| 165 |
+
|
| 166 |
+
theorem property_mono {s t N M : ℕ} (hN : RamseyProperty s t N) (hNM : N ≤ M) :
|
| 167 |
+
RamseyProperty s t M := by
|
| 168 |
+
intro G
|
| 169 |
+
exact property_for_finite_type G hN (by simpa using hNM)
|
| 170 |
+
|
| 171 |
+
theorem ramsey_le_pow {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) :
|
| 172 |
+
ramsey s t ≤ t^(s-1) := by
|
| 173 |
+
obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le hs
|
| 174 |
+
have hh := ramsey_le_of_property (ramseyProperty_pow n ht)
|
| 175 |
+
simpa [Nat.add_comm] using hh
|
| 176 |
+
|
| 177 |
+
theorem le_ramsey {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : t ≤ ramsey s t := by
|
| 178 |
+
obtain ⟨A,hA⟩ | ⟨B,hB⟩ := ramsey_has_property hs ht (⊥ : SimpleGraph (Fin (ramsey s t)))
|
| 179 |
+
· exact False.elim ((SimpleGraph.cliqueFree_bot (by omega : 1 < s)) A hA)
|
| 180 |
+
· have hb := card_le_card (subset_univ B)
|
| 181 |
+
simpa [hB.2] using hb
|
| 182 |
+
|
| 183 |
+
theorem ramsey_two {t : ℕ} (ht : 1 ≤ t) : ramsey 2 t = t := by
|
| 184 |
+
apply Nat.le_antisymm
|
| 185 |
+
· simpa using ramsey_le_pow (s := 2) (by omega) ht
|
| 186 |
+
· exact le_ramsey (by omega) ht
|
| 187 |
+
|
| 188 |
+
omit [Fintype V] [DecidableEq V] in
|
| 189 |
+
theorem cliqueFree_common {s : ℕ} (hs : G.CliqueFree (s+2))
|
| 190 |
+
{x y : V} (hxy : G.Adj x y) :
|
| 191 |
+
(G.induce (G.commonNeighbors x y)).CliqueFree s := by
|
| 192 |
+
rw [G.cliqueFree_induce_iff]
|
| 193 |
+
have hc : G.CliqueFreeOn Set.univ (s+2) := (G.cliqueFreeOn_univ).mpr hs
|
| 194 |
+
have hn : G.CliqueFreeOn (G.neighborSet x) (s+1) := by
|
| 195 |
+
simpa using SimpleGraph.CliqueFreeOn.of_succ G hc (a := x) (Set.mem_univ x)
|
| 196 |
+
exact SimpleGraph.CliqueFreeOn.of_succ G hn hxy
|
| 197 |
+
|
| 198 |
+
theorem exists_avoiding_pred {s t : ℕ} (hs : 2 ≤ s) (ht : 2 ≤ t) :
|
| 199 |
+
∃ G : SimpleGraph (Fin (ramsey s t - 1)), G.CliqueFree s ∧ Gᶜ.CliqueFree t := by
|
| 200 |
+
have hr : 2 ≤ ramsey s t := ht.trans (le_ramsey hs (by omega))
|
| 201 |
+
have hn : ¬ RamseyProperty s t (ramsey s t - 1) := by
|
| 202 |
+
intro h
|
| 203 |
+
have hh := ramsey_le_of_property h
|
| 204 |
+
omega
|
| 205 |
+
simp only [RamseyProperty, not_forall, not_or, not_exists] at hn
|
| 206 |
+
exact hn
|
| 207 |
+
|
| 208 |
+
end Foundation
|
| 209 |
+
end SharpLogRamsey
|
| 210 |
+
|
| 211 |
+
open scoped BigOperators Classical
|
| 212 |
+
open Finset
|
| 213 |
+
namespace SharpLogRamsey.TriangleFree
|
| 214 |
+
variable {V : Type*} [Fintype V] [DecidableEq V]
|
| 215 |
+
variable (G : SimpleGraph V)
|
| 216 |
+
|
| 217 |
+
noncomputable def independentSets : Finset (Finset V) :=
|
| 218 |
+
univ.filter (fun S => G.IsIndepSet (S : Set V))
|
| 219 |
+
|
| 220 |
+
@[simp] theorem mem_independentSets (S : Finset V) :
|
| 221 |
+
S ∈ independentSets G ↔ G.IsIndepSet (S : Set V) := by
|
| 222 |
+
simp [independentSets]
|
| 223 |
+
|
| 224 |
+
theorem independentSets_nonempty : (independentSets G).Nonempty := by
|
| 225 |
+
refine ⟨∅, ?_⟩
|
| 226 |
+
simp [SimpleGraph.IsIndepSet]
|
| 227 |
+
|
| 228 |
+
noncomputable def closed (x : V) : Finset V := insert x (G.neighborFinset x)
|
| 229 |
+
noncomputable def outside (x : V) (S : Finset V) : Finset V := S \ closed G x
|
| 230 |
+
noncomputable def available (x : V) (J : Finset V) : Finset V :=
|
| 231 |
+
(G.neighborFinset x).filter (fun u => ∀ v ∈ J, ¬G.Adj u v)
|
| 232 |
+
noncomputable def fiber (x : V) (J : Finset V) : Finset (Finset V) :=
|
| 233 |
+
(independentSets G).filter (fun S => outside G x S = J)
|
| 234 |
+
|
| 235 |
+
def Admissible (x : V) (J : Finset V) : Prop :=
|
| 236 |
+
G.IsIndepSet (J : Set V) ∧ Disjoint J (closed G x)
|
| 237 |
+
|
| 238 |
+
@[simp] theorem mem_closed (x u : V) : u ∈ closed G x ↔ u = x ∨ G.Adj x u := by
|
| 239 |
+
simp [closed]
|
| 240 |
+
@[simp] theorem mem_outside (x u : V) (S : Finset V) :
|
| 241 |
+
u ∈ outside G x S ↔ u ∈ S ∧ u ≠ x ∧ ¬G.Adj x u := by
|
| 242 |
+
simp [outside]
|
| 243 |
+
@[simp] theorem mem_available (x u : V) (J : Finset V) :
|
| 244 |
+
u ∈ available G x J ↔ G.Adj x u ∧ ∀ v ∈ J, ¬G.Adj u v := by
|
| 245 |
+
simp [available]
|
| 246 |
+
|
| 247 |
+
@[simp] theorem center_not_available (x : V) (J : Finset V) : x ∉ available G x J := by
|
| 248 |
+
simp
|
| 249 |
+
|
| 250 |
+
theorem admissible_outside (x : V) {S : Finset V}
|
| 251 |
+
(hS : S ∈ independentSets G) : Admissible G x (outside G x S) := by
|
| 252 |
+
constructor
|
| 253 |
+
· exact (mem_independentSets G S |>.mp hS).mono (by
|
| 254 |
+
intro u hu; exact (mem_outside G x u S |>.mp hu).1)
|
| 255 |
+
· exact disjoint_left.mpr (fun u hu hc => (Finset.mem_sdiff.mp hu).2 hc)
|
| 256 |
+
|
| 257 |
+
theorem admissible_not_center {x : V} {J : Finset V}
|
| 258 |
+
(hJ : Admissible G x J) : x ∉ J := by
|
| 259 |
+
intro hx
|
| 260 |
+
exact disjoint_left.mp hJ.2 hx (by simp)
|
| 261 |
+
|
| 262 |
+
theorem admissible_not_adj {x u : V} {J : Finset V}
|
| 263 |
+
(hJ : Admissible G x J) (hu : u ∈ J) : ¬G.Adj x u := by
|
| 264 |
+
intro h
|
| 265 |
+
exact disjoint_left.mp hJ.2 hu (by simp [h])
|
| 266 |
+
|
| 267 |
+
theorem available_disjoint {x : V} {J : Finset V}
|
| 268 |
+
(hJ : Admissible G x J) : Disjoint J (available G x J) := by
|
| 269 |
+
apply disjoint_left.mpr
|
| 270 |
+
intro u hJ' hu
|
| 271 |
+
exact admissible_not_adj G hJ hJ' (mem_available G x u J |>.mp hu).1
|
| 272 |
+
|
| 273 |
+
theorem independent_insert_center {x : V} {J : Finset V}
|
| 274 |
+
(hJ : Admissible G x J) : G.IsIndepSet ((insert x J : Finset V) : Set V) := by
|
| 275 |
+
intro u hu v hv huv
|
| 276 |
+
simp only [mem_coe, mem_insert] at hu hv
|
| 277 |
+
rcases hu with rfl | hu
|
| 278 |
+
· rcases hv with rfl | hv
|
| 279 |
+
· simp
|
| 280 |
+
· exact admissible_not_adj G hJ hv
|
| 281 |
+
· rcases hv with rfl | hv
|
| 282 |
+
· exact fun h => admissible_not_adj G hJ hu h.symm
|
| 283 |
+
· exact hJ.1 hu hv huv
|
| 284 |
+
|
| 285 |
+
theorem independent_extend (htri : G.CliqueFree 3) {x : V} {J K : Finset V}
|
| 286 |
+
(hJ : Admissible G x J) (hK : K ⊆ available G x J) :
|
| 287 |
+
G.IsIndepSet ((J ∪ K : Finset V) : Set V) := by
|
| 288 |
+
intro u hu v hv huv
|
| 289 |
+
simp only [mem_coe, mem_union] at hu hv
|
| 290 |
+
rcases hu with hu | hu <;> rcases hv with hv | hv
|
| 291 |
+
· exact hJ.1 hu hv huv
|
| 292 |
+
· exact fun h => (mem_available G x v J |>.mp (hK hv)).2 u hu h.symm
|
| 293 |
+
· exact (mem_available G x u J |>.mp (hK hu)).2 v hv
|
| 294 |
+
· exact (G.isIndepSet_neighborSet_of_triangleFree htri x)
|
| 295 |
+
(mem_available G x u J |>.mp (hK hu)).1
|
| 296 |
+
(mem_available G x v J |>.mp (hK hv)).1 huv
|
| 297 |
+
|
| 298 |
+
theorem outside_insert_center {x : V} {J : Finset V}
|
| 299 |
+
(hJ : Admissible G x J) : outside G x (insert x J) = J := by
|
| 300 |
+
ext u
|
| 301 |
+
simp only [mem_outside, mem_insert]
|
| 302 |
+
constructor
|
| 303 |
+
· rintro ⟨h, hne, _⟩
|
| 304 |
+
exact h.resolve_left hne
|
| 305 |
+
· intro hu
|
| 306 |
+
exact ⟨Or.inr hu, fun h => admissible_not_center G hJ (h ▸ hu),
|
| 307 |
+
admissible_not_adj G hJ hu⟩
|
| 308 |
+
|
| 309 |
+
theorem outside_extend {x : V} {J K : Finset V}
|
| 310 |
+
(hJ : Admissible G x J) (hK : K ⊆ available G x J) :
|
| 311 |
+
outside G x (J ∪ K) = J := by
|
| 312 |
+
ext u
|
| 313 |
+
simp only [mem_outside, mem_union]
|
| 314 |
+
constructor
|
| 315 |
+
· rintro ⟨hu | hu, _, hna⟩
|
| 316 |
+
· exact hu
|
| 317 |
+
· exact False.elim (hna (mem_available G x u J |>.mp (hK hu)).1)
|
| 318 |
+
· intro hu
|
| 319 |
+
exact ⟨Or.inl hu, fun h => admissible_not_center G hJ (h ▸ hu),
|
| 320 |
+
admissible_not_adj G hJ hu⟩
|
| 321 |
+
|
| 322 |
+
theorem fiber_eq (htri : G.CliqueFree 3) {x : V} {J : Finset V}
|
| 323 |
+
(hJ : Admissible G x J) :
|
| 324 |
+
fiber G x J = insert (insert x J)
|
| 325 |
+
((available G x J).powerset.image (fun K => J ∪ K)) := by
|
| 326 |
+
ext S
|
| 327 |
+
simp only [fiber, mem_filter, mem_independentSets, mem_insert, mem_image,
|
| 328 |
+
mem_powerset]
|
| 329 |
+
constructor
|
| 330 |
+
· rintro ⟨hS, hout⟩
|
| 331 |
+
by_cases hx : x ∈ S
|
| 332 |
+
· left
|
| 333 |
+
ext u
|
| 334 |
+
simp only [mem_insert]
|
| 335 |
+
constructor
|
| 336 |
+
· intro hu
|
| 337 |
+
by_cases hux : u = x
|
| 338 |
+
· exact Or.inl hux
|
| 339 |
+
· right
|
| 340 |
+
rw [← hout, mem_outside]
|
| 341 |
+
exact ⟨hu, hux, hS hx hu (Ne.symm hux)⟩
|
| 342 |
+
· rintro (rfl | hu)
|
| 343 |
+
· exact hx
|
| 344 |
+
· rw [← hout, mem_outside] at hu
|
| 345 |
+
exact hu.1
|
| 346 |
+
· right
|
| 347 |
+
refine ⟨S ∩ G.neighborFinset x, ?_, ?_⟩
|
| 348 |
+
· intro u hu
|
| 349 |
+
simp only [mem_inter, SimpleGraph.mem_neighborFinset] at hu
|
| 350 |
+
apply (mem_available G x u J).mpr
|
| 351 |
+
refine ⟨hu.2, ?_⟩
|
| 352 |
+
intro v hv hadj
|
| 353 |
+
have hvS : v ∈ S := by rw [← hout, mem_outside] at hv; exact hv.1
|
| 354 |
+
exact hS hu.1 hvS hadj.ne hadj
|
| 355 |
+
· ext u
|
| 356 |
+
simp only [mem_union, mem_inter, SimpleGraph.mem_neighborFinset]
|
| 357 |
+
constructor
|
| 358 |
+
· rintro (hu | hu)
|
| 359 |
+
· rw [← hout, mem_outside] at hu; exact hu.1
|
| 360 |
+
· exact hu.1
|
| 361 |
+
· intro hu
|
| 362 |
+
by_cases hax : G.Adj x u
|
| 363 |
+
· exact Or.inr ⟨hu, hax⟩
|
| 364 |
+
· left
|
| 365 |
+
rw [← hout, mem_outside]
|
| 366 |
+
exact ⟨hu, fun h => hx (h ▸ hu), hax⟩
|
| 367 |
+
· rintro (rfl | ⟨K, hK, rfl⟩)
|
| 368 |
+
· exact ⟨independent_insert_center G hJ, outside_insert_center G hJ⟩
|
| 369 |
+
· exact ⟨independent_extend G htri hJ hK, outside_extend G hJ hK⟩
|
| 370 |
+
|
| 371 |
+
theorem extend_injective {x : V} {J : Finset V} (hJ : Admissible G x J) :
|
| 372 |
+
Set.InjOn (fun K => J ∪ K) ((available G x J).powerset : Set (Finset V)) := by
|
| 373 |
+
intro K hK L hL heq
|
| 374 |
+
have hdK : Disjoint J K := (available_disjoint G hJ).mono_right (mem_powerset.mp hK)
|
| 375 |
+
have hdL : Disjoint J L := (available_disjoint G hJ).mono_right (mem_powerset.mp hL)
|
| 376 |
+
simpa [union_sdiff_cancel_left hdK, union_sdiff_cancel_left hdL] using
|
| 377 |
+
congrArg (fun S => S \ J) heq
|
| 378 |
+
|
| 379 |
+
theorem center_choice_not_image {x : V} {J : Finset V} (hJ : Admissible G x J) :
|
| 380 |
+
insert x J ∉ (available G x J).powerset.image (fun K => J ∪ K) := by
|
| 381 |
+
rintro h
|
| 382 |
+
obtain ⟨K, hK, heq⟩ := mem_image.mp h
|
| 383 |
+
have hx : x ∈ J ∪ K := heq ▸ mem_insert_self x J
|
| 384 |
+
rcases mem_union.mp hx with hx | hx
|
| 385 |
+
· exact admissible_not_center G hJ hx
|
| 386 |
+
· exact center_not_available G x J (mem_powerset.mp hK hx)
|
| 387 |
+
|
| 388 |
+
theorem card_fiber (htri : G.CliqueFree 3) {x : V} {J : Finset V}
|
| 389 |
+
(hJ : Admissible G x J) : (fiber G x J).card = 1 + 2^(available G x J).card := by
|
| 390 |
+
rw [fiber_eq G htri hJ, card_insert_of_notMem (center_choice_not_image G hJ),
|
| 391 |
+
card_image_of_injOn (extend_injective G hJ), card_powerset]
|
| 392 |
+
omega
|
| 393 |
+
|
| 394 |
+
theorem sum_fiber (htri : G.CliqueFree 3) {x : V} {J : Finset V}
|
| 395 |
+
(hJ : Admissible G x J) (f : Finset V → ℝ) :
|
| 396 |
+
∑ S ∈ fiber G x J, f S = f (insert x J) +
|
| 397 |
+
∑ K ∈ (available G x J).powerset, f (J ∪ K) := by
|
| 398 |
+
rw [fiber_eq G htri hJ, sum_insert (center_choice_not_image G hJ),
|
| 399 |
+
sum_image (extend_injective G hJ)]
|
| 400 |
+
|
| 401 |
+
omit [Fintype V] in
|
| 402 |
+
|
| 403 |
+
theorem twice_sum_powerset_card (A : Finset V) :
|
| 404 |
+
2 * (∑ K ∈ A.powerset, (K.card : ℝ)) = A.card * (2:ℝ)^A.card := by
|
| 405 |
+
have hc : ∑ K ∈ A.powerset, ((A \ K).card : ℝ) =
|
| 406 |
+
∑ K ∈ A.powerset, (K.card : ℝ) := by
|
| 407 |
+
apply sum_bij (fun K _ => A \ K)
|
| 408 |
+
· intro K _; exact mem_powerset.mpr sdiff_subset
|
| 409 |
+
· intro K hK L hL heq
|
| 410 |
+
have := congrArg (fun X => A \ X) heq
|
| 411 |
+
simpa [Finset.sdiff_sdiff_eq_self (mem_powerset.mp hK),
|
| 412 |
+
Finset.sdiff_sdiff_eq_self (mem_powerset.mp hL)] using this
|
| 413 |
+
· intro K hK
|
| 414 |
+
exact ⟨A \ K, mem_powerset.mpr sdiff_subset,
|
| 415 |
+
Finset.sdiff_sdiff_eq_self (mem_powerset.mp hK)⟩
|
| 416 |
+
· intro K _; rfl
|
| 417 |
+
have hsum : ∑ K ∈ A.powerset, (((A \ K).card : ℝ) + K.card) =
|
| 418 |
+
A.card * (2:ℝ)^A.card := by
|
| 419 |
+
calc
|
| 420 |
+
_ = ∑ _K ∈ A.powerset, (A.card : ℝ) := by
|
| 421 |
+
apply sum_congr rfl
|
| 422 |
+
intro K hK
|
| 423 |
+
exact_mod_cast card_sdiff_add_card_eq_card (mem_powerset.mp hK)
|
| 424 |
+
_ = _ := by simp [card_powerset]; ring
|
| 425 |
+
rw [sum_add_distrib, hc] at hsum
|
| 426 |
+
linarith
|
| 427 |
+
|
| 428 |
+
theorem center_neighbor_inter {x : V} {J : Finset V}
|
| 429 |
+
(hJ : Admissible G x J) : insert x J ∩ G.neighborFinset x = ∅ := by
|
| 430 |
+
apply eq_empty_iff_forall_notMem.mpr
|
| 431 |
+
intro u hu
|
| 432 |
+
simp only [mem_inter, mem_insert, SimpleGraph.mem_neighborFinset] at hu
|
| 433 |
+
rcases hu.1 with rfl | huJ
|
| 434 |
+
· exact G.irrefl hu.2
|
| 435 |
+
· exact admissible_not_adj G hJ huJ hu.2
|
| 436 |
+
|
| 437 |
+
theorem extend_neighbor_inter {x : V} {J K : Finset V}
|
| 438 |
+
(hJ : Admissible G x J) (hK : K ⊆ available G x J) :
|
| 439 |
+
(J ∪ K) ∩ G.neighborFinset x = K := by
|
| 440 |
+
ext u
|
| 441 |
+
simp only [mem_inter, mem_union, SimpleGraph.mem_neighborFinset]
|
| 442 |
+
constructor
|
| 443 |
+
· rintro ⟨hu | hu, hadj⟩
|
| 444 |
+
· exact False.elim (admissible_not_adj G hJ hu hadj)
|
| 445 |
+
· exact hu
|
| 446 |
+
· intro hu
|
| 447 |
+
exact ⟨Or.inr hu, (mem_available G x u J |>.mp (hK hu)).1⟩
|
| 448 |
+
|
| 449 |
+
end SharpLogRamsey.TriangleFree
|
| 450 |
+
end
|
| 451 |
+
|
| 452 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/FiniteStreamTail.lean
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
section
|
| 6 |
+
namespace SharpLogRamsey.FiniteStreamTail
|
| 7 |
+
open Finset Real
|
| 8 |
+
open scoped Classical BigOperators
|
| 9 |
+
noncomputable section
|
| 10 |
+
variable {α : Type*} [Fintype α]
|
| 11 |
+
|
| 12 |
+
def hits {N : ℕ} (S : Finset α) (z : Fin N→α) : ℕ :=
|
| 13 |
+
(univ.filter (fun i=>z i∈S)).card
|
| 14 |
+
|
| 15 |
+
def probability (S : Finset α) : ℝ := (S.card:ℝ)/(Fintype.card α:ℝ)
|
| 16 |
+
|
| 17 |
+
lemma moment (S : Finset α) (N : ℕ) :
|
| 18 |
+
(∑ z : Fin N→α,(2:ℝ)^hits S z)=
|
| 19 |
+
((Fintype.card α:ℝ)+(S.card:ℝ))^N := by
|
| 20 |
+
have hp (z : Fin N→α) :
|
| 21 |
+
(2:ℝ)^hits S z=∏ i,if z i∈S then (2:ℝ) else 1 := by
|
| 22 |
+
simp only [prod_ite,hits,prod_const,one_pow,mul_one]
|
| 23 |
+
have hs : (∑ a : α,if a∈S then (2:ℝ) else 1)=(Fintype.card α:ℝ)+(S.card:ℝ) := by
|
| 24 |
+
have he (a : α) : (if a∈S then (2:ℝ) else 1)=1+(if a∈S then 1 else 0) := by
|
| 25 |
+
split_ifs <;> norm_num
|
| 26 |
+
simp only [he,sum_add_distrib,sum_const,card_univ,nsmul_eq_mul,mul_one,
|
| 27 |
+
Fintype.sum_ite_mem,sum_const]
|
| 28 |
+
simp_rw [hp]
|
| 29 |
+
rw [←Fintype.prod_sum (fun (_ : Fin N) (a : α)=>if a∈S then (2:ℝ) else 1)]
|
| 30 |
+
simp only [hs,prod_const,card_univ,Fintype.card_fin]
|
| 31 |
+
|
| 32 |
+
variable [Nonempty α]
|
| 33 |
+
|
| 34 |
+
lemma card_pos : (0:ℝ)<Fintype.card α := by exact_mod_cast Fintype.card_pos
|
| 35 |
+
|
| 36 |
+
lemma average_moment (S : Finset α) (N : ℕ) :
|
| 37 |
+
(∑ z : Fin N→α,(2:ℝ)^hits S z)/(Fintype.card (Fin N→α):ℝ) =
|
| 38 |
+
(1+probability S)^N := by
|
| 39 |
+
rw [moment]
|
| 40 |
+
simp only [Fintype.card_fun,Fintype.card_fin,Nat.cast_pow,←div_pow,probability]
|
| 41 |
+
congr 1
|
| 42 |
+
rw [add_div,div_self (ne_of_gt (card_pos (α:=α)))]
|
| 43 |
+
|
| 44 |
+
lemma average_moment_le (S : Finset α) (N : ℕ) :
|
| 45 |
+
(∑ z : Fin N→α,(2:ℝ)^hits S z)/(Fintype.card (Fin N→α):ℝ) ≤
|
| 46 |
+
exp (N*probability S) := by
|
| 47 |
+
rw [average_moment,exp_nat_mul]
|
| 48 |
+
apply pow_le_pow_left₀
|
| 49 |
+
· exact add_nonneg zero_le_one (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))
|
| 50 |
+
· simpa only [add_comm] using Real.add_one_le_exp (probability S)
|
| 51 |
+
|
| 52 |
+
lemma single_tail (S : Finset α) (N : ℕ) (t : ℝ) :
|
| 53 |
+
probability (univ.filter (fun z : Fin N→α=>t≤hits S z)) ≤
|
| 54 |
+
exp (N*probability S-t*log 2) := by
|
| 55 |
+
let B := univ.filter (fun z : Fin N→α=>t≤hits S z)
|
| 56 |
+
have hsum : (B.card:ℝ)*exp (t*log 2)≤∑ z : Fin N→α,(2:ℝ)^hits S z := by
|
| 57 |
+
calc
|
| 58 |
+
_ = ∑ _z∈B,exp (t*log 2) := by simp
|
| 59 |
+
_ ≤ ∑ z∈B,(2:ℝ)^hits S z := by
|
| 60 |
+
apply sum_le_sum
|
| 61 |
+
intro z hz
|
| 62 |
+
have ht := (mem_filter.mp hz).2
|
| 63 |
+
have he : exp ((hits S z:ℝ)*log 2)=(2:ℝ)^hits S z := by
|
| 64 |
+
rw [exp_nat_mul,exp_log (by norm_num)]
|
| 65 |
+
rw [←he]
|
| 66 |
+
apply exp_le_exp.mpr
|
| 67 |
+
exact mul_le_mul_of_nonneg_right ht (log_nonneg (by norm_num))
|
| 68 |
+
_ ≤ _ := sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun _ _ _=>by positivity)
|
| 69 |
+
have hdiv := div_le_div_of_nonneg_right hsum (Nat.cast_nonneg (Fintype.card (Fin N→α)))
|
| 70 |
+
have hm := average_moment_le S N
|
| 71 |
+
have hb : probability B*exp (t*log 2)≤exp (N*probability S) := by
|
| 72 |
+
unfold probability
|
| 73 |
+
calc
|
| 74 |
+
_ = (B.card*exp (t*log 2))/(Fintype.card (Fin N→α):ℝ) := by ring
|
| 75 |
+
_ ≤ _ := hdiv.trans hm
|
| 76 |
+
have hh := (le_div_iff₀ (exp_pos (t*log 2))).mpr hb
|
| 77 |
+
simpa only [exp_sub] using hh
|
| 78 |
+
|
| 79 |
+
lemma probability_univ : probability (univ : Finset α)=1 := by
|
| 80 |
+
simp only [probability,card_univ]
|
| 81 |
+
exact div_self (ne_of_gt (card_pos (α:=α)))
|
| 82 |
+
|
| 83 |
+
lemma probability_compl (S : Finset α) : probability Sᶜ=1-probability S := by
|
| 84 |
+
simp only [probability,Finset.card_compl,Nat.cast_sub (card_le_univ S),sub_div,
|
| 85 |
+
div_self (ne_of_gt (card_pos (α:=α)))]
|
| 86 |
+
|
| 87 |
+
omit [Nonempty α] [Fintype α] in
|
| 88 |
+
lemma hits_embedding {N n : ℕ} (S : Finset α) (z : Fin N→α) (e : Fin n↪Fin N) :
|
| 89 |
+
hits S (z∘e)≤hits S z := by
|
| 90 |
+
let A := univ.filter (fun i : Fin n=>z (e i)∈S)
|
| 91 |
+
have he : A.map e⊆univ.filter (fun i : Fin N=>z i∈S) := by
|
| 92 |
+
intro i hi
|
| 93 |
+
obtain ⟨j,hj,rfl⟩ := mem_map.mp hi
|
| 94 |
+
exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hj).2⟩
|
| 95 |
+
simpa only [card_map,A,hits,Function.comp_def] using card_le_card he
|
| 96 |
+
|
| 97 |
+
variable {J : Type*} [Fintype J]
|
| 98 |
+
|
| 99 |
+
theorem simultaneous_tail (R : J→Finset α) (N : ℕ) (t μ : ℝ)
|
| 100 |
+
(hμ : ∀ j,(N:ℝ)*probability (R j)≤μ) :
|
| 101 |
+
probability (univ.filter (fun z : Fin N→α=>∃ j,t≤hits (R j) z)) ≤
|
| 102 |
+
(Fintype.card J:ℝ)*exp (μ-t*log 2) := by
|
| 103 |
+
let B := fun j=>univ.filter (fun z : Fin N→α=>t≤hits (R j) z)
|
| 104 |
+
have he : (univ.filter (fun z : Fin N→α=>∃ j,t≤hits (R j) z))=
|
| 105 |
+
univ.biUnion B := by ext z; simp [B]
|
| 106 |
+
rw [he]
|
| 107 |
+
have hc : ((univ.biUnion B).card:ℝ)≤∑ j,((B j).card:ℝ) := by
|
| 108 |
+
exact_mod_cast (card_biUnion_le (s:=univ) (t:=B))
|
| 109 |
+
calc
|
| 110 |
+
_ ≤ (∑ j,((B j).card:ℝ))/(Fintype.card (Fin N→α):ℝ) :=
|
| 111 |
+
div_le_div_of_nonneg_right hc (by positivity)
|
| 112 |
+
_ = ∑ j,probability (B j) := by rw [sum_div]; rfl
|
| 113 |
+
_ ≤ ∑ _j : J,exp (μ-t*log 2) := by
|
| 114 |
+
apply sum_le_sum
|
| 115 |
+
intro j _
|
| 116 |
+
exact (single_tail (R j) N t).trans (exp_le_exp.mpr (sub_le_sub_right (hμ j) _))
|
| 117 |
+
_ = _ := by simp
|
| 118 |
+
|
| 119 |
+
end
|
| 120 |
+
end SharpLogRamsey.FiniteStreamTail
|
| 121 |
+
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/FlagConstruction.lean
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Marking.Popular
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey
|
| 8 |
+
|
| 9 |
+
section LinearAlgebra
|
| 10 |
+
variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V]
|
| 11 |
+
|
| 12 |
+
theorem flag_vectors_independent {m : ℕ} (a : Fin m → V)
|
| 13 |
+
(b : Fin m → Module.Dual K V)
|
| 14 |
+
(ha : ∀ i, a i ≠ 0)
|
| 15 |
+
(hz : ∀ i j, i ≤ j → b j (a i) = 0)
|
| 16 |
+
(hn : ∀ i j, i < j → b i (a j) ≠ 0) :
|
| 17 |
+
LinearIndependent K a := by
|
| 18 |
+
induction m with
|
| 19 |
+
| zero => exact linearIndependent_empty_type
|
| 20 |
+
| succ m ih =>
|
| 21 |
+
apply linearIndependent_finSucc'.mpr
|
| 22 |
+
refine ⟨ih (Fin.init a) (Fin.init b) (fun i => ha i.castSucc)
|
| 23 |
+
(fun i j h => hz i.castSucc j.castSucc h)
|
| 24 |
+
(fun i j h => hn i.castSucc j.castSucc h), ?_⟩
|
| 25 |
+
cases m with
|
| 26 |
+
| zero => simpa using ha (Fin.last 0)
|
| 27 |
+
| succ n =>
|
| 28 |
+
intro hmem
|
| 29 |
+
let j : Fin (n + 1 + 1) := (Fin.last n).castSucc
|
| 30 |
+
have hspan : Submodule.span K (Set.range (Fin.init a)) ≤
|
| 31 |
+
LinearMap.ker (b j) := by
|
| 32 |
+
apply Submodule.span_le.mpr
|
| 33 |
+
rintro _ ⟨i, rfl⟩
|
| 34 |
+
exact hz i.castSucc j (by simpa [j] using Fin.le_last i)
|
| 35 |
+
have hzero : b j (a (Fin.last (n + 1))) = 0 := hspan hmem
|
| 36 |
+
exact hn j (Fin.last (n + 1)) (by simp [j]) hzero
|
| 37 |
+
|
| 38 |
+
theorem flag_length_lt_finrank [FiniteDimensional K V] {m : ℕ}
|
| 39 |
+
(a : Fin (m+1) → V) (b : Fin (m+1) → Module.Dual K V)
|
| 40 |
+
(ha : ∀ i, a i ≠ 0) (hb : b (Fin.last m) ≠ 0)
|
| 41 |
+
(hz : ∀ i j, i ≤ j → b j (a i) = 0)
|
| 42 |
+
(hn : ∀ i j, i < j → b i (a j) ≠ 0) :
|
| 43 |
+
m + 1 < Module.finrank K V := by
|
| 44 |
+
let W := LinearMap.ker (b (Fin.last m))
|
| 45 |
+
let a' : Fin (m+1) → W := fun i => ⟨a i, hz i (Fin.last m) (Fin.le_last i)⟩
|
| 46 |
+
have hli : LinearIndependent K a' :=
|
| 47 |
+
LinearIndependent.of_comp W.subtype (flag_vectors_independent a b ha hz hn)
|
| 48 |
+
have hle : m + 1 ≤ Module.finrank K W := by
|
| 49 |
+
simpa using hli.fintype_card_le_finrank
|
| 50 |
+
have hproper : W ≠ ⊤ := by
|
| 51 |
+
exact fun h => hb (LinearMap.ker_eq_top.mp h)
|
| 52 |
+
exact hle.trans_lt (Submodule.finrank_lt hproper)
|
| 53 |
+
|
| 54 |
+
end LinearAlgebra
|
| 55 |
+
|
| 56 |
+
section Flags
|
| 57 |
+
variable (K V : Type*) [Field K] [AddCommGroup V] [Module K V]
|
| 58 |
+
|
| 59 |
+
theorem incident_iff_submodule (a : Projectivization K V)
|
| 60 |
+
(b : Projectivization K (Module.Dual K V)) :
|
| 61 |
+
Incident K V a b ↔ a.submodule ≤ LinearMap.ker b.rep := by
|
| 62 |
+
rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem]
|
| 63 |
+
rfl
|
| 64 |
+
|
| 65 |
+
def flagGraph {N : ℕ} (F : Fin N → Flag K V) : SimpleGraph (Fin N) where
|
| 66 |
+
Adj i j :=
|
| 67 |
+
(i < j ∧ Incident K V (F i).point (F j).dualPoint ∧
|
| 68 |
+
¬ Incident K V (F j).point (F i).dualPoint) ∨
|
| 69 |
+
(j < i ∧ Incident K V (F j).point (F i).dualPoint ∧
|
| 70 |
+
¬ Incident K V (F i).point (F j).dualPoint)
|
| 71 |
+
symm := ⟨fun _ _ h => h.symm⟩
|
| 72 |
+
loopless := ⟨fun i => by simp⟩
|
| 73 |
+
|
| 74 |
+
variable {K V}
|
| 75 |
+
|
| 76 |
+
theorem flagGraph_adj_of_lt {N : ℕ} (F : Fin N → Flag K V)
|
| 77 |
+
{i j : Fin N} (hij : i < j) :
|
| 78 |
+
(flagGraph K V F).Adj i j ↔
|
| 79 |
+
Incident K V (F i).point (F j).dualPoint ∧
|
| 80 |
+
¬ Incident K V (F j).point (F i).dualPoint := by
|
| 81 |
+
simp only [flagGraph, hij, true_and, not_lt_of_ge hij.le, false_and, or_false]
|
| 82 |
+
|
| 83 |
+
theorem flagGraph_cliqueFree [FiniteDimensional K V] {d N : ℕ}
|
| 84 |
+
(hdim : Module.finrank K V = d+1) (F : Fin N → Flag K V) :
|
| 85 |
+
(flagGraph K V F).CliqueFree (d+1) := by
|
| 86 |
+
intro S hS
|
| 87 |
+
let e := S.orderEmbOfFin hS.card_eq
|
| 88 |
+
let a : Fin (d+1) → V := fun i => (F (e i)).point.rep
|
| 89 |
+
let b : Fin (d+1) → Module.Dual K V := fun i => (F (e i)).dualPoint.rep
|
| 90 |
+
have hedge (i j : Fin (d+1)) (h : i < j) :
|
| 91 |
+
Incident K V (F (e i)).point (F (e j)).dualPoint ∧
|
| 92 |
+
¬ Incident K V (F (e j)).point (F (e i)).dualPoint := by
|
| 93 |
+
apply (flagGraph_adj_of_lt F (e.strictMono h)).mp
|
| 94 |
+
exact hS.isClique (S.orderEmbOfFin_mem hS.card_eq i)
|
| 95 |
+
(S.orderEmbOfFin_mem hS.card_eq j) (ne_of_lt (e.strictMono h))
|
| 96 |
+
have hz : ∀ i j, i ≤ j → b j (a i) = 0 := by
|
| 97 |
+
intro i j h
|
| 98 |
+
rcases lt_or_eq_of_le h with hlt | rfl
|
| 99 |
+
· exact (hedge i j hlt).1
|
| 100 |
+
· exact (F (e i)).incident
|
| 101 |
+
have hn : ∀ i j, i < j → b i (a j) ≠ 0 := by
|
| 102 |
+
intro i j h
|
| 103 |
+
exact (hedge i j h).2
|
| 104 |
+
have hlt := flag_length_lt_finrank a b (fun i => (F (e i)).point.rep_nonzero)
|
| 105 |
+
(F (e (Fin.last d))).dualPoint.rep_nonzero hz hn
|
| 106 |
+
omega
|
| 107 |
+
|
| 108 |
+
theorem consistent_iff_no_edges {N : ℕ} (F : Fin N → Flag K V) :
|
| 109 |
+
Consistent F ↔ ∀ i j, ¬ (flagGraph K V F).Adj i j := by
|
| 110 |
+
constructor
|
| 111 |
+
· intro h i j hadj
|
| 112 |
+
rcases hadj with ⟨hij, hinc, hnot⟩ | ⟨hji, hinc, hnot⟩
|
| 113 |
+
· exact hnot (h i j hij hinc)
|
| 114 |
+
· exact hnot (h j i hji hinc)
|
| 115 |
+
· intro h i j hij hinc
|
| 116 |
+
by_contra hnot
|
| 117 |
+
exact h i j ((flagGraph_adj_of_lt F hij).mpr ⟨hinc, hnot⟩)
|
| 118 |
+
|
| 119 |
+
def ConsistentOn {N : ℕ} (F : Fin N → Flag K V) (S : Finset (Fin N)) : Prop :=
|
| 120 |
+
∀ i ∈ S, ∀ j ∈ S, i < j → Incident K V (F i).point (F j).dualPoint →
|
| 121 |
+
Incident K V (F j).point (F i).dualPoint
|
| 122 |
+
|
| 123 |
+
theorem consistentOn_iff_compl_isClique {N : ℕ} (F : Fin N → Flag K V)
|
| 124 |
+
(S : Finset (Fin N)) :
|
| 125 |
+
ConsistentOn F S ↔ (flagGraph K V F)ᶜ.IsClique S := by
|
| 126 |
+
constructor
|
| 127 |
+
· intro h i hi j hj hne
|
| 128 |
+
rw [SimpleGraph.compl_adj]
|
| 129 |
+
refine ⟨hne, ?_⟩
|
| 130 |
+
rintro (⟨hij, hinc, hnot⟩ | ⟨hji, hinc, hnot⟩)
|
| 131 |
+
· exact hnot (h i hi j hj hij hinc)
|
| 132 |
+
· exact hnot (h j hj i hi hji hinc)
|
| 133 |
+
· intro h i hi j hj hij hinc
|
| 134 |
+
have hnot := ((flagGraph K V F).compl_adj i j).mp (h hi hj (ne_of_lt hij))
|
| 135 |
+
by_contra hrev
|
| 136 |
+
exact hnot.2 ((flagGraph_adj_of_lt F hij).mpr ⟨hinc, hrev⟩)
|
| 137 |
+
|
| 138 |
+
noncomputable def projectiveSubmoduleEquiv (W : Submodule K V) :
|
| 139 |
+
Projectivization K W ≃ {a : Projectivization K V // a.submodule ≤ W} := by
|
| 140 |
+
let f : Projectivization K W → {a : Projectivization K V // a.submodule ≤ W} :=
|
| 141 |
+
fun a => ⟨Projectivization.map W.subtype W.injective_subtype a, by
|
| 142 |
+
induction a using Projectivization.ind with
|
| 143 |
+
| h v hv =>
|
| 144 |
+
rw [Projectivization.map_mk, Projectivization.submodule_mk,
|
| 145 |
+
Submodule.span_singleton_le_iff_mem]
|
| 146 |
+
exact v.property⟩
|
| 147 |
+
apply Equiv.ofBijective f
|
| 148 |
+
constructor
|
| 149 |
+
· intro a b h
|
| 150 |
+
exact Projectivization.map_injective W.subtype W.injective_subtype
|
| 151 |
+
(congrArg Subtype.val h)
|
| 152 |
+
· rintro ⟨a, ha⟩
|
| 153 |
+
have hmem : a.rep ∈ W := ha (by
|
| 154 |
+
rw [Projectivization.submodule_eq]
|
| 155 |
+
exact Submodule.mem_span_singleton_self _)
|
| 156 |
+
let v : W := ⟨a.rep, hmem⟩
|
| 157 |
+
have hv : v ≠ 0 := fun h => a.rep_nonzero (congrArg Subtype.val h)
|
| 158 |
+
refine ⟨Projectivization.mk K v hv, ?_⟩
|
| 159 |
+
apply Subtype.ext
|
| 160 |
+
exact a.mk_rep
|
| 161 |
+
|
| 162 |
+
theorem card_incident_points [Finite K] [FiniteDimensional K V] {d : ℕ}
|
| 163 |
+
(hdim : Module.finrank K V = d+1)
|
| 164 |
+
(b : Projectivization K (Module.Dual K V)) :
|
| 165 |
+
Nat.card {a : Projectivization K V // Incident K V a b} =
|
| 166 |
+
∑ i ∈ Finset.range d, Nat.card K ^ i := by
|
| 167 |
+
let e : {a : Projectivization K V // Incident K V a b} ≃
|
| 168 |
+
{a : Projectivization K V // a.submodule ≤ LinearMap.ker b.rep} :=
|
| 169 |
+
Equiv.subtypeEquivRight (fun a => incident_iff_submodule K V a b)
|
| 170 |
+
rw [Nat.card_congr e, ← Nat.card_congr (projectiveSubmoduleEquiv (LinearMap.ker b.rep))]
|
| 171 |
+
apply Projectivization.card_of_finrank
|
| 172 |
+
have h := Module.Dual.finrank_ker_add_one_of_ne_zero b.rep_nonzero
|
| 173 |
+
omega
|
| 174 |
+
|
| 175 |
+
theorem card_flags [Finite K] [FiniteDimensional K V] {d : ℕ}
|
| 176 |
+
(hdim : Module.finrank K V = d+1) :
|
| 177 |
+
Nat.card (Flag K V) =
|
| 178 |
+
(∑ i ∈ Finset.range (d+1), Nat.card K ^ i) *
|
| 179 |
+
(∑ i ∈ Finset.range d, Nat.card K ^ i) := by
|
| 180 |
+
classical
|
| 181 |
+
let : Finite V := Finite.of_injective (Module.finBasis K V).equivFun
|
| 182 |
+
(Module.finBasis K V).equivFun.injective
|
| 183 |
+
let : Finite (Module.Dual K V) :=
|
| 184 |
+
Finite.of_injective (Module.finBasis K (Module.Dual K V)).equivFun
|
| 185 |
+
(Module.finBasis K (Module.Dual K V)).equivFun.injective
|
| 186 |
+
let : Finite (Projectivization K V) :=
|
| 187 |
+
Finite.of_injective Projectivization.rep (fun a b h => by
|
| 188 |
+
rw [← a.mk_rep, ← b.mk_rep]; congr 1)
|
| 189 |
+
let : Finite (Projectivization K (Module.Dual K V)) :=
|
| 190 |
+
Finite.of_injective Projectivization.rep (fun a b h => by
|
| 191 |
+
rw [← a.mk_rep, ← b.mk_rep]; congr 1)
|
| 192 |
+
let := Fintype.ofFinite (Projectivization K (Module.Dual K V))
|
| 193 |
+
let e : Flag K V ≃ Σ b : Projectivization K (Module.Dual K V),
|
| 194 |
+
{a : Projectivization K V // Incident K V a b} :=
|
| 195 |
+
{ toFun := fun f => ⟨f.dualPoint, f.point, f.incident⟩
|
| 196 |
+
invFun := fun f => ⟨f.2.1, f.1, f.2.2⟩
|
| 197 |
+
left_inv := fun f => by cases f; rfl
|
| 198 |
+
right_inv := fun f => by cases f; rfl }
|
| 199 |
+
rw [Nat.card_congr e, Nat.card_sigma]
|
| 200 |
+
simp_rw [card_incident_points hdim]
|
| 201 |
+
simp only [Finset.sum_const, Finset.card_univ, smul_eq_mul]
|
| 202 |
+
rw [← Nat.card_eq_fintype_card]
|
| 203 |
+
rw [Projectivization.card_of_finrank K (Module.Dual K V)
|
| 204 |
+
(Subspace.dual_finrank_eq.trans hdim)]
|
| 205 |
+
|
| 206 |
+
theorem prime_flagGraph_cliqueFree (q d N : ℕ) [Fact q.Prime]
|
| 207 |
+
(F : Fin N → Flag (ZMod q) (Fin (d+1) → ZMod q)) :
|
| 208 |
+
(flagGraph (ZMod q) (Fin (d+1) → ZMod q) F).CliqueFree (d+1) := by
|
| 209 |
+
apply flagGraph_cliqueFree
|
| 210 |
+
simp
|
| 211 |
+
|
| 212 |
+
end Flags
|
| 213 |
+
end SharpLogRamsey
|
| 214 |
+
|
| 215 |
+
end
|
| 216 |
+
|
| 217 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/GraphWitness.lean
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Parameters.FiniteIteration
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Parameters.NoContext
|
| 4 |
+
import OAI.Combinatorics.SharpRamsey.Construction.InitialLaw
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
namespace SharpLogRamsey.Marking
|
| 10 |
+
open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales
|
| 11 |
+
open scoped Classical BigOperators Topology
|
| 12 |
+
noncomputable section
|
| 13 |
+
local instance witnessFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) :=
|
| 14 |
+
Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective
|
| 15 |
+
local instance witnessFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) :=
|
| 16 |
+
Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective
|
| 17 |
+
local instance witnessProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _
|
| 18 |
+
local instance witnessDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _
|
| 19 |
+
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 _
|
| 20 |
+
|
| 21 |
+
theorem eventually_graph_witness (i : ℕ) (η : ℝ) (hη : 0 < η) (hηu : η ≤ 1) :
|
| 22 |
+
∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) →
|
| 23 |
+
∀ N k : ℕ, 0 < k → k ≤ N → (k:ℝ) ≤ (q:ℝ)*σ^(1+η) →
|
| 24 |
+
((q:ℝ)*σ^(1+η))/2 ≤ k → (N:ℝ) ≤ (q:ℝ)^(i+3)*σ →
|
| 25 |
+
∃ G : SimpleGraph (Fin N),G.CliqueFree (i+4) ∧ G.indepNum < k := by
|
| 26 |
+
let P:=max 4 (stepPrefactor (i+3))
|
| 27 |
+
let T:=⌈8/η⌉₊+1
|
| 28 |
+
let Lstar:ℝ:=(4*classCount i)^T
|
| 29 |
+
let c:ℝ:=(1/2)/(256*classCount i)^T
|
| 30 |
+
have hP4 : 4 ≤ P:=le_max_left _ _
|
| 31 |
+
have hP1 : 1 ≤ P:=by linarith
|
| 32 |
+
have hPs : stepPrefactor (i+3) ≤ P:=le_max_right _ _
|
| 33 |
+
have hK : 0 < classCount i:=classCount_pos i
|
| 34 |
+
have hLs : 0 < Lstar:=by dsimp [Lstar];positivity
|
| 35 |
+
have hc : 0 < c:=by dsimp [c];positivity
|
| 36 |
+
filter_upwards [eventually_iterated_context i η P (InitialExperiment.occupancyConstant i)
|
| 37 |
+
hη hηu hP1 hPs (InitialExperiment.occupancyConstant_pos i).le,
|
| 38 |
+
eventually_no_small_context i η c Lstar P hη hc hLs hP1] with σ hiter hnone
|
| 39 |
+
intro q _ hq he N k hk hkn hku hklo hN
|
| 40 |
+
by_contra! hbad
|
| 41 |
+
have h : ∀ z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q),
|
| 42 |
+
k ≤ (flagGraph (ZMod q) (Fin (i+4)→ZMod q) z).indepNum:=by
|
| 43 |
+
intro z
|
| 44 |
+
exact hbad _ (prime_flagGraph_cliqueFree q (i+3) N z)
|
| 45 |
+
have hlog : log (q:ℝ)=σ:=by rw [←he,log_exp]
|
| 46 |
+
have hNlog : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ):=by simpa only [hlog] using hN
|
| 47 |
+
let Ω:=InitialExperiment.goodEvent i q N
|
| 48 |
+
let p:=InitialExperiment.law i q N hNlog
|
| 49 |
+
let stream : Ω→Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q):=Subtype.val
|
| 50 |
+
let F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q):=InitialExperiment.tuple i q N k h
|
| 51 |
+
have hdom : ∀ g,(p.map stream).mass g ≤ 2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N:=
|
| 52 |
+
InitialExperiment.law_dom i q N hNlog
|
| 53 |
+
have hsel : ∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x):=by
|
| 54 |
+
intro x _
|
| 55 |
+
exact Or.inr (InitialExperiment.tuple_occurs i q N k h x)
|
| 56 |
+
have hcon : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (fun j=>flagPair (F x j))).map toScan):=by
|
| 57 |
+
intro x _
|
| 58 |
+
exact InitialExperiment.tuple_consistent i q N k h x
|
| 59 |
+
have hocc : ∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q),
|
| 60 |
+
((univ.filter (fun j : Fin k=>(flagPair (F x j)).swap∈
|
| 61 |
+
orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤
|
| 62 |
+
InitialExperiment.occupancyConstant i*σ:=by
|
| 63 |
+
intro x _ W
|
| 64 |
+
simpa only [hlog] using InitialExperiment.tuple_occupancy i q N k h x W
|
| 65 |
+
let e0:=initial_context p F _ (InitialExperiment.alphabet_cap i q hP4 σ he)
|
| 66 |
+
obtain ⟨m,hm,⟨e⟩⟩:=hiter q hq he Ω N k p stream F hk hkn hku hklo hdom hsel hN hcon hocc e0
|
| 67 |
+
exact hnone q he Ω N k m p stream F hkn hku hdom hsel hN hcon hm ⟨e⟩
|
| 68 |
+
end
|
| 69 |
+
end SharpLogRamsey.Marking
|
| 70 |
+
|
| 71 |
+
end
|
| 72 |
+
|
| 73 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/InitialLaw.lean
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Construction.InitialTools
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey.InitialExperiment
|
| 8 |
+
open Finset Real Filter Selection Marking FiniteStreamTail RectangleStreamEvent
|
| 9 |
+
open scoped Classical BigOperators Topology
|
| 10 |
+
noncomputable section
|
| 11 |
+
local instance initLawFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) :=
|
| 12 |
+
Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective
|
| 13 |
+
local instance initLawFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) :=
|
| 14 |
+
Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective
|
| 15 |
+
local instance initLawProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _
|
| 16 |
+
local instance initLawDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _
|
| 17 |
+
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 _
|
| 18 |
+
|
| 19 |
+
def occupancyConstant (i : ℕ) : ℝ := (((i+4)^2:ℕ)+5:ℝ)/log 2
|
| 20 |
+
|
| 21 |
+
lemma occupancyConstant_pos (i : ℕ) : 0 < occupancyConstant i:=by
|
| 22 |
+
unfold occupancyConstant
|
| 23 |
+
exact div_pos (by positivity) (log_pos (by norm_num))
|
| 24 |
+
|
| 25 |
+
variable (i q : ℕ) [Fact q.Prime] (N k : ℕ)
|
| 26 |
+
|
| 27 |
+
local instance initLawFlagNonempty : Nonempty (Flag (ZMod q) (Fin (i+4)→ZMod q)):=
|
| 28 |
+
Fintype.card_pos_iff.mp (by
|
| 29 |
+
have hh:=flags_card_pos (K:=ZMod q) (V:=Fin (i+4)→ZMod q) (d:=i+3) (by omega) (by simp)
|
| 30 |
+
simpa only [←Nat.card_eq_fintype_card] using hh)
|
| 31 |
+
|
| 32 |
+
def goodEvent : Finset (Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)):=
|
| 33 |
+
univ.filter (fun z=>∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q),
|
| 34 |
+
(hits (rectangle W) z:ℝ)<occupancyConstant i*log (q:ℝ))
|
| 35 |
+
|
| 36 |
+
lemma goodEvent_half (hN : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ)) :
|
| 37 |
+
(1:ℝ)/2 ≤ probability (goodEvent i q N) := by
|
| 38 |
+
have hh:=simultaneous_good_probability (d:=i+3) (N:=N) (K:=ZMod q) (V:=Fin (i+4)→ZMod q)
|
| 39 |
+
(by omega) (by simp) (by simpa only [Nat.card_zmod] using hN)
|
| 40 |
+
have hq : 2 ≤ (q:ℝ):=by exact_mod_cast (Fact.out : q.Prime).two_le
|
| 41 |
+
have hq0 : (0:ℝ) < q:=by linarith
|
| 42 |
+
have hdiv : 1/(q:ℝ) ≤ 1/2:=(div_le_iff₀ hq0).mpr (by linarith)
|
| 43 |
+
have hin : (1:ℝ)/2 ≤ 1-1/q:=by linarith
|
| 44 |
+
apply hin.trans
|
| 45 |
+
simpa only [goodEvent,occupancyConstant,Nat.card_zmod,show i+3+1=i+4 by omega,
|
| 46 |
+
probability,hits,rectangle,mem_filter,mem_univ,true_and,←Fintype.card_subtype,
|
| 47 |
+
←Nat.card_eq_fintype_card] using hh
|
| 48 |
+
|
| 49 |
+
def law (hN : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ)) : Law (goodEvent i q N):=
|
| 50 |
+
uniformLaw.onEvent (goodEvent i q N) (by rw [uniformLaw_event]; have:=goodEvent_half i q N hN;linarith)
|
| 51 |
+
|
| 52 |
+
lemma law_dom (hN : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ)) :
|
| 53 |
+
∀ g,((law i q N hN).map (Subtype.val : goodEvent i q N→_)).mass g ≤
|
| 54 |
+
2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N := by
|
| 55 |
+
intro g
|
| 56 |
+
have hh:=uniformLaw_conditioned (goodEvent_half i q N hN) g
|
| 57 |
+
convert hh using 1 <;> simp only [law,Fintype.card_fun,Fintype.card_fin,Nat.cast_pow]
|
| 58 |
+
|
| 59 |
+
variable (h : ∀ z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q),
|
| 60 |
+
k ≤ (flagGraph (ZMod q) (Fin (i+4)→ZMod q) z).indepNum)
|
| 61 |
+
|
| 62 |
+
def chosen (z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) : Fin k↪o Fin N:=
|
| 63 |
+
Classical.choose (independent_selected z (h z))
|
| 64 |
+
|
| 65 |
+
lemma chosen_consistent (z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) :
|
| 66 |
+
Consistent (fun j=>z (chosen i q N k h z j)):=Classical.choose_spec (independent_selected z (h z))
|
| 67 |
+
|
| 68 |
+
def tuple (z : goodEvent i q N) : Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q):=
|
| 69 |
+
fun j=>z.val (chosen i q N k h z.val j.rev)
|
| 70 |
+
|
| 71 |
+
lemma tuple_occurs (z : goodEvent i q N) : Occurs (reverseTuple (tuple i q N k h z)) z.val := by
|
| 72 |
+
apply (occurs_iff_orderEmbedding _ _).mpr
|
| 73 |
+
refine ⟨chosen i q N k h z.val,?_⟩
|
| 74 |
+
intro j
|
| 75 |
+
simp only [reverseTuple,tuple,Fin.rev_rev]
|
| 76 |
+
|
| 77 |
+
lemma tuple_consistent (z : goodEvent i q N) :
|
| 78 |
+
ScanConsistent ((List.ofFn (fun j=>flagPair (tuple i q N k h z j))).map toScan) :=
|
| 79 |
+
selected_reverse_consistent z.val (chosen i q N k h z.val) (chosen_consistent i q N k h z.val)
|
| 80 |
+
|
| 81 |
+
lemma tuple_occupancy (z : goodEvent i q N) :
|
| 82 |
+
∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q),
|
| 83 |
+
((univ.filter (fun j : Fin k=>(flagPair (tuple i q N k h z j)).swap∈
|
| 84 |
+
orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤
|
| 85 |
+
occupancyConstant i*log (q:ℝ) := by
|
| 86 |
+
intro W
|
| 87 |
+
let e : Fin k↪Fin N:= (Equiv.toEmbedding (Equiv.ofBijective Fin.rev (by
|
| 88 |
+
constructor
|
| 89 |
+
· intro a b hab;simpa using congrArg Fin.rev hab
|
| 90 |
+
· intro a;exact ⟨a.rev,by simp⟩))).trans (chosen i q N k h z.val).toEmbedding
|
| 91 |
+
have hh:=hits_embedding (rectangle W) z.val e
|
| 92 |
+
have hz : (hits (rectangle W) z.val:ℝ)<occupancyConstant i*log (q:ℝ):=(mem_filter.mp z.property).2 W
|
| 93 |
+
apply le_trans _ hz.le
|
| 94 |
+
convert (Nat.cast_le (α:=ℝ)).mpr hh using 1
|
| 95 |
+
congr 1
|
| 96 |
+
apply congrArg Finset.card
|
| 97 |
+
ext j
|
| 98 |
+
simp only [mem_filter,mem_univ,true_and,rectangle_pair_iff]
|
| 99 |
+
rfl
|
| 100 |
+
|
| 101 |
+
lemma alphabet_cap {P : ℝ} (hP : 4 ≤ P) (σ : ℝ) (he : exp σ=(q:ℝ)) :
|
| 102 |
+
(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ) ≤
|
| 103 |
+
P*(q:ℝ)^(i+3)*exp (((i+2:ℕ):ℝ)*σ) := by
|
| 104 |
+
have hq : 2 ≤ q:=(Fact.out : q.Prime).two_le
|
| 105 |
+
have hh : Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)) ≤ 4*q^(i+3)*q^(i+2):=by
|
| 106 |
+
rw [actualFlag_card (d:=i+3) (by simp),Nat.card_zmod]
|
| 107 |
+
have h1:=InitialRectangles.sum_powers_le_two hq (show 0 < i+3+1 by omega)
|
| 108 |
+
have h2:=InitialRectangles.sum_powers_le_two hq (show 0 < i+3 by omega)
|
| 109 |
+
have hx:=Nat.mul_le_mul h1 h2
|
| 110 |
+
simp only [Nat.add_sub_cancel,show i+3-1=i+2 by omega] at hx
|
| 111 |
+
exact hx.trans_eq (by ring)
|
| 112 |
+
rw [exp_nat_mul,he]
|
| 113 |
+
have hh' : (Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ) ≤ 4*(q:ℝ)^(i+3)*(q:ℝ)^(i+2):=by exact_mod_cast hh
|
| 114 |
+
apply hh'.trans
|
| 115 |
+
gcongr
|
| 116 |
+
end
|
| 117 |
+
end SharpLogRamsey.InitialExperiment
|
| 118 |
+
|
| 119 |
+
end
|
| 120 |
+
|
| 121 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/InitialRectangles.lean
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Construction.FlagConstruction
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey.InitialRectangles
|
| 8 |
+
open Finset Real
|
| 9 |
+
open scoped Classical BigOperators
|
| 10 |
+
noncomputable section
|
| 11 |
+
variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V]
|
| 12 |
+
[FiniteDimensional K V]
|
| 13 |
+
|
| 14 |
+
local instance flat_JoinedInitialRectangles_1 : Finite (Module.Dual K V) := Module.finite_of_finite K
|
| 15 |
+
local instance flat_JoinedInitialRectangles_2 : Finite (Projectivization K V) := by
|
| 16 |
+
let : Finite V := Module.finite_of_finite K
|
| 17 |
+
exact Finite.of_injective Projectivization.rep (fun a b h => by
|
| 18 |
+
rw [←a.mk_rep,←b.mk_rep]; congr 1)
|
| 19 |
+
local instance flat_JoinedInitialRectangles_3 : Finite (Projectivization K (Module.Dual K V)) :=
|
| 20 |
+
Finite.of_injective Projectivization.rep (fun a b h => by
|
| 21 |
+
rw [←a.mk_rep,←b.mk_rep]; congr 1)
|
| 22 |
+
local instance flat_JoinedInitialRectangles_4 : Finite (Flag K V) :=
|
| 23 |
+
Finite.of_injective (fun f : Flag K V => (f.point,f.dualPoint)) (by
|
| 24 |
+
intro a b h
|
| 25 |
+
cases a; cases b
|
| 26 |
+
cases h
|
| 27 |
+
rfl)
|
| 28 |
+
local instance flat_JoinedInitialRectangles_5 : Finite (Submodule K V) := by
|
| 29 |
+
let : Finite V := Module.finite_of_finite K
|
| 30 |
+
exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective
|
| 31 |
+
|
| 32 |
+
def IsRectangle (W : Submodule K V) (f : Flag K V) : Prop :=
|
| 33 |
+
f.point.submodule≤W ∧ f.dualPoint.submodule≤W.dualAnnihilator
|
| 34 |
+
|
| 35 |
+
omit [FiniteDimensional K V] in
|
| 36 |
+
lemma card_points (W : Submodule K V) :
|
| 37 |
+
Nat.card {a : Projectivization K V // a.submodule≤W} =
|
| 38 |
+
∑ i∈range (Module.finrank K W),(Nat.card K)^i := by
|
| 39 |
+
rw [←Nat.card_congr (projectiveSubmoduleEquiv W)]
|
| 40 |
+
exact Projectivization.card_of_finrank K W rfl
|
| 41 |
+
|
| 42 |
+
lemma card_rectangle_le (W : Submodule K V) :
|
| 43 |
+
Nat.card {f : Flag K V // IsRectangle W f} ≤
|
| 44 |
+
(∑ i∈range (Module.finrank K W),(Nat.card K)^i)*
|
| 45 |
+
(∑ i∈range (Module.finrank K W.dualAnnihilator),(Nat.card K)^i) := by
|
| 46 |
+
let f : {f : Flag K V // IsRectangle W f} →
|
| 47 |
+
{a : Projectivization K V // a.submodule≤W} ×
|
| 48 |
+
{b : Projectivization K (Module.Dual K V) // b.submodule≤W.dualAnnihilator} :=
|
| 49 |
+
fun z => (⟨z.1.point,z.2.1⟩,⟨z.1.dualPoint,z.2.2⟩)
|
| 50 |
+
have hi : Function.Injective f := by
|
| 51 |
+
intro a b h
|
| 52 |
+
apply Subtype.ext
|
| 53 |
+
have hp := congrArg (fun z => z.1.val) h
|
| 54 |
+
have hd := congrArg (fun z => z.2.val) h
|
| 55 |
+
cases a with | mk a ha =>
|
| 56 |
+
cases b with | mk b hb =>
|
| 57 |
+
cases a; cases b
|
| 58 |
+
simp only [f] at hp hd
|
| 59 |
+
cases hp; cases hd; rfl
|
| 60 |
+
exact (Nat.card_le_card_of_injective f hi).trans_eq (by
|
| 61 |
+
rw [Nat.card_prod,card_points,card_points])
|
| 62 |
+
|
| 63 |
+
lemma card_subspaces_le :
|
| 64 |
+
Nat.card (Submodule K V)≤(Nat.card K)^(Module.finrank K V)^2 := by
|
| 65 |
+
let : Finite V := Module.finite_of_finite K
|
| 66 |
+
let : Finite (V→ₗ[K]V) := Finite.of_injective DFunLike.coe DFunLike.coe_injective
|
| 67 |
+
have hs : Function.Surjective (LinearMap.range : (V→ₗ[K]V)→Submodule K V) := by
|
| 68 |
+
intro W
|
| 69 |
+
obtain ⟨Q,hQ⟩ := W.exists_isCompl
|
| 70 |
+
exact ⟨W.projection Q hQ,W.range_projection hQ⟩
|
| 71 |
+
apply (Nat.card_le_card_of_surjective _ hs).trans_eq
|
| 72 |
+
let : Fintype K := Fintype.ofFinite K
|
| 73 |
+
let : Fintype (V→ₗ[K]V) := Fintype.ofFinite _
|
| 74 |
+
simpa only [Nat.card_eq_fintype_card,Module.finrank_linearMap,pow_two] using
|
| 75 |
+
(Module.card_eq_pow_finrank (K:=K) (V:=V→ₗ[K]V))
|
| 76 |
+
|
| 77 |
+
omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] in
|
| 78 |
+
lemma sum_powers_le_two {q n : ℕ} (hq : 2≤q) (hn : 0<n) :
|
| 79 |
+
∑ i∈range n,q^i≤2*q^(n-1) := by
|
| 80 |
+
obtain ⟨m,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hn)
|
| 81 |
+
clear hn
|
| 82 |
+
induction m with
|
| 83 |
+
| zero => simp
|
| 84 |
+
| succ m ih =>
|
| 85 |
+
rw [sum_range_succ]
|
| 86 |
+
simp only [Nat.succ_eq_add_one,Nat.add_sub_cancel] at *
|
| 87 |
+
have hm : 2*q^m≤q^(m+1) := by
|
| 88 |
+
rw [pow_succ]
|
| 89 |
+
simpa only [mul_comm] using Nat.mul_le_mul_left (q^m) hq
|
| 90 |
+
omega
|
| 91 |
+
|
| 92 |
+
lemma card_rectangle_bound {d : ℕ} (hd : 1≤d)
|
| 93 |
+
(hdim : Module.finrank K V=d+1) (W : Submodule K V) :
|
| 94 |
+
Nat.card {f : Flag K V // IsRectangle W f} ≤ 4*(Nat.card K)^(d-1) := by
|
| 95 |
+
have hq : 2≤Nat.card K := Finite.one_lt_card (α:=K)
|
| 96 |
+
have hs := Subspace.finrank_add_finrank_dualAnnihilator_eq W
|
| 97 |
+
rw [hdim] at hs
|
| 98 |
+
let r := Module.finrank K W
|
| 99 |
+
let s := Module.finrank K W.dualAnnihilator
|
| 100 |
+
by_cases hr : r=0
|
| 101 |
+
· apply (card_rectangle_le W).trans
|
| 102 |
+
change (∑ i∈range r,(Nat.card K)^i)*_≤_
|
| 103 |
+
simp [hr]
|
| 104 |
+
by_cases ht : s=0
|
| 105 |
+
· apply (card_rectangle_le W).trans
|
| 106 |
+
change _*(∑ i∈range s,(Nat.card K)^i)≤_
|
| 107 |
+
simp [ht]
|
| 108 |
+
have he : (r-1)+(s-1)=d-1 := by dsimp [r,s] at *; omega
|
| 109 |
+
calc
|
| 110 |
+
_ ≤ (∑ i∈range r,(Nat.card K)^i)*(∑ i∈range s,(Nat.card K)^i) := card_rectangle_le W
|
| 111 |
+
_ ≤ (2*(Nat.card K)^(r-1))*(2*(Nat.card K)^(s-1)) :=
|
| 112 |
+
Nat.mul_le_mul (sum_powers_le_two hq (Nat.pos_of_ne_zero hr))
|
| 113 |
+
(sum_powers_le_two hq (Nat.pos_of_ne_zero ht))
|
| 114 |
+
_ = _ := by rw [show (2*(Nat.card K)^(r-1))*(2*(Nat.card K)^(s-1))=
|
| 115 |
+
4*((Nat.card K)^(r-1)*(Nat.card K)^(s-1)) by ring,←pow_add,he]
|
| 116 |
+
|
| 117 |
+
lemma card_flags_lower {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) :
|
| 118 |
+
(Nat.card K)^(2*d-1)≤Nat.card (Flag K V) := by
|
| 119 |
+
rw [card_flags hdim]
|
| 120 |
+
have h1 : (Nat.card K)^d≤∑ i∈range (d+1),(Nat.card K)^i :=
|
| 121 |
+
single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega))
|
| 122 |
+
have h2 : (Nat.card K)^(d-1)≤∑ i∈range d,(Nat.card K)^i :=
|
| 123 |
+
single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega))
|
| 124 |
+
have he : 2*d-1=d+(d-1) := by omega
|
| 125 |
+
rw [he,pow_add]
|
| 126 |
+
exact Nat.mul_le_mul h1 h2
|
| 127 |
+
|
| 128 |
+
lemma finite_flags : Finite (Flag K V) := inferInstance
|
| 129 |
+
|
| 130 |
+
lemma finite_subspaces : Finite (Submodule K V) := inferInstance
|
| 131 |
+
|
| 132 |
+
end
|
| 133 |
+
end SharpLogRamsey.InitialRectangles
|
| 134 |
+
|
| 135 |
+
end
|
| 136 |
+
|
| 137 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/InitialTools.lean
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Marking.TrackedGeometry
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Construction.RectangleStreamEvent
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
namespace SharpLogRamsey
|
| 9 |
+
open Finset Real Selection Marking
|
| 10 |
+
open scoped Classical BigOperators
|
| 11 |
+
noncomputable section
|
| 12 |
+
|
| 13 |
+
namespace Selection
|
| 14 |
+
variable {α : Type} [Fintype α] [Nonempty α]
|
| 15 |
+
def uniformLaw : Law α where
|
| 16 |
+
mass _:=1/(Fintype.card α:ℝ)
|
| 17 |
+
nonneg _:=by positivity
|
| 18 |
+
total:=by simp [Fintype.card_ne_zero]
|
| 19 |
+
|
| 20 |
+
lemma uniformLaw_event (E : Finset α) : uniformLaw.event E=FiniteStreamTail.probability E:=by
|
| 21 |
+
simp only [Law.event,uniformLaw,sum_const,nsmul_eq_mul,FiniteStreamTail.probability]
|
| 22 |
+
ring
|
| 23 |
+
|
| 24 |
+
lemma uniformLaw_conditioned {E : Finset α} (hE : (1:ℝ)/2 ≤ FiniteStreamTail.probability E) :
|
| 25 |
+
∀ a,((uniformLaw.onEvent E (by rw [uniformLaw_event];linarith)).map (Subtype.val : E→α)).mass a ≤
|
| 26 |
+
2/(Fintype.card α:ℝ) := by
|
| 27 |
+
intro a
|
| 28 |
+
have hh:=uniformLaw.onEvent_map_le_two E (by rwa [uniformLaw_event]) id a
|
| 29 |
+
rw [Law.map_id] at hh
|
| 30 |
+
convert hh using 1 <;> simp [uniformLaw]
|
| 31 |
+
ring
|
| 32 |
+
end Selection
|
| 33 |
+
|
| 34 |
+
variable {K V : Type} [Field K] [AddCommGroup V] [Module K V]
|
| 35 |
+
[Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))]
|
| 36 |
+
|
| 37 |
+
lemma rectangle_pair_iff [Finite K] [FiniteDimensional K V] (W : Submodule K V) (f : Flag K V) :
|
| 38 |
+
(flagPair f).swap∈orthogonalRectangle Projectivization.rep Projectivization.rep W ↔
|
| 39 |
+
f∈RectangleStreamEvent.rectangle W := by
|
| 40 |
+
simp only [orthogonalRectangle,mem_filter,mem_univ,true_and,RectangleStreamEvent.rectangle,
|
| 41 |
+
InitialRectangles.IsRectangle,Projectivization.submodule_eq,Submodule.span_singleton_le_iff_mem]
|
| 42 |
+
rfl
|
| 43 |
+
|
| 44 |
+
def initial_context {Ω : Type} [Fintype Ω] {k : ℕ} (p : Law Ω)
|
| 45 |
+
(F : Ω→Fin k→Flag K V) (B : ℝ) (hB : (Fintype.card (Flag K V):ℝ) ≤ B) :
|
| 46 |
+
ContextOutput p (fun x j=>flagPair (F x j)) k B 0 1 where
|
| 47 |
+
X:={x // p.mass x≠0}
|
| 48 |
+
Γ:=Unit
|
| 49 |
+
finiteX:=inferInstance
|
| 50 |
+
finiteΓ:=inferInstance
|
| 51 |
+
μ:=p.nullFree
|
| 52 |
+
source:=Subtype.val
|
| 53 |
+
msg:=fun _=>()
|
| 54 |
+
chosen:=fun _=>OrderEmbedding.ofStrictMono id (fun _ _ h=>h)
|
| 55 |
+
domains:=fun _ _=>univ.map ⟨flagPair,flagPair_injective⟩
|
| 56 |
+
supported:=fun x=>x.property
|
| 57 |
+
hit:=fun x j=>mem_map.mpr ⟨F x.val j,mem_univ _,rfl⟩
|
| 58 |
+
size:=by intro _ _;simpa only [card_map,card_univ] using hB
|
| 59 |
+
dominated:=by
|
| 60 |
+
intro x
|
| 61 |
+
have hh:=p.nullFree_map id
|
| 62 |
+
rw [Law.map_id] at hh
|
| 63 |
+
have he : p.nullFree.map (Subtype.val : {x // p.mass x≠0}→Ω)=p:=by
|
| 64 |
+
convert hh using 1
|
| 65 |
+
congr!
|
| 66 |
+
rw [he,one_mul]
|
| 67 |
+
cost:=by
|
| 68 |
+
have hh:=entropy_le_log_card (p.nullFree.map (fun _=>())) univ (by simp)
|
| 69 |
+
simpa using hh
|
| 70 |
+
|
| 71 |
+
omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in
|
| 72 |
+
lemma independent_selected {N k : ℕ} (z : Fin N→Flag K V)
|
| 73 |
+
(h : k ≤ (flagGraph K V z).indepNum) :
|
| 74 |
+
∃ e : Fin k↪o Fin N,Consistent (fun j=>z (e j)) := by
|
| 75 |
+
obtain ⟨S,hS⟩:=(flagGraph K V z).exists_isNIndepSet_indepNum
|
| 76 |
+
obtain ⟨T,hTS,hTk⟩:=exists_subset_card_eq (s:=S) (n:=k) (by rwa [hS.card_eq])
|
| 77 |
+
let e:=T.orderEmbOfFin hTk
|
| 78 |
+
refine ⟨e,?_⟩
|
| 79 |
+
have hc : ConsistentOn z T:=(consistentOn_iff_compl_isClique _ _).mpr (by
|
| 80 |
+
rw [SimpleGraph.isClique_compl]
|
| 81 |
+
exact hS.isIndepSet.mono (by exact_mod_cast hTS))
|
| 82 |
+
intro a b hab hi
|
| 83 |
+
exact hc (e a) (T.orderEmbOfFin_mem hTk a) (e b) (T.orderEmbOfFin_mem hTk b) (e.strictMono hab) hi
|
| 84 |
+
|
| 85 |
+
omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in
|
| 86 |
+
lemma selected_reverse_consistent {N k : ℕ} (z : Fin N→Flag K V)
|
| 87 |
+
(e : Fin k↪o Fin N) (hc : Consistent (fun j=>z (e j))) :
|
| 88 |
+
ScanConsistent ((List.ofFn (fun j=>flagPair (z (e j.rev)))).map toScan) := by
|
| 89 |
+
have hh:=backwardScan_consistent (fun j=>z (e j)) hc
|
| 90 |
+
simpa only [backwardScan,List.map_ofFn,Function.comp_def,flagPair,toScan] using hh
|
| 91 |
+
end
|
| 92 |
+
end SharpLogRamsey
|
| 93 |
+
|
| 94 |
+
end
|
| 95 |
+
|
| 96 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/PrimeConstruction.lean
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Construction.GraphWitness
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Construction.SourceSizes
|
| 4 |
+
import OAI.Combinatorics.SharpRamsey.Bounds.Lower
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
namespace SharpLogRamsey.LowerTransfer
|
| 10 |
+
open Real Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
noncomputable section
|
| 13 |
+
|
| 14 |
+
theorem actual_prime_construction (i : ℕ) : PrimeConstruction (i+3) := by
|
| 15 |
+
intro η hη hηu
|
| 16 |
+
have hσ:=Marking.eventually_graph_witness i η hη (by linarith : η ≤ 1)
|
| 17 |
+
have ht : Tendsto (fun q : ℕ=>log (q:ℝ)) atTop atTop:=
|
| 18 |
+
tendsto_log_atTop.comp tendsto_natCast_atTop_atTop
|
| 19 |
+
filter_upwards [ht.eventually hσ,InitialExperiment.eventually_source_sizes i η hη.le]
|
| 20 |
+
with q hgraph hsize
|
| 21 |
+
intro hq
|
| 22 |
+
have : Fact q.Prime:=⟨hq⟩
|
| 23 |
+
have hq0 : (0:ℝ) < q:=by exact_mod_cast hq.pos
|
| 24 |
+
exact hgraph q hsize.1 (exp_log hq0) _ _ hsize.2.2.1 hsize.2.2.2.1
|
| 25 |
+
hsize.2.2.2.2.1 hsize.2.2.2.2.2.1 hsize.2.2.2.2.2.2
|
| 26 |
+
|
| 27 |
+
theorem prime_construction (d : ℕ) (hd : 5 ≤ d) : PrimeConstruction d := by
|
| 28 |
+
have he : d-3+3=d:=by omega
|
| 29 |
+
simpa only [he] using actual_prime_construction (d-3)
|
| 30 |
+
end
|
| 31 |
+
end SharpLogRamsey.LowerTransfer
|
| 32 |
+
|
| 33 |
+
end
|
| 34 |
+
|
| 35 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/RectangleStreamEvent.lean
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Construction.InitialRectangles
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Construction.FiniteStreamTail
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
namespace SharpLogRamsey.RectangleStreamEvent
|
| 9 |
+
open Finset Real InitialRectangles FiniteStreamTail
|
| 10 |
+
open scoped Classical BigOperators
|
| 11 |
+
noncomputable section
|
| 12 |
+
variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V]
|
| 13 |
+
[FiniteDimensional K V]
|
| 14 |
+
local instance flat_JoinedRectangleStreamEvent_1 : Fintype (Flag K V) := @Fintype.ofFinite _ (finite_flags (K:=K) (V:=V))
|
| 15 |
+
local instance flat_JoinedRectangleStreamEvent_2 : Fintype (Submodule K V) := @Fintype.ofFinite _ (finite_subspaces (K:=K) (V:=V))
|
| 16 |
+
|
| 17 |
+
def rectangle (W : Submodule K V) : Finset (Flag K V) :=
|
| 18 |
+
univ.filter (IsRectangle W)
|
| 19 |
+
|
| 20 |
+
lemma rectangle_card {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1)
|
| 21 |
+
(W : Submodule K V) : (rectangle W).card≤4*(Nat.card K)^(d-1) := by
|
| 22 |
+
convert card_rectangle_bound hd hdim W using 1
|
| 23 |
+
rw [Nat.card_eq_fintype_card,Fintype.card_subtype]
|
| 24 |
+
rfl
|
| 25 |
+
|
| 26 |
+
lemma flags_card_pos {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) :
|
| 27 |
+
0<Fintype.card (Flag K V) := by
|
| 28 |
+
have h := card_flags_lower hd hdim
|
| 29 |
+
rw [Nat.card_eq_fintype_card (α:=Flag K V)] at h
|
| 30 |
+
exact lt_of_lt_of_le (pow_pos (Nat.card_pos (α:=K)) _) h
|
| 31 |
+
|
| 32 |
+
lemma rectangle_probability {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1)
|
| 33 |
+
(W : Submodule K V) : probability (rectangle W)≤4/(Nat.card K:ℝ)^d := by
|
| 34 |
+
have hp : 0<(Nat.card K:ℝ) := by exact_mod_cast (show 0<Nat.card K from Nat.card_pos)
|
| 35 |
+
have hf : 0<(Fintype.card (Flag K V):ℝ) := by exact_mod_cast flags_card_pos hd hdim
|
| 36 |
+
have hc : ((rectangle W).card:ℝ)≤4*(Nat.card K:ℝ)^(d-1) := by
|
| 37 |
+
exact_mod_cast rectangle_card hd hdim W
|
| 38 |
+
have hb : (Nat.card K:ℝ)^(2*d-1)≤Fintype.card (Flag K V) := by
|
| 39 |
+
exact_mod_cast (show (Nat.card K)^(2*d-1)≤Fintype.card (Flag K V) by
|
| 40 |
+
simpa only [Nat.card_eq_fintype_card] using card_flags_lower hd hdim)
|
| 41 |
+
unfold probability
|
| 42 |
+
calc
|
| 43 |
+
_ ≤ (4*(Nat.card K:ℝ)^(d-1))/(Nat.card K:ℝ)^(2*d-1) :=
|
| 44 |
+
div_le_div₀ (by positivity) hc (by positivity) hb
|
| 45 |
+
_ = _ := by
|
| 46 |
+
have he : 2*d-1=d+(d-1) := by omega
|
| 47 |
+
rw [he,pow_add]
|
| 48 |
+
field_simp
|
| 49 |
+
|
| 50 |
+
lemma rectangle_mean {d N : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1)
|
| 51 |
+
(hN : (N:ℝ)≤(Nat.card K:ℝ)^d*log (Nat.card K)) (W : Submodule K V) :
|
| 52 |
+
(N:ℝ)*probability (rectangle W)≤4*log (Nat.card K) := by
|
| 53 |
+
have hp : 0<(Nat.card K:ℝ) := by exact_mod_cast (show 0<Nat.card K from Nat.card_pos)
|
| 54 |
+
calc
|
| 55 |
+
_ ≤ N*(4/(Nat.card K:ℝ)^d) :=
|
| 56 |
+
mul_le_mul_of_nonneg_left (rectangle_probability hd hdim W) (Nat.cast_nonneg _)
|
| 57 |
+
_ ≤ ((Nat.card K:ℝ)^d*log (Nat.card K))*(4/(Nat.card K:ℝ)^d) :=
|
| 58 |
+
mul_le_mul_of_nonneg_right hN (by positivity)
|
| 59 |
+
_ = _ := by field_simp
|
| 60 |
+
|
| 61 |
+
omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] in
|
| 62 |
+
lemma union_exponent (q : ℝ) (hq : 0<q) (n : ℕ) :
|
| 63 |
+
q^n*exp (4*log q-(((n:ℝ)+5)/log 2*log q)*log 2)=1/q := by
|
| 64 |
+
have hl : log (2:ℝ)≠0 := ne_of_gt (log_pos (by norm_num))
|
| 65 |
+
have he : 4*log q-(((n:ℝ)+5)/log 2*log q)*log 2=
|
| 66 |
+
-(n:ℝ)*log q-log q := by field_simp; ring
|
| 67 |
+
rw [he]
|
| 68 |
+
have hpow : q^n=exp ((n:ℝ)*log q) := by rw [exp_nat_mul,exp_log hq]
|
| 69 |
+
rw [hpow,←exp_add]
|
| 70 |
+
rw [show (n:ℝ)*log q+(-(n:ℝ)*log q-log q)= -log q by ring,
|
| 71 |
+
exp_neg,exp_log hq,one_div]
|
| 72 |
+
|
| 73 |
+
theorem simultaneous_rectangle_tail {d N : ℕ} (hd : 1≤d)
|
| 74 |
+
(hdim : Module.finrank K V=d+1)
|
| 75 |
+
(hN : (N:ℝ)≤(Nat.card K:ℝ)^d*log (Nat.card K)) :
|
| 76 |
+
probability (univ.filter (fun z : Fin N→Flag K V=>∃ W : Submodule K V,
|
| 77 |
+
(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z)) ≤
|
| 78 |
+
1/(Nat.card K:ℝ) := by
|
| 79 |
+
have hf := flags_card_pos hd hdim
|
| 80 |
+
let : Nonempty (Flag K V) := Fintype.card_pos_iff.mp hf
|
| 81 |
+
let t : ℝ := (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)
|
| 82 |
+
have hs := simultaneous_tail (rectangle (K:=K) (V:=V)) N t (4*log (Nat.card K))
|
| 83 |
+
(rectangle_mean hd hdim hN)
|
| 84 |
+
have hc : (Fintype.card (Submodule K V):ℝ)≤(Nat.card K:ℝ)^((d+1)^2) := by
|
| 85 |
+
have h := card_subspaces_le (K:=K) (V:=V)
|
| 86 |
+
rw [hdim,Nat.card_eq_fintype_card] at h
|
| 87 |
+
exact_mod_cast h
|
| 88 |
+
calc
|
| 89 |
+
_ ≤ (Fintype.card (Submodule K V):ℝ)*exp (4*log (Nat.card K)-t*log 2) := hs
|
| 90 |
+
_ ≤ (Nat.card K:ℝ)^((d+1)^2)*exp (4*log (Nat.card K)-t*log 2) :=
|
| 91 |
+
mul_le_mul_of_nonneg_right hc (le_of_lt (exp_pos _))
|
| 92 |
+
_ = _ := union_exponent _ (by exact_mod_cast (show 0<Nat.card K from Nat.card_pos)) _
|
| 93 |
+
|
| 94 |
+
theorem source_length_tail {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) :
|
| 95 |
+
probability (univ.filter (fun z : Fin ⌊(Nat.card K:ℝ)^d*log (Nat.card K)⌋₊→Flag K V=>
|
| 96 |
+
∃ W : Submodule K V,
|
| 97 |
+
(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z)) ≤
|
| 98 |
+
1/(Nat.card K:ℝ) := by
|
| 99 |
+
apply simultaneous_rectangle_tail hd hdim
|
| 100 |
+
apply Nat.floor_le
|
| 101 |
+
apply mul_nonneg (by positivity)
|
| 102 |
+
apply log_nonneg
|
| 103 |
+
exact_mod_cast (Nat.le_of_lt (Finite.one_lt_card (α:=K)))
|
| 104 |
+
|
| 105 |
+
omit [Finite K] in
|
| 106 |
+
|
| 107 |
+
lemma dual_rectangle (U : Submodule K (Module.Dual K V)) (f : Flag K V) :
|
| 108 |
+
IsRectangle U.dualCoannihilator f ↔
|
| 109 |
+
f.dualPoint.submodule≤U ∧ f.point.submodule≤U.dualCoannihilator := by
|
| 110 |
+
simp only [IsRectangle,Subspace.dualCoannihilator_dualAnnihilator_eq,and_comm]
|
| 111 |
+
|
| 112 |
+
lemma inherited_occupancy {N n : ℕ} (z : Fin N→Flag K V) (e : Fin n↪Fin N)
|
| 113 |
+
(M : ℝ) (h : ∀ W : Submodule K V,(hits (rectangle W) z:ℝ)<M) :
|
| 114 |
+
∀ W : Submodule K V,(hits (rectangle W) (z∘e):ℝ)<M := by
|
| 115 |
+
intro W
|
| 116 |
+
exact lt_of_le_of_lt (by exact_mod_cast hits_embedding (rectangle W) z e) (h W)
|
| 117 |
+
|
| 118 |
+
theorem simultaneous_good_probability {d N : ℕ} (hd : 1≤d)
|
| 119 |
+
(hdim : Module.finrank K V=d+1)
|
| 120 |
+
(hN : (N:ℝ)≤(Nat.card K:ℝ)^d*log (Nat.card K)) :
|
| 121 |
+
1-1/(Nat.card K:ℝ) ≤
|
| 122 |
+
probability (univ.filter (fun z : Fin N→Flag K V=>∀ W : Submodule K V,
|
| 123 |
+
(hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K))) := by
|
| 124 |
+
let : Nonempty (Flag K V) := Fintype.card_pos_iff.mp (flags_card_pos hd hdim)
|
| 125 |
+
let B := univ.filter (fun z : Fin N→Flag K V=>∃ W : Submodule K V,
|
| 126 |
+
(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z)
|
| 127 |
+
have he : Bᶜ=univ.filter (fun z : Fin N→Flag K V=>∀ W : Submodule K V,
|
| 128 |
+
(hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)) := by
|
| 129 |
+
ext z
|
| 130 |
+
simp only [B,mem_compl,mem_filter,mem_univ,true_and,not_exists,not_le]
|
| 131 |
+
rw [←he]
|
| 132 |
+
have hc : probability Bᶜ=1-probability B := by
|
| 133 |
+
convert probability_compl B using 1
|
| 134 |
+
congr 1
|
| 135 |
+
ext z
|
| 136 |
+
simp
|
| 137 |
+
rw [hc]
|
| 138 |
+
exact sub_le_sub_left (simultaneous_rectangle_tail hd hdim hN) 1
|
| 139 |
+
|
| 140 |
+
theorem source_good_probability {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) :
|
| 141 |
+
(1:ℝ)/2 ≤
|
| 142 |
+
probability (univ.filter (fun z : Fin ⌊(Nat.card K:ℝ)^d*log (Nat.card K)⌋₊→Flag K V=>
|
| 143 |
+
∀ W : Submodule K V,
|
| 144 |
+
(hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K))) := by
|
| 145 |
+
have hq : 2≤(Nat.card K:ℝ) := by exact_mod_cast (Finite.one_lt_card (α:=K))
|
| 146 |
+
have hp : 0<(Nat.card K:ℝ) := by linarith
|
| 147 |
+
have hh : 1/(Nat.card K:ℝ)≤1/2 := (div_le_iff₀ hp).mpr (by linarith)
|
| 148 |
+
apply (show (1:ℝ)/2≤1-1/(Nat.card K:ℝ) by linarith).trans
|
| 149 |
+
apply simultaneous_good_probability hd hdim
|
| 150 |
+
exact Nat.floor_le (mul_nonneg (by positivity) (log_nonneg (by linarith)))
|
| 151 |
+
|
| 152 |
+
end
|
| 153 |
+
end SharpLogRamsey.RectangleStreamEvent
|
| 154 |
+
|
| 155 |
+
end
|
| 156 |
+
|
| 157 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Construction/SourceSizes.lean
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
section
|
| 6 |
+
namespace SharpLogRamsey.InitialExperiment
|
| 7 |
+
open Real Filter
|
| 8 |
+
open scoped Topology
|
| 9 |
+
noncomputable section
|
| 10 |
+
|
| 11 |
+
lemma eventually_source_sizes (i : ℕ) (η : ℝ) (hη : 0 ≤ η) :
|
| 12 |
+
∀ᶠ q : ℕ in atTop,
|
| 13 |
+
3 ≤ q ∧ 1 ≤ log (q:ℝ) ∧
|
| 14 |
+
0 < ⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊ ∧
|
| 15 |
+
⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊ ≤ ⌊(q:ℝ)^(i+3)*log (q:ℝ)⌋₊ ∧
|
| 16 |
+
(⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ) ≤ (q:ℝ)*(log (q:ℝ))^(1+η) ∧
|
| 17 |
+
((q:ℝ)*(log (q:ℝ))^(1+η))/2 ≤ (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ) ∧
|
| 18 |
+
(⌊(q:ℝ)^(i+3)*log (q:ℝ)⌋₊:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ) := by
|
| 19 |
+
have hsmall := (isLittleO_log_rpow_rpow_atTop η (by norm_num : (0:ℝ)<1)).bound (by norm_num : (0:ℝ)<1)
|
| 20 |
+
filter_upwards [tendsto_natCast_atTop_atTop.eventually hsmall,
|
| 21 |
+
(tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually_ge_atTop 1,
|
| 22 |
+
eventually_ge_atTop (3:ℕ)] with q hsmall hl hq
|
| 23 |
+
change 1 ≤ log (q:ℝ) at hl
|
| 24 |
+
have hq1 : (1:ℝ) ≤ q:=by exact_mod_cast (show 1 ≤ q by omega)
|
| 25 |
+
have hq2 : (2:ℝ) ≤ q:=by exact_mod_cast (show 2 ≤ q by omega)
|
| 26 |
+
have hq0 : (0:ℝ) < q:=by linarith
|
| 27 |
+
have hl0 : 0 < log (q:ℝ):=by linarith
|
| 28 |
+
simp only [Real.norm_eq_abs,abs_of_pos (rpow_pos_of_pos hl0 _),
|
| 29 |
+
rpow_one,abs_of_pos hq0,one_mul] at hsmall
|
| 30 |
+
have hpow : 1 ≤ (log (q:ℝ))^(1+η):=one_le_rpow hl (by linarith)
|
| 31 |
+
have hQ : 2 ≤ (q:ℝ)*(log (q:ℝ))^(1+η):=by nlinarith only [hpow,hq2]
|
| 32 |
+
have hf : (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ)+1 > (q:ℝ)*(log (q:ℝ))^(1+η):=Nat.lt_floor_add_one _
|
| 33 |
+
have hlower : ((q:ℝ)*(log (q:ℝ))^(1+η))/2 ≤ (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ):=by linarith
|
| 34 |
+
refine ⟨hq,hl,?_,?_,Nat.floor_le (by positivity),hlower,Nat.floor_le (by positivity)⟩
|
| 35 |
+
· exact (Nat.one_le_floor_iff _).mpr (by linarith)
|
| 36 |
+
· apply Nat.floor_mono
|
| 37 |
+
calc
|
| 38 |
+
_ = (q:ℝ)*log (q:ℝ)*(log (q:ℝ))^η:=by rw [rpow_add hl0,rpow_one];ring
|
| 39 |
+
_ ≤ (q:ℝ)*log (q:ℝ)*(q:ℝ):=mul_le_mul_of_nonneg_left hsmall (by positivity)
|
| 40 |
+
_ = (q:ℝ)^2*log (q:ℝ):=by ring
|
| 41 |
+
_ ≤ _:=mul_le_mul_of_nonneg_right (pow_le_pow_right₀ hq1 (by omega : 2 ≤ i+3)) hl0.le
|
| 42 |
+
end
|
| 43 |
+
end SharpLogRamsey.InitialExperiment
|
| 44 |
+
|
| 45 |
+
end
|
| 46 |
+
|
| 47 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/AnchorEventsRealized.lean
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.WitnessList
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
open MeasureTheory ProbabilityTheory
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
open MeasureTheory ProbabilityTheory
|
| 15 |
+
open scoped BigOperators ENNReal NNReal
|
| 16 |
+
namespace SharpRamseyFive.ResidualCertificate
|
| 17 |
+
variable {V : Type*} [Fintype V] [DecidableEq V]
|
| 18 |
+
section SharedHitGeometry
|
| 19 |
+
open scoped Classical
|
| 20 |
+
variable {D B : Type*} [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B]
|
| 21 |
+
omit [Fintype D] [Fintype B] in
|
| 22 |
+
lemma anchorEvents_realized (hit : B → D → Prop) (C : Finset (B × D))
|
| 23 |
+
(A : Finset D) (r : A → B) (h : ∀ d : A, hit (r d) d.val) :
|
| 24 |
+
Realized hit (anchorEvents C A r) := by
|
| 25 |
+
intro p hp
|
| 26 |
+
obtain ⟨d, _, rfl⟩ := Finset.mem_image.mp hp
|
| 27 |
+
exact h d
|
| 28 |
+
|
| 29 |
+
omit [Fintype V] [Fintype D] in
|
| 30 |
+
|
| 31 |
+
theorem anchor_step_witnesses (s : V → Finset D) (hit : B → D → Prop)
|
| 32 |
+
(E : Finset V) (C : Finset (B × D)) (v : V) (a : ℕ)
|
| 33 |
+
(hC : DictionaryInvariant s E C) (hreal : Realized hit C)
|
| 34 |
+
(ha : a ≤ (touchedToEncoded s hit E v).card) :
|
| 35 |
+
∃ (A : Finset D) (r : A → B), A.card = a ∧
|
| 36 |
+
A ⊆ s v ∧ A ⊆ encodedDirections s E ∧
|
| 37 |
+
(∀ d : A, hit (r d) d.val) ∧
|
| 38 |
+
Disjoint C (anchorEvents C A r) ∧
|
| 39 |
+
Realized hit (C ∪ anchorEvents C A r) ∧
|
| 40 |
+
DictionaryInvariant s (insert v E) (C ∪ anchorEvents C A r) ∧
|
| 41 |
+
(C ∪ anchorEvents C A r).card ≤ C.card + a := by
|
| 42 |
+
classical
|
| 43 |
+
obtain ⟨A, hA, hAc⟩ := Finset.exists_subset_card_eq ha
|
| 44 |
+
have hh (d : A) : ∃ r, hit r d.val := (Finset.mem_filter.mp (hA d.property)).2
|
| 45 |
+
choose r hr using hh
|
| 46 |
+
have hAs : A ⊆ s v := fun d hd => (Finset.mem_inter.mp
|
| 47 |
+
(Finset.mem_filter.mp (hA hd)).1).1
|
| 48 |
+
have hAE : A ⊆ encodedDirections s E := fun d hd => (Finset.mem_inter.mp
|
| 49 |
+
(Finset.mem_filter.mp (hA hd)).1).2
|
| 50 |
+
refine ⟨A, r, hAc, hAs, hAE, hr, anchorEvents_fresh C A r,
|
| 51 |
+
realized_union hit hreal (anchorEvents_realized hit C A r hr), ?_, ?_⟩
|
| 52 |
+
· unfold DictionaryInvariant
|
| 53 |
+
rw [paidDirections_union]
|
| 54 |
+
apply Finset.union_subset
|
| 55 |
+
· exact hC.trans (encodedDirections_mono s (Finset.subset_insert _ _))
|
| 56 |
+
· exact (anchorEvents_directions C A r).trans
|
| 57 |
+
(hAE.trans (encodedDirections_mono s (Finset.subset_insert _ _)))
|
| 58 |
+
· exact (Finset.card_union_le _ _).trans (Nat.add_le_add_left
|
| 59 |
+
((anchorEvents_card C A r).trans_eq hAc) _)
|
| 60 |
+
|
| 61 |
+
noncomputable def pairEvents (T : Finset B) (d : T → D) : Finset (B × D) :=
|
| 62 |
+
T.attach.image (fun r => (r.val, d r))
|
| 63 |
+
|
| 64 |
+
omit [Fintype D] [Fintype B] in
|
| 65 |
+
lemma pairEvents_card (T : Finset B) (d : T → D) :
|
| 66 |
+
(pairEvents T d).card = T.card := by
|
| 67 |
+
rw [pairEvents, Finset.card_image_of_injective]
|
| 68 |
+
· exact Finset.card_attach
|
| 69 |
+
· intro r r' he
|
| 70 |
+
exact Subtype.ext (congrArg Prod.fst he)
|
| 71 |
+
|
| 72 |
+
omit [Fintype D] [Fintype B] in
|
| 73 |
+
lemma pairEvents_realized (hit : B → D → Prop) (T : Finset B) (d : T → D)
|
| 74 |
+
(h : ∀ r : T, hit r.val (d r)) : Realized hit (pairEvents T d) := by
|
| 75 |
+
intro p hp
|
| 76 |
+
obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp
|
| 77 |
+
exact h r
|
| 78 |
+
|
| 79 |
+
omit [Fintype V] [Fintype D] in
|
| 80 |
+
|
| 81 |
+
theorem pair_step_witnesses (s : V → Finset D) (hit : B → D → Prop)
|
| 82 |
+
(E : Finset V) (C : Finset (B × D)) (v u : V) (K : ℕ)
|
| 83 |
+
(hC : DictionaryInvariant s E C) (hreal : Realized hit C)
|
| 84 |
+
(hp : K ≤ (sharedBatches (outsideDirections s E) hit v u).card) :
|
| 85 |
+
∃ (T : Finset B) (d : T → D), T.card = K ∧
|
| 86 |
+
(∀ r : T, d r ∈ s v ∩ s u ∧ d r ∉ encodedDirections s E ∧ hit r.val (d r)) ∧
|
| 87 |
+
Disjoint C (pairEvents T d) ∧ Realized hit (C ∪ pairEvents T d) ∧
|
| 88 |
+
DictionaryInvariant s (insert v (insert u E)) (C ∪ pairEvents T d) ∧
|
| 89 |
+
(C ∪ pairEvents T d).card = C.card + K := by
|
| 90 |
+
classical
|
| 91 |
+
obtain ⟨T, hT, hTc⟩ := Finset.exists_subset_card_eq hp
|
| 92 |
+
have hh (r : T) : ∃ d, d ∈ s v ∩ s u ∧ d ∉ encodedDirections s E ∧ hit r.val d := by
|
| 93 |
+
obtain ⟨d, hd, hr⟩ := (Finset.mem_filter.mp (hT r.property)).2
|
| 94 |
+
obtain ⟨hdv, hdu⟩ := Finset.mem_inter.mp hd
|
| 95 |
+
exact ⟨d, Finset.mem_inter.mpr ⟨(Finset.mem_sdiff.mp hdv).1,
|
| 96 |
+
(Finset.mem_sdiff.mp hdu).1⟩, (Finset.mem_sdiff.mp hdv).2, hr⟩
|
| 97 |
+
choose d hd using hh
|
| 98 |
+
have hfresh : Disjoint C (pairEvents T d) := by
|
| 99 |
+
apply Finset.disjoint_left.mpr
|
| 100 |
+
intro p hp he
|
| 101 |
+
obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp he
|
| 102 |
+
exact (hd r).2.1 (hC (Finset.mem_image_of_mem Prod.snd hp))
|
| 103 |
+
refine ⟨T, d, hTc, hd, hfresh,
|
| 104 |
+
realized_union hit hreal (pairEvents_realized hit T d (fun r => (hd r).2.2)), ?_, ?_⟩
|
| 105 |
+
· unfold DictionaryInvariant
|
| 106 |
+
rw [paidDirections_union]
|
| 107 |
+
apply Finset.union_subset
|
| 108 |
+
· exact hC.trans (encodedDirections_mono s ((Finset.subset_insert _ _).trans
|
| 109 |
+
(Finset.subset_insert _ _)))
|
| 110 |
+
· intro z hz
|
| 111 |
+
obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz
|
| 112 |
+
obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp
|
| 113 |
+
exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _,
|
| 114 |
+
(Finset.mem_inter.mp (hd r).1).1⟩
|
| 115 |
+
· rw [Finset.card_union_of_disjoint hfresh, pairEvents_card, hTc]
|
| 116 |
+
|
| 117 |
+
inductive PaidStep (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) :
|
| 118 |
+
(Finset V × Finset (B × D)) → (Finset V × Finset (B × D)) → Prop
|
| 119 |
+
| anchor (E : Finset V) (C : Finset (B × D)) (v : V) (hv : v ∉ E)
|
| 120 |
+
(A : Finset D) (hA : A.card = a) (hAs : A ⊆ s v)
|
| 121 |
+
(hAE : A ⊆ encodedDirections s E) (r : A → B) (hr : ∀ d : A, hit (r d) d.val) :
|
| 122 |
+
PaidStep s hit a K (E, C) (insert v E, C ∪ anchorEvents C A r)
|
| 123 |
+
| pair (E : Finset V) (C : Finset (B × D)) (v u : V)
|
| 124 |
+
(hv : v ∉ E) (hu : u ∉ E) (hne : v ≠ u)
|
| 125 |
+
(T : Finset B) (hT : T.card = K) (d : T → D)
|
| 126 |
+
(hd : ∀ r : T, d r ∈ s v ∩ s u ∧ d r ∉ encodedDirections s E ∧ hit r.val (d r)) :
|
| 127 |
+
PaidStep s hit a K (E, C) (insert v (insert u E), C ∪ pairEvents T d)
|
| 128 |
+
|
| 129 |
+
omit [Fintype V] in
|
| 130 |
+
omit [Fintype D] [Fintype B] in
|
| 131 |
+
lemma paidStep_realized (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ)
|
| 132 |
+
{Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z')
|
| 133 |
+
(hreal : Realized hit Z.2) : Realized hit Z'.2 := by
|
| 134 |
+
cases h with
|
| 135 |
+
| anchor E C v hv A hA hAs hAE r hr =>
|
| 136 |
+
exact realized_union hit hreal (anchorEvents_realized hit C A r hr)
|
| 137 |
+
| pair E C v u hv hu hne T hT d hd =>
|
| 138 |
+
exact realized_union hit hreal (pairEvents_realized hit T d (fun r => (hd r).2.2))
|
| 139 |
+
omit [Fintype V] [Fintype D] [Fintype B] in
|
| 140 |
+
|
| 141 |
+
lemma paidStep_dictionary (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ)
|
| 142 |
+
{Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z')
|
| 143 |
+
(hC : DictionaryInvariant s Z.1 Z.2) : DictionaryInvariant s Z'.1 Z'.2 := by
|
| 144 |
+
cases h with
|
| 145 |
+
| anchor E C v hv A hA hAs hAE r hr =>
|
| 146 |
+
unfold DictionaryInvariant
|
| 147 |
+
rw [paidDirections_union]
|
| 148 |
+
exact Finset.union_subset
|
| 149 |
+
(hC.trans (encodedDirections_mono s (Finset.subset_insert _ _)))
|
| 150 |
+
((anchorEvents_directions C A r).trans
|
| 151 |
+
(hAE.trans (encodedDirections_mono s (Finset.subset_insert _ _))))
|
| 152 |
+
| pair E C v u hv hu hne T hT d hd =>
|
| 153 |
+
unfold DictionaryInvariant
|
| 154 |
+
rw [paidDirections_union]
|
| 155 |
+
refine Finset.union_subset
|
| 156 |
+
(hC.trans (encodedDirections_mono s ((Finset.subset_insert _ _).trans
|
| 157 |
+
(Finset.subset_insert _ _)))) ?_
|
| 158 |
+
intro z hz
|
| 159 |
+
obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz
|
| 160 |
+
obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp
|
| 161 |
+
exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _,
|
| 162 |
+
(Finset.mem_inter.mp (hd r).1).1⟩
|
| 163 |
+
|
| 164 |
+
omit [Fintype V] in
|
| 165 |
+
omit [Fintype D] [Fintype B] in
|
| 166 |
+
lemma paidStep_cost (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) (haK : a ≤ K)
|
| 167 |
+
{Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z') :
|
| 168 |
+
Z'.2.card + K * Z.1.card ≤ Z.2.card + K * Z'.1.card := by
|
| 169 |
+
cases h with
|
| 170 |
+
| anchor E C v hv A hA hAs hAE r hr =>
|
| 171 |
+
simp only [Finset.card_insert_of_notMem hv, Nat.mul_add, Nat.mul_one]
|
| 172 |
+
have hc := (Finset.card_union_le C (anchorEvents C A r)).trans
|
| 173 |
+
(Nat.add_le_add_left ((anchorEvents_card C A r).trans_eq hA) C.card)
|
| 174 |
+
omega
|
| 175 |
+
| pair E C v u hv hu hne T hT d hd =>
|
| 176 |
+
have hv' : v ∉ insert u E := by simp [hne, hv]
|
| 177 |
+
simp only [Finset.card_insert_of_notMem hv', Finset.card_insert_of_notMem hu,
|
| 178 |
+
Nat.mul_add, Nat.mul_one]
|
| 179 |
+
have hc := Finset.card_union_le C (pairEvents T d)
|
| 180 |
+
rw [pairEvents_card, hT] at hc
|
| 181 |
+
omega
|
| 182 |
+
|
| 183 |
+
omit [Fintype V] [Fintype D] in
|
| 184 |
+
|
| 185 |
+
lemma encodingStep_lift (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ)
|
| 186 |
+
{E F : Finset V} (h : EncodingStep s hit a K E F)
|
| 187 |
+
(C : Finset (B × D)) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) :
|
| 188 |
+
∃ C', PaidStep s hit a K (E, C) (F, C') ∧
|
| 189 |
+
DictionaryInvariant s F C' ∧ Realized hit C' := by
|
| 190 |
+
cases h with
|
| 191 |
+
| anchor v hv ha =>
|
| 192 |
+
obtain ⟨A, r, hAc, hAs, hAE, hr, _, hh, hdict, _⟩ :=
|
| 193 |
+
anchor_step_witnesses s hit E C v a hC hreal ha
|
| 194 |
+
exact ⟨_, .anchor E C v hv A hAc hAs hAE r hr, hdict, hh⟩
|
| 195 |
+
| pair v u hv hu hne hp =>
|
| 196 |
+
obtain ⟨T, d, hTc, hd, _, hh, hdict, _⟩ :=
|
| 197 |
+
pair_step_witnesses s hit E C v u K hC hreal hp
|
| 198 |
+
exact ⟨_, .pair E C v u hv hu hne T hTc d hd, hdict, hh⟩
|
| 199 |
+
omit [Fintype V] [Fintype D] in
|
| 200 |
+
|
| 201 |
+
lemma encoding_path_lift (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ)
|
| 202 |
+
{E F : Finset V} (h : Relation.ReflTransGen (EncodingStep s hit a K) E F)
|
| 203 |
+
(C : Finset (B × D)) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) :
|
| 204 |
+
∃ C', Relation.ReflTransGen (PaidStep s hit a K) (E, C) (F, C') ∧
|
| 205 |
+
DictionaryInvariant s F C' ∧ Realized hit C' := by
|
| 206 |
+
induction h with
|
| 207 |
+
| refl => exact ⟨C, .refl, hC, hreal⟩
|
| 208 |
+
| @tail F G h hFG ih =>
|
| 209 |
+
obtain ⟨C', hpath, hc', hr'⟩ := ih
|
| 210 |
+
obtain ⟨C'', hstep, hc'', hr''⟩ := encodingStep_lift s hit a K hFG C' hc' hr'
|
| 211 |
+
exact ⟨C'', hpath.tail hstep, hc'', hr''⟩
|
| 212 |
+
|
| 213 |
+
omit [Fintype V] in
|
| 214 |
+
omit [Fintype D] [Fintype B] in
|
| 215 |
+
|
| 216 |
+
lemma paid_path_cost (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) (haK : a ≤ K)
|
| 217 |
+
{Z Z' : Finset V × Finset (B × D)}
|
| 218 |
+
(h : Relation.ReflTransGen (PaidStep s hit a K) Z Z') :
|
| 219 |
+
Z'.2.card + K * Z.1.card ≤ Z.2.card + K * Z'.1.card := by
|
| 220 |
+
induction h with
|
| 221 |
+
| refl => omega
|
| 222 |
+
| @tail F G h hFG ih =>
|
| 223 |
+
have hc := paidStep_cost s hit a K haK hFG
|
| 224 |
+
omega
|
| 225 |
+
|
| 226 |
+
omit [Fintype D] in
|
| 227 |
+
|
| 228 |
+
theorem terminal_paid_certificate (s : V → Finset D) (hit : B → D → Prop)
|
| 229 |
+
(a K : ℕ) (haK : a ≤ K) (E : Finset V) :
|
| 230 |
+
∃ F C, Relation.ReflTransGen (PaidStep s hit a K) (E, ∅) (F, C) ∧
|
| 231 |
+
DictionaryInvariant s F C ∧ Realized hit C ∧
|
| 232 |
+
C.card ≤ K * Fintype.card V ∧ (paidDirections C).card ≤ K * Fintype.card V ∧
|
| 233 |
+
(∀ v ∉ F, (touchedToEncoded s hit F v).card < a) ∧
|
| 234 |
+
∀ v ∉ F, ∀ u ∉ F, v ≠ u →
|
| 235 |
+
(sharedBatches (outsideDirections s F) hit v u).card < K := by
|
| 236 |
+
classical
|
| 237 |
+
obtain ⟨F, hF, ha, hp⟩ := exists_terminal_encoding s hit a K E
|
| 238 |
+
have hc : DictionaryInvariant s E (∅ : Finset (B × D)) := by
|
| 239 |
+
simp [DictionaryInvariant, paidDirections]
|
| 240 |
+
have hr : Realized hit (∅ : Finset (B × D)) := by simp [Realized]
|
| 241 |
+
obtain ⟨C, hpath, hC, hreal⟩ := encoding_path_lift s hit a K hF ∅ hc hr
|
| 242 |
+
have hcost := paid_path_cost s hit a K haK hpath
|
| 243 |
+
simp only [Finset.card_empty, zero_add] at hcost
|
| 244 |
+
have hbound : C.card ≤ K * Fintype.card V := by
|
| 245 |
+
have hcard := Nat.mul_le_mul_left K (Finset.card_le_univ F)
|
| 246 |
+
omega
|
| 247 |
+
exact ⟨F, C, hpath, hC, hreal, hbound,
|
| 248 |
+
Finset.card_image_le.trans hbound, ha, hp⟩
|
| 249 |
+
|
| 250 |
+
end SharedHitGeometry
|
| 251 |
+
|
| 252 |
+
end SharpRamseyFive.ResidualCertificate
|
| 253 |
+
|
| 254 |
+
namespace SharpRamseyFive.CertificateCover
|
| 255 |
+
open SharpRamseyFive.StaticCertificates
|
| 256 |
+
open SharpRamseyFive.CertificateEnumeration
|
| 257 |
+
open SharpRamseyFive.WeightedPrograms
|
| 258 |
+
open SharpRamseyFive.ResidualCertificate
|
| 259 |
+
open scoped BigOperators
|
| 260 |
+
|
| 261 |
+
variable {V H D B : Type*} [Fintype V] [DecidableEq V]
|
| 262 |
+
[Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D]
|
| 263 |
+
[Fintype B] [DecidableEq B]
|
| 264 |
+
variable (lines : H → Finset D)
|
| 265 |
+
|
| 266 |
+
def Agrees (f : V → H) (E : Finset V) (s : State V H D B) : Prop :=
|
| 267 |
+
∀ v ∈ E, s.1 v = f v
|
| 268 |
+
|
| 269 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B] in
|
| 270 |
+
lemma agrees_update (f : V → H) (E : Finset V) (s : State V H D B)
|
| 271 |
+
(hs : Agrees f E s) (v : V) (C : Finset (B × D)) :
|
| 272 |
+
Agrees f (insert v E) (Function.update s.1 v (f v), C) := by
|
| 273 |
+
intro u hu
|
| 274 |
+
rcases Finset.mem_insert.mp hu with rfl | hu
|
| 275 |
+
· simp
|
| 276 |
+
· by_cases he : u = v
|
| 277 |
+
· subst u; simp
|
| 278 |
+
· simpa [Function.update_of_ne he] using hs u hu
|
| 279 |
+
|
| 280 |
+
noncomputable def anchorName (C : Finset (B × D)) (S : Finset D)
|
| 281 |
+
(d : D) (hd : d ∈ S) (r : B) : AnchorChoice C S :=
|
| 282 |
+
if he : d ∈ dictionary C then .inl ⟨d, Finset.mem_inter.mpr ⟨hd, he⟩⟩
|
| 283 |
+
else .inr (r, ⟨d, Finset.mem_sdiff.mpr ⟨hd, he⟩⟩)
|
| 284 |
+
|
| 285 |
+
omit [Fintype D] [Fintype B] [DecidableEq B] in
|
| 286 |
+
lemma anchorName_direction (C : Finset (B × D)) (S : Finset D)
|
| 287 |
+
(d : D) (hd : d ∈ S) (r : B) : (anchorName C S d hd r).direction = d := by
|
| 288 |
+
unfold anchorName
|
| 289 |
+
split_ifs <;> rfl
|
| 290 |
+
|
| 291 |
+
omit [Fintype D] [Fintype B] [DecidableEq B] in
|
| 292 |
+
lemma anchorName_realized (hit : B → D → Prop) (C : Finset (B × D))
|
| 293 |
+
(S : Finset D) (d : D) (hd : d ∈ S) (r : B) (hr : hit r d) :
|
| 294 |
+
Realized hit (anchorName C S d hd r).requirements := by
|
| 295 |
+
unfold anchorName
|
| 296 |
+
split_ifs <;> simp_all [AnchorChoice.requirements, Realized]
|
| 297 |
+
|
| 298 |
+
omit [Fintype D] [Fintype B] [DecidableEq B] in
|
| 299 |
+
lemma anchor_req_card {C : Finset (B × D)} {S : Finset D} (a : AnchorChoice C S) :
|
| 300 |
+
a.requirements.card ≤ 1 := by
|
| 301 |
+
cases a <;> simp [AnchorChoice.requirements]
|
| 302 |
+
|
| 303 |
+
omit [Fintype D] [Fintype B] [DecidableEq B] in
|
| 304 |
+
lemma anchor_req_directions {C : Finset (B × D)} {S : Finset D}
|
| 305 |
+
(a : AnchorChoice C S) : paidDirections a.requirements ⊆ {a.direction} := by
|
| 306 |
+
cases a <;> simp [AnchorChoice.requirements, AnchorChoice.direction, paidDirections]
|
| 307 |
+
omit [Fintype D] [Fintype B] [DecidableEq B] in
|
| 308 |
+
|
| 309 |
+
lemma anchor_req_disjoint {C : Finset (B × D)} {S T : Finset D}
|
| 310 |
+
(a : AnchorChoice C S) (b : AnchorChoice C T) (hne : a.direction ≠ b.direction) :
|
| 311 |
+
Disjoint a.requirements b.requirements := by
|
| 312 |
+
apply Finset.disjoint_left.mpr
|
| 313 |
+
intro p ha hb
|
| 314 |
+
have ha' := anchor_req_directions a (Finset.mem_image_of_mem Prod.snd ha)
|
| 315 |
+
have hb' := anchor_req_directions b (Finset.mem_image_of_mem Prod.snd hb)
|
| 316 |
+
exact hne ((Finset.mem_singleton.mp ha').symm.trans (Finset.mem_singleton.mp hb'))
|
| 317 |
+
|
| 318 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 319 |
+
omit [Fintype D] in
|
| 320 |
+
lemma rawCost_eq_weight (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool)
|
| 321 |
+
(s : State V H D B) (a : Action lines K s)
|
| 322 |
+
(henabled : ∀ c : OneChoice lines s, a = .inr (.inl c) → low = true) :
|
| 323 |
+
rawCost lines rate denom K low s a =
|
| 324 |
+
weight (fun p : B × D => rate p.2) (newEvents lines K s a) /
|
| 325 |
+
denom ^ degree lines K s a := by
|
| 326 |
+
rcases a with a | a
|
| 327 |
+
· simp [rawCost, newEvents, degree, weight]
|
| 328 |
+
rcases a with a | a
|
| 329 |
+
· rw [henabled a rfl]
|
| 330 |
+
simp [rawCost, newEvents, degree, oneCost, AnchorChoice.weight]
|
| 331 |
+
rcases a with a | a
|
| 332 |
+
· simp only [rawCost, newEvents, degree, twoCost, pow_one]
|
| 333 |
+
rw [weight_union_fresh _ _ _ (anchor_req_disjoint _ _ a.2.2.2.2.2.property.1),
|
| 334 |
+
AnchorChoice.weight, AnchorChoice.weight]
|
| 335 |
+
· rfl
|
| 336 |
+
|
| 337 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 338 |
+
omit [Fintype D] in
|
| 339 |
+
lemma newEvents_card (K : ℕ) (hK : 2 ≤ K) (s : State V H D B) (a : Action lines K s) :
|
| 340 |
+
(newEvents lines K s a).card ≤ K * degree lines K s a := by
|
| 341 |
+
rcases a with a | a
|
| 342 |
+
· simp [newEvents, degree]
|
| 343 |
+
rcases a with a | a
|
| 344 |
+
· simpa [newEvents, degree] using (anchor_req_card a.2.2.1).trans (by omega : 1 ≤ K)
|
| 345 |
+
rcases a with a | a
|
| 346 |
+
· change (a.2.2.2.1.requirements ∪ a.2.2.2.2.1.requirements).card ≤ K * 1
|
| 347 |
+
have hc := Finset.card_union_le a.2.2.2.1.requirements a.2.2.2.2.1.requirements
|
| 348 |
+
have h1 := anchor_req_card a.2.2.2.1
|
| 349 |
+
have h2 := anchor_req_card a.2.2.2.2.1
|
| 350 |
+
omega
|
| 351 |
+
· simp only [newEvents, degree, witnessRequirements_card]
|
| 352 |
+
have ht := (Finset.mem_powersetCard.mp a.2.2.2.2.1.property).2
|
| 353 |
+
omega
|
| 354 |
+
|
| 355 |
+
def Enabled (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : Prop :=
|
| 356 |
+
∀ c : OneChoice lines s, a = .inr (.inl c) → low = true
|
| 357 |
+
|
| 358 |
+
omit [Fintype H] [DecidableEq H] in
|
| 359 |
+
omit [Fintype D] in
|
| 360 |
+
|
| 361 |
+
lemma step_weight (rate : D → ℝ≥0) (denom : ℝ) (hdenom : denom ≠ 0)
|
| 362 |
+
(K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s)
|
| 363 |
+
(he : Enabled lines K low s a) (hs : s.2.card ≤ K * Fintype.card V) :
|
| 364 |
+
weight (fun p : B × D => rate p.2) (advance lines K s a).2 =
|
| 365 |
+
weight (fun p : B × D => rate p.2) s.2 *
|
| 366 |
+
programCost lines rate denom K low s a * denom ^ degree lines K s a := by
|
| 367 |
+
rw [programCost, ite_eq_left hs, rawCost_eq_weight lines rate denom K low s a he]
|
| 368 |
+
rw [advance, weight_union_fresh _ _ _ (newEvents_fresh lines K s a)]
|
| 369 |
+
field_simp
|
| 370 |
+
|
| 371 |
+
def Coherent (f : V → H) (hit : B → D → Prop) (K : ℕ)
|
| 372 |
+
(E : Finset V) (s : State V H D B) : Prop :=
|
| 373 |
+
Agrees f E s ∧ DictionaryInvariant (fun v => lines (f v)) E s.2 ∧
|
| 374 |
+
Realized hit s.2 ∧ s.2.card ≤ K * E.card
|
| 375 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 376 |
+
omit [Fintype D] in
|
| 377 |
+
|
| 378 |
+
lemma coherent_step (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K)
|
| 379 |
+
(E F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s)
|
| 380 |
+
(a : Action lines K s) (hEF : E ⊆ F)
|
| 381 |
+
(hag : Agrees f F (advance lines K s a))
|
| 382 |
+
(hdict : paidDirections (newEvents lines K s a) ⊆ encodedDirections (fun v => lines (f v)) F)
|
| 383 |
+
(hreal : Realized hit (newEvents lines K s a))
|
| 384 |
+
(hcard : F.card = E.card + degree lines K s a) :
|
| 385 |
+
Coherent lines f hit K F (advance lines K s a) := by
|
| 386 |
+
refine ⟨hag, ?_, realized_union hit hs.2.2.1 hreal, ?_⟩
|
| 387 |
+
· change paidDirections (s.2 ∪ newEvents lines K s a) ⊆ _
|
| 388 |
+
rw [paidDirections_union]
|
| 389 |
+
exact Finset.union_subset
|
| 390 |
+
(hs.2.1.trans (encodedDirections_mono _ hEF)) hdict
|
| 391 |
+
· change (s.2 ∪ newEvents lines K s a).card ≤ _
|
| 392 |
+
apply (Finset.card_union_le _ _).trans
|
| 393 |
+
calc
|
| 394 |
+
_ ≤ K * E.card + K * degree lines K s a :=
|
| 395 |
+
Nat.add_le_add hs.2.2.2 (newEvents_card lines K hK s a)
|
| 396 |
+
_ = _ := by rw [hcard, Nat.mul_add]
|
| 397 |
+
|
| 398 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 399 |
+
omit [Fintype D] [DecidableEq B] in
|
| 400 |
+
lemma touched_anchor (f : V → H) (hit : B → D → Prop)
|
| 401 |
+
(E : Finset V) (s : State V H D B) (hs : Agrees f E s) (v : V) (d : D)
|
| 402 |
+
(hd : d ∈ touchedToEncoded (fun v => lines (f v)) hit E v) :
|
| 403 |
+
∃ u ∈ E, ∃ x : AnchorChoice s.2 (lines (s.1 u)),
|
| 404 |
+
x.direction = d ∧ d ∈ lines (f v) ∧ Realized hit x.requirements := by
|
| 405 |
+
classical
|
| 406 |
+
obtain ⟨hgeom, r, hr⟩ := Finset.mem_filter.mp hd
|
| 407 |
+
obtain ⟨hv, henc⟩ := Finset.mem_inter.mp hgeom
|
| 408 |
+
obtain ⟨u, hu, hdu⟩ := Finset.mem_biUnion.mp henc
|
| 409 |
+
have hdu' : d ∈ lines (s.1 u) := by rw [hs u hu]; exact hdu
|
| 410 |
+
exact ⟨u, hu, anchorName s.2 _ d hdu' r,
|
| 411 |
+
anchorName_direction _ _ _ _ _, hv, anchorName_realized hit _ _ _ _ _ hr⟩
|
| 412 |
+
|
| 413 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 414 |
+
omit [Fintype D] in
|
| 415 |
+
|
| 416 |
+
lemma make_one (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K)
|
| 417 |
+
(E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s)
|
| 418 |
+
(v : V) (hv : v ∉ E)
|
| 419 |
+
(ha : 1 ≤ (touchedToEncoded (fun v => lines (f v)) hit E v).card) :
|
| 420 |
+
∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧
|
| 421 |
+
(insert v E).card = E.card + degree lines K s a ∧
|
| 422 |
+
Enabled lines K true s a ∧ actionCharge lines K s a = 0 := by
|
| 423 |
+
classical
|
| 424 |
+
obtain ⟨d, hd⟩ := Finset.card_pos.mp (by omega : 0 < (touchedToEncoded (fun v => lines (f v)) hit E v).card)
|
| 425 |
+
obtain ⟨u, hu, x, hxd, hdv, hxreal⟩ := touched_anchor lines f hit E s hs.1 v d hd
|
| 426 |
+
let c : OneChoice lines s := ⟨v, u, x, f v, hxd ▸ hdv⟩
|
| 427 |
+
let a : Action lines K s := .inr (.inl c)
|
| 428 |
+
have hc : (insert v E).card = E.card + degree lines K s a := by
|
| 429 |
+
simp [a, degree, Finset.card_insert_of_notMem hv]
|
| 430 |
+
refine ⟨a, ?_, hc, fun _ _ => rfl, rfl⟩
|
| 431 |
+
apply coherent_step lines f hit K hK E (insert v E) s hs a (Finset.subset_insert _ _) _ _ hxreal hc
|
| 432 |
+
· exact agrees_update f E s hs.1 v _
|
| 433 |
+
· apply (anchor_req_directions x).trans
|
| 434 |
+
intro z hz
|
| 435 |
+
have hz' : z = x.direction := Finset.mem_singleton.mp hz
|
| 436 |
+
apply Finset.mem_biUnion.mpr
|
| 437 |
+
exact ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hxd ▸ hdv)⟩
|
| 438 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 439 |
+
omit [Fintype D] in
|
| 440 |
+
|
| 441 |
+
lemma make_two (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K)
|
| 442 |
+
(low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s)
|
| 443 |
+
(v : V) (hv : v ∉ E)
|
| 444 |
+
(ha : 2 ≤ (touchedToEncoded (fun v => lines (f v)) hit E v).card) :
|
| 445 |
+
∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧
|
| 446 |
+
(insert v E).card = E.card + degree lines K s a ∧
|
| 447 |
+
Enabled lines K low s a ∧ actionCharge lines K s a = 1 := by
|
| 448 |
+
classical
|
| 449 |
+
obtain ⟨d, hd, e, he, hde⟩ := Finset.one_lt_card.mp (by omega :
|
| 450 |
+
1 < (touchedToEncoded (fun v => lines (f v)) hit E v).card)
|
| 451 |
+
obtain ⟨u, hu, x, hxd, hdv, hxreal⟩ := touched_anchor lines f hit E s hs.1 v d hd
|
| 452 |
+
obtain ⟨w, hw, y, hye, hev, hyreal⟩ := touched_anchor lines f hit E s hs.1 v e he
|
| 453 |
+
let c : TwoChoice lines s := ⟨v, u, w, x, y, f v,
|
| 454 |
+
by simpa only [hxd, hye] using And.intro hde (And.intro hdv hev)⟩
|
| 455 |
+
let a : Action lines K s := .inr (.inr (.inl c))
|
| 456 |
+
have hc : (insert v E).card = E.card + degree lines K s a := by
|
| 457 |
+
simp [a, degree, Finset.card_insert_of_notMem hv]
|
| 458 |
+
refine ⟨a, ?_, hc, ?_, rfl⟩
|
| 459 |
+
· apply coherent_step lines f hit K hK E (insert v E) s hs a (Finset.subset_insert _ _) _ _
|
| 460 |
+
(realized_union hit hxreal hyreal) hc
|
| 461 |
+
· exact agrees_update f E s hs.1 v _
|
| 462 |
+
· change paidDirections (x.requirements ∪ y.requirements) ⊆ _
|
| 463 |
+
rw [paidDirections_union]
|
| 464 |
+
apply Finset.union_subset
|
| 465 |
+
· apply (anchor_req_directions x).trans
|
| 466 |
+
intro z hz
|
| 467 |
+
have hz' := Finset.mem_singleton.mp hz
|
| 468 |
+
exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hxd ▸ hdv)⟩
|
| 469 |
+
· apply (anchor_req_directions y).trans
|
| 470 |
+
intro z hz
|
| 471 |
+
have hz' := Finset.mem_singleton.mp hz
|
| 472 |
+
exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hye ▸ hev)⟩
|
| 473 |
+
· intro c' he
|
| 474 |
+
simp [a] at he
|
| 475 |
+
end SharpRamseyFive.CertificateCover
|
| 476 |
+
end
|
| 477 |
+
|
| 478 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/CompleteProgramWeight.lean
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.TruncatedTupleIntegrable
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.MakePair
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 8 |
+
|
| 9 |
+
section
|
| 10 |
+
open MeasureTheory ProbabilityTheory
|
| 11 |
+
open scoped BigOperators NNReal
|
| 12 |
+
open MeasureTheory ProbabilityTheory
|
| 13 |
+
open scoped BigOperators NNReal
|
| 14 |
+
open scoped BigOperators
|
| 15 |
+
open MeasureTheory ProbabilityTheory
|
| 16 |
+
open scoped BigOperators ENNReal NNReal
|
| 17 |
+
namespace SharpRamseyFive.CertificateCover
|
| 18 |
+
open SharpRamseyFive.StaticCertificates
|
| 19 |
+
open SharpRamseyFive.CertificateEnumeration
|
| 20 |
+
open SharpRamseyFive.WeightedPrograms
|
| 21 |
+
open SharpRamseyFive.ResidualCertificate
|
| 22 |
+
open scoped BigOperators
|
| 23 |
+
variable {V H D B : Type*} [Fintype V] [DecidableEq V]
|
| 24 |
+
[Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D]
|
| 25 |
+
[Fintype B] [DecidableEq B]
|
| 26 |
+
variable (lines : H → Finset D)
|
| 27 |
+
omit [Fintype H] [DecidableEq H] [Fintype D] in
|
| 28 |
+
lemma complete_program_weight (rate : D → ℝ≥0) (denom : ℝ) (hd : denom ≠ 0)
|
| 29 |
+
(K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B)
|
| 30 |
+
(c : completePrograms lines K low E s) :
|
| 31 |
+
weight (fun p : B × D => rate p.2) (finish lines K s c.val.2).2 =
|
| 32 |
+
(weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) *
|
| 33 |
+
dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.val.2 := by
|
| 34 |
+
rw [trace_weight lines rate denom hd K low s c.val.2 c.property.1,
|
| 35 |
+
c.property.2.2]
|
| 36 |
+
ring
|
| 37 |
+
omit [Fintype D] in
|
| 38 |
+
|
| 39 |
+
lemma complete_program_sum (rate : D → ℝ≥0) (denom b mass : ℝ)
|
| 40 |
+
(hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass)
|
| 41 |
+
(hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass)
|
| 42 |
+
(K N₁ N₂ : ℕ) (low : Bool)
|
| 43 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁)
|
| 44 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 45 |
+
(Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂)
|
| 46 |
+
(E : Finset V) (s : State V H D B) :
|
| 47 |
+
(∑ c : completePrograms lines K low E s,
|
| 48 |
+
weight (fun p : B × D => rate p.2) (finish lines K s c.val.2).2) ≤
|
| 49 |
+
(weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) *
|
| 50 |
+
∑ n : Fin (Fintype.card V - E.card + 1),
|
| 51 |
+
branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by
|
| 52 |
+
classical
|
| 53 |
+
simp_rw [complete_program_weight lines rate denom hd.ne' K low E s]
|
| 54 |
+
rw [← Finset.mul_sum]
|
| 55 |
+
apply mul_le_mul_of_nonneg_left _
|
| 56 |
+
(mul_nonneg (weight_nonneg _ _) (pow_nonneg hd.le _))
|
| 57 |
+
change (∑ c : {c : AllPrograms lines K E s // CompleteProgram lines K low E s c},
|
| 58 |
+
dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.val.2) ≤ _
|
| 59 |
+
have hsub := Finset.sum_subtype (p := CompleteProgram lines K low E s)
|
| 60 |
+
(F := completePrograms_fintype lines K low E s)
|
| 61 |
+
(Finset.univ.filter (CompleteProgram lines K low E s)) (fun _ => by simp)
|
| 62 |
+
(fun c : AllPrograms lines K E s => dWeight (Action lines K) (advance lines K)
|
| 63 |
+
(programCost lines rate denom K low) s c.2)
|
| 64 |
+
rw [← hsub, Finset.sum_filter]
|
| 65 |
+
change (∑ c : AllPrograms lines K E s,
|
| 66 |
+
if CompleteProgram lines K low E s c then
|
| 67 |
+
dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.2
|
| 68 |
+
else 0) ≤ _
|
| 69 |
+
rw [Fintype.sum_sigma]
|
| 70 |
+
apply Finset.sum_le_sum
|
| 71 |
+
intro n _
|
| 72 |
+
apply le_trans _ (program_enumeration lines rate denom b mass hd.le hb hm hmass
|
| 73 |
+
K N₁ N₂ low hN₁ hN₂ n.val s)
|
| 74 |
+
apply Finset.sum_le_sum
|
| 75 |
+
intro w _
|
| 76 |
+
by_cases hc : CompleteProgram lines K low E s ⟨n, w⟩
|
| 77 |
+
· simp only [ite_eq_left hc, ite_eq_left hc.2.1]
|
| 78 |
+
exact le_rfl
|
| 79 |
+
· simp only [ite_eq_right hc]
|
| 80 |
+
split_ifs
|
| 81 |
+
· exact dWeight_nonneg (Action lines K) (advance lines K) _
|
| 82 |
+
(programCost_nonneg lines rate denom hd.le K low) s w
|
| 83 |
+
· exact le_rfl
|
| 84 |
+
|
| 85 |
+
def badEvent (K J : ℕ) (low : Bool) (E : Finset V) (s : State V H D B)
|
| 86 |
+
(f : V → H) : Set ((B × D) → ℕ) :=
|
| 87 |
+
{ω | Function.Injective f ∧ Coherent lines f (fun r d => ω (r, d) ≠ 0) K E s ∧
|
| 88 |
+
(∀ v ∉ E, Fintype.card B / 2 ≤
|
| 89 |
+
(touchedBatches (fun v => lines (f v)) (fun r d => ω (r, d) ≠ 0) v).card) ∧
|
| 90 |
+
(low = false → ∀ d, (Finset.univ.filter (fun r => ω (r, d) ≠ 0)).card ≤ J)}
|
| 91 |
+
omit [Fintype H] [DecidableEq H] in
|
| 92 |
+
omit [Fintype D] in
|
| 93 |
+
|
| 94 |
+
lemma bad_event_cover (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 95 |
+
(hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K))
|
| 96 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 97 |
+
(E : Finset V) (s : State V H D B) (f : V → H) (ω : (B × D) → ℕ)
|
| 98 |
+
(hω : ω ∈ badEvent lines K J low E s f) :
|
| 99 |
+
∃ c : completePrograms lines K low E s,
|
| 100 |
+
(finish lines K s c.val.2).1 = f ∧ ω ∈ positiveEvent (finish lines K s c.val.2).2 := by
|
| 101 |
+
classical
|
| 102 |
+
have hex : ∃ n, ∃ w : Word lines K n s,
|
| 103 |
+
Segment lines f (fun r d => ω (r, d) ≠ 0) K low E Finset.univ s w ∧
|
| 104 |
+
0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by
|
| 105 |
+
cases low with
|
| 106 |
+
| false =>
|
| 107 |
+
exact bad_program_high lines f hω.1 (fun r d => ω (r, d) ≠ 0) K J h hK hh
|
| 108 |
+
hsize E s hω.2.1 hω.2.2.1 (hω.2.2.2 rfl) herr
|
| 109 |
+
| true =>
|
| 110 |
+
apply bad_program_low lines f hω.1 (fun r d => ω (r, d) ≠ 0) K h hK hh
|
| 111 |
+
_ E s hω.2.1 hω.2.2.1 herr
|
| 112 |
+
simpa using hsize
|
| 113 |
+
obtain ⟨n, w, hw, hq, hn⟩ := hex
|
| 114 |
+
have hc : CompleteProgram lines K low E s ⟨⟨n, by omega⟩, w⟩ := by
|
| 115 |
+
refine ⟨hw.2.2, hq, ?_⟩
|
| 116 |
+
change degreeSum lines K s w = Fintype.card V - E.card
|
| 117 |
+
have he := hw.2.1
|
| 118 |
+
simp only [Finset.card_univ] at he
|
| 119 |
+
omega
|
| 120 |
+
refine ⟨⟨⟨⟨n, by omega⟩, w⟩, hc⟩, ?_, ?_⟩
|
| 121 |
+
· funext v
|
| 122 |
+
exact hw.1.1 v (Finset.mem_univ _)
|
| 123 |
+
· intro p hp
|
| 124 |
+
exact hw.1.2.2.1 p hp
|
| 125 |
+
|
| 126 |
+
theorem bad_completion_bound (rate : D → ℝ≥0) (denom b mass : ℝ)
|
| 127 |
+
(hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass)
|
| 128 |
+
(hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass)
|
| 129 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 130 |
+
(hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K))
|
| 131 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 132 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁)
|
| 133 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 134 |
+
(Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂)
|
| 135 |
+
(E : Finset V) (s : State V H D B) :
|
| 136 |
+
(∑ f : V → H, (poissonLaw (fun p : B × D => rate p.2)).real
|
| 137 |
+
(badEvent lines K J low E s f)) ≤
|
| 138 |
+
(weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) *
|
| 139 |
+
∑ n : Fin (Fintype.card V - E.card + 1),
|
| 140 |
+
branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by
|
| 141 |
+
classical
|
| 142 |
+
apply le_trans _ (complete_program_sum lines rate denom b mass hd hb hm hmass
|
| 143 |
+
K N₁ N₂ low hN₁ hN₂ E s)
|
| 144 |
+
apply decoded_static_union_bound rate
|
| 145 |
+
(fun c : completePrograms lines K low E s => (finish lines K s c.val.2).2)
|
| 146 |
+
(fun c => (finish lines K s c.val.2).1) (badEvent lines K J low E s)
|
| 147 |
+
· intro f
|
| 148 |
+
exact (Set.to_countable _).measurableSet
|
| 149 |
+
· intro f ω hω
|
| 150 |
+
exact bad_event_cover lines K J h hK hh low hsize herr E s f ω hω
|
| 151 |
+
|
| 152 |
+
def selectedBadEvent (K J : ℕ) (low : Bool) (E : Finset V) (s : State V H D B)
|
| 153 |
+
(f : V → H) : Set ((B × D) → ℕ) := by
|
| 154 |
+
classical
|
| 155 |
+
exact {ω | Function.Injective f ∧ ∃ hit : B → D → Prop,
|
| 156 |
+
(∀ r d, hit r d → ω (r, d) ≠ 0) ∧ Coherent lines f hit K E s ∧
|
| 157 |
+
(∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches (fun v => lines (f v)) hit v).card) ∧
|
| 158 |
+
(low = false → ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J)}
|
| 159 |
+
omit [Fintype H] [DecidableEq H] in
|
| 160 |
+
omit [Fintype D] in
|
| 161 |
+
|
| 162 |
+
lemma selected_bad_event_cover (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 163 |
+
(hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K))
|
| 164 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 165 |
+
(E : Finset V) (s : State V H D B) (f : V → H) (ω : (B × D) → ℕ)
|
| 166 |
+
(hω : ω ∈ selectedBadEvent lines K J low E s f) :
|
| 167 |
+
∃ c : completePrograms lines K low E s,
|
| 168 |
+
(finish lines K s c.val.2).1 = f ∧ ω ∈ positiveEvent (finish lines K s c.val.2).2 := by
|
| 169 |
+
classical
|
| 170 |
+
obtain ⟨hfi, hit, hpos, hco, hbad, htr⟩ := hω
|
| 171 |
+
have hex : ∃ n, ∃ w : Word lines K n s,
|
| 172 |
+
Segment lines f hit K low E Finset.univ s w ∧
|
| 173 |
+
0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by
|
| 174 |
+
cases low with
|
| 175 |
+
| false =>
|
| 176 |
+
exact bad_program_high lines f hfi hit K J h hK hh
|
| 177 |
+
hsize E s hco hbad (htr rfl) herr
|
| 178 |
+
| true =>
|
| 179 |
+
apply bad_program_low lines f hfi hit K h hK hh _ E s hco hbad herr
|
| 180 |
+
simpa using hsize
|
| 181 |
+
obtain ⟨n, w, hw, hq, hn⟩ := hex
|
| 182 |
+
have hc : CompleteProgram lines K low E s ⟨⟨n, by omega⟩, w⟩ := by
|
| 183 |
+
refine ⟨hw.2.2, hq, ?_⟩
|
| 184 |
+
change degreeSum lines K s w = Fintype.card V - E.card
|
| 185 |
+
have he := hw.2.1
|
| 186 |
+
simp only [Finset.card_univ] at he
|
| 187 |
+
omega
|
| 188 |
+
refine ⟨⟨⟨⟨n, by omega⟩, w⟩, hc⟩, ?_, ?_⟩
|
| 189 |
+
· funext v
|
| 190 |
+
exact hw.1.1 v (Finset.mem_univ _)
|
| 191 |
+
· intro p hp
|
| 192 |
+
exact hpos p.1 p.2 (hw.1.2.2.1 p hp)
|
| 193 |
+
|
| 194 |
+
theorem selected_bad_completion_bound (rate : D → ℝ≥0) (denom b mass : ℝ)
|
| 195 |
+
(hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass)
|
| 196 |
+
(hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass)
|
| 197 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 198 |
+
(hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K))
|
| 199 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 200 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁)
|
| 201 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 202 |
+
(Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂)
|
| 203 |
+
(E : Finset V) (s : State V H D B) :
|
| 204 |
+
(∑ f : V → H, (poissonLaw (fun p : B × D => rate p.2)).real
|
| 205 |
+
(selectedBadEvent lines K J low E s f)) ≤
|
| 206 |
+
(weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) *
|
| 207 |
+
∑ n : Fin (Fintype.card V - E.card + 1),
|
| 208 |
+
branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by
|
| 209 |
+
classical
|
| 210 |
+
apply le_trans _ (complete_program_sum lines rate denom b mass hd hb hm hmass
|
| 211 |
+
K N₁ N₂ low hN₁ hN₂ E s)
|
| 212 |
+
apply decoded_static_union_bound rate
|
| 213 |
+
(fun c : completePrograms lines K low E s => (finish lines K s c.val.2).2)
|
| 214 |
+
(fun c => (finish lines K s c.val.2).1) (selectedBadEvent lines K J low E s)
|
| 215 |
+
· intro f
|
| 216 |
+
exact (Set.to_countable _).measurableSet
|
| 217 |
+
· intro f ω hω
|
| 218 |
+
exact selected_bad_event_cover lines K J h hK hh low hsize herr E s f ω hω
|
| 219 |
+
|
| 220 |
+
end SharpRamseyFive.CertificateCover
|
| 221 |
+
|
| 222 |
+
namespace SharpRamseyFive.SelectionBridge
|
| 223 |
+
open MeasureTheory ProbabilityTheory
|
| 224 |
+
open scoped BigOperators NNReal
|
| 225 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 226 |
+
open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations
|
| 227 |
+
open SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedPrograms
|
| 228 |
+
open Classical
|
| 229 |
+
variable {D V H C : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 230 |
+
[Fintype H] [DecidableEq H] [Fintype C] [DecidableEq C]
|
| 231 |
+
omit [DecidableEq D] in
|
| 232 |
+
|
| 233 |
+
lemma restriction_preserving (rate : D → ℝ≥0) (lab : D → Option C) (R : ℕ) :
|
| 234 |
+
MeasurePreserving (fun ω : Fin R × D → ℕ => fun i : Block lab R none => ω i)
|
| 235 |
+
(batchMeasure (fun i : Fin R × D => rate i.2))
|
| 236 |
+
(batchMeasure (fun i : Block lab R none => rate i.1.2)) := by
|
| 237 |
+
exact (measurePreserving_eval (fun c : Option C => batchMeasure
|
| 238 |
+
(fun i : Block lab R c => rate i.1.2)) none).comp
|
| 239 |
+
(measurePreserving_partition (fun i : Fin R × D => rate i.2) (fun i => lab i.2))
|
| 240 |
+
omit [DecidableEq D] in
|
| 241 |
+
|
| 242 |
+
lemma integral_restriction (rate : D → ℝ≥0) (lab : D → Option C) (R : ℕ)
|
| 243 |
+
(F : (Block lab R none → ℕ) → ℝ) :
|
| 244 |
+
(∫ z, F z ∂batchMeasure (fun i : Block lab R none => rate i.1.2)) =
|
| 245 |
+
∫ ω, F (fun i => ω i) ∂batchMeasure (fun i : Fin R × D => rate i.2) := by
|
| 246 |
+
have h := restriction_preserving rate lab R
|
| 247 |
+
rw [← h.map_eq]
|
| 248 |
+
exact integral_map h.measurable.aemeasurable (measurable_of_countable F).aestronglyMeasurable
|
| 249 |
+
omit [Fintype D] [DecidableEq V] in
|
| 250 |
+
|
| 251 |
+
lemma label_none_external (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ)
|
| 252 |
+
{v : V} {d : D} (hd : d ∈ s v) (he : componentLabel weight s t d = none) :
|
| 253 |
+
External weight s t d := by
|
| 254 |
+
by_contra hn
|
| 255 |
+
have hi := componentLabel_internal weight s t (Finset.mem_filter.mpr ⟨hd,hn⟩)
|
| 256 |
+
rw [he] at hi
|
| 257 |
+
cases hi
|
| 258 |
+
|
| 259 |
+
noncomputable def selectedHit (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ)
|
| 260 |
+
{R : ℕ} (ω : Fin R × D → ℕ) (r : Fin R) (d : D) : Prop :=
|
| 261 |
+
componentLabel weight s t d = none ∧ ω (r,d) ≠ 0
|
| 262 |
+
|
| 263 |
+
lemma touched_equals_shared (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ)
|
| 264 |
+
(R : ℕ) (ω : Fin R × D → ℕ) (v : V) :
|
| 265 |
+
TupleComponents.hitBatches (touched (componentLabel weight s t) R
|
| 266 |
+
((strongGraph weight s t).connectedComponentMk v) (s v) (fun i => ω i)) =
|
| 267 |
+
ResidualCertificate.touchedBatches s (selectedHit weight s t ω) v := by
|
| 268 |
+
ext r
|
| 269 |
+
simp only [TupleComponents.hitBatches, touched, Finset.mem_filter, Finset.mem_univ, true_and,
|
| 270 |
+
decide_eq_true_eq, ResidualCertificate.touchedBatches,
|
| 271 |
+
ResidualCertificate.sharedBatches, Finset.mem_inter]
|
| 272 |
+
constructor
|
| 273 |
+
· rintro ⟨d,hd,hpos⟩
|
| 274 |
+
obtain ⟨u,hu,hdiff⟩ := (external_iff_other weight s t hd).mp
|
| 275 |
+
(label_none_external weight s t hd d.property)
|
| 276 |
+
refine ⟨u, ?_, d, ⟨hd,hu⟩, d.property,hpos⟩
|
| 277 |
+
intro he
|
| 278 |
+
subst u
|
| 279 |
+
exact hdiff rfl
|
| 280 |
+
· rintro ⟨u,_,d,⟨hd,_⟩,he,hpos⟩
|
| 281 |
+
exact ⟨⟨d,he⟩,hd,hpos⟩
|
| 282 |
+
|
| 283 |
+
omit [DecidableEq V] in
|
| 284 |
+
lemma selected_trunc (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ)
|
| 285 |
+
(R J : ℕ) (ω : Fin R × D → ℕ)
|
| 286 |
+
(htr : blockTrunc (componentLabel weight s t) R J none (fun i => ω i) ≠ 0) :
|
| 287 |
+
∀ d, (Finset.univ.filter (fun r => selectedHit weight s t ω r d)).card ≤ J := by
|
| 288 |
+
intro d
|
| 289 |
+
by_cases hd : componentLabel weight s t d = none
|
| 290 |
+
· have hp : lineTrunc R J (fun r => ω (r,d)) ≠ 0 :=
|
| 291 |
+
Finset.prod_ne_zero_iff.mp htr ⟨d,hd⟩ (Finset.mem_univ _)
|
| 292 |
+
have hh : (Finset.univ.filter (fun r => ω (r,d) ≠ 0)).card < J := by
|
| 293 |
+
by_contra hn
|
| 294 |
+
exact hp (ite_eq_right hn)
|
| 295 |
+
simpa only [selectedHit, hd, true_and] using hh.le
|
| 296 |
+
· simp only [selectedHit, hd, false_and, Finset.filter_false, Finset.card_empty]
|
| 297 |
+
exact Nat.zero_le _
|
| 298 |
+
|
| 299 |
+
noncomputable def vertexBadMass (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ)
|
| 300 |
+
(R J : ℕ) (A : Finset V) : ℝ :=
|
| 301 |
+
badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => rate i.1.2))
|
| 302 |
+
(blockTrunc (componentLabel weight s t) R J none)
|
| 303 |
+
(fun v z => BAD (touched (componentLabel weight s t) R
|
| 304 |
+
((strongGraph weight s t).connectedComponentMk v) (s v) z)) A
|
| 305 |
+
|
| 306 |
+
omit [Fintype D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 307 |
+
lemma empty_coherent (lines : H → Finset D) (f g : V → H) (R K : ℕ)
|
| 308 |
+
(E : Finset V) (hit : Fin R → D → Prop) (he : ∀ v ∈ E, g v = f v) :
|
| 309 |
+
Coherent lines f hit K E (g,∅) := by
|
| 310 |
+
refine ⟨he, ?_, ?_, ?_⟩
|
| 311 |
+
· simp [ResidualCertificate.DictionaryInvariant, ResidualCertificate.paidDirections]
|
| 312 |
+
· intro p hp
|
| 313 |
+
exact False.elim (Finset.notMem_empty p hp)
|
| 314 |
+
· simp
|
| 315 |
+
omit [Fintype H] [DecidableEq H] in
|
| 316 |
+
|
| 317 |
+
lemma bad_mass_le_selected_event (weight rate : D → ℝ≥0) (lines : H → Finset D)
|
| 318 |
+
(f g : V → H) (hf : Function.Injective f) (R J K : ℕ) (t : ℝ) (low : Bool)
|
| 319 |
+
(A : Finset V) (he : ∀ v ∈ Finset.univ \ A, g v = f v) :
|
| 320 |
+
vertexBadMass weight rate (lines ∘ f) t R J A ≤
|
| 321 |
+
(StaticCertificates.poissonLaw (fun i : Fin R × D => rate i.2)).real
|
| 322 |
+
(selectedBadEvent lines K J low (Finset.univ \ A) (g,∅) f) := by
|
| 323 |
+
let lab := componentLabel weight (lines ∘ f) t
|
| 324 |
+
let bad := fun v z => BAD (touched lab R
|
| 325 |
+
((strongGraph weight (lines ∘ f) t).connectedComponentMk v) (lines (f v)) z)
|
| 326 |
+
let T := blockTrunc lab R J none
|
| 327 |
+
let E : Set ((Fin R × D) → ℕ) := selectedBadEvent lines K J low (Finset.univ \ A) (g,∅) f
|
| 328 |
+
have hE : MeasurableSet E := (Set.to_countable _).measurableSet
|
| 329 |
+
change (∫ z, T z * ∏ v ∈ A, badIndicator bad v z
|
| 330 |
+
∂batchMeasure (fun i : Block lab R none => rate i.1.2)) ≤ _
|
| 331 |
+
rw [integral_restriction rate lab R]
|
| 332 |
+
have hi : Integrable (fun ω : Fin R × D → ℕ =>
|
| 333 |
+
T (fun i => ω i) * ∏ v ∈ A, badIndicator bad v (fun i => ω i))
|
| 334 |
+
(batchMeasure (fun i : Fin R × D => rate i.2)) := by
|
| 335 |
+
apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable 1
|
| 336 |
+
apply Filter.Eventually.of_forall
|
| 337 |
+
intro ω
|
| 338 |
+
rw [Real.norm_eq_abs, abs_of_nonneg (badTerm_range T (blockTrunc_range lab R J none)
|
| 339 |
+
bad A (fun i => ω i)).1]
|
| 340 |
+
exact (badTerm_range T (blockTrunc_range lab R J none) bad A (fun i => ω i)).2
|
| 341 |
+
change _ ≤ (batchMeasure (fun i : Fin R × D => rate i.2)).real E
|
| 342 |
+
rw [← integral_indicator_one hE]
|
| 343 |
+
apply integral_mono hi ((integrable_const (1 : ℝ)).indicator hE)
|
| 344 |
+
intro ω
|
| 345 |
+
dsimp only
|
| 346 |
+
by_cases hz : T (fun i => ω i) * ∏ v ∈ A, badIndicator bad v (fun i => ω i) = 0
|
| 347 |
+
· rw [hz]
|
| 348 |
+
exact Set.indicator_nonneg (fun _ _ => zero_le_one) ω
|
| 349 |
+
· have ht : T (fun i => ω i) ≠ 0 := (mul_ne_zero_iff.mp hz).1
|
| 350 |
+
have hb : ∀ v ∈ A, bad v (fun i => ω i) := by
|
| 351 |
+
intro v hv
|
| 352 |
+
have hn := Finset.prod_ne_zero_iff.mp (mul_ne_zero_iff.mp hz).2 v hv
|
| 353 |
+
by_contra hn'
|
| 354 |
+
exact hn (ite_eq_right hn')
|
| 355 |
+
have hmem : ω ∈ E := by
|
| 356 |
+
refine ⟨hf, selectedHit weight (lines ∘ f) t ω, ?_, ?_, ?_, ?_⟩
|
| 357 |
+
· intro r d hd
|
| 358 |
+
exact hd.2
|
| 359 |
+
· exact empty_coherent lines f g R K (Finset.univ \ A) _ he
|
| 360 |
+
· intro v hv
|
| 361 |
+
have hvA : v ∈ A := by simpa using hv
|
| 362 |
+
have hvb := hb v hvA
|
| 363 |
+
change R / 2 ≤ (TupleComponents.hitBatches (touched lab R
|
| 364 |
+
((strongGraph weight (lines ∘ f) t).connectedComponentMk v) (lines (f v))
|
| 365 |
+
(fun i => ω i))).card at hvb
|
| 366 |
+
change R / 2 ≤ (TupleComponents.hitBatches (touched
|
| 367 |
+
(componentLabel weight (lines ∘ f) t) R
|
| 368 |
+
((strongGraph weight (lines ∘ f) t).connectedComponentMk v)
|
| 369 |
+
((lines ∘ f) v) (fun i => ω i))).card at hvb
|
| 370 |
+
rw [touched_equals_shared weight (lines ∘ f) t R ω v] at hvb
|
| 371 |
+
simpa only [Fintype.card_fin, Function.comp_def] using hvb
|
| 372 |
+
· intro _
|
| 373 |
+
exact selected_trunc weight (lines ∘ f) t R J ω ht
|
| 374 |
+
rw [Set.indicator_of_mem hmem]
|
| 375 |
+
exact (badTerm_range T (blockTrunc_range lab R J none) bad A (fun i => ω i)).2
|
| 376 |
+
omit [Fintype D] [Fintype V] [DecidableEq V] in
|
| 377 |
+
|
| 378 |
+
lemma vertex_injective (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : Function.Injective (vertex weight s t) := by
|
| 379 |
+
intro c d he
|
| 380 |
+
have h := congrArg (strongGraph weight s t).connectedComponentMk he
|
| 381 |
+
simpa only [vertex_color] using h
|
| 382 |
+
|
| 383 |
+
lemma component_bad_mass_eq_vertex (weight rate : D → ℝ≥0) (s : V → Finset D)
|
| 384 |
+
(t : ℝ) (R J : ℕ) (U : Finset (Components weight s t)) :
|
| 385 |
+
badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => rate i.1.2))
|
| 386 |
+
(blockTrunc (componentLabel weight s t) R J none)
|
| 387 |
+
(isBad weight s t R) U =
|
| 388 |
+
vertexBadMass weight rate s t R J (U.image (vertex weight s t)) := by
|
| 389 |
+
unfold badMass vertexBadMass
|
| 390 |
+
congr 1
|
| 391 |
+
funext z
|
| 392 |
+
congr 1
|
| 393 |
+
rw [Finset.prod_image (fun _ _ _ _ he => vertex_injective weight s t he)]
|
| 394 |
+
apply Finset.prod_congr rfl
|
| 395 |
+
intro c hc
|
| 396 |
+
simp only [badIndicator, isBad, vertex_color]
|
| 397 |
+
split_ifs with h <;> simp only [h, ite_true, ite_false]
|
| 398 |
+
|
| 399 |
+
theorem bad_residual_sum_le (weight rate : D → ℝ≥0) (lines : H → Finset D)
|
| 400 |
+
(t : ℝ) (R : ℕ) (denom b mass : ℝ)
|
| 401 |
+
(hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass)
|
| 402 |
+
(hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass)
|
| 403 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 404 |
+
(hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K))
|
| 405 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 406 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁)
|
| 407 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 408 |
+
(Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂)
|
| 409 |
+
(A : Finset V) (g : V → H) :
|
| 410 |
+
(∑ f : V → H, if Function.Injective f ∧ (∀ v ∉ A, g v = f v) then
|
| 411 |
+
vertexBadMass weight rate (lines ∘ f) t R J A else 0) ≤
|
| 412 |
+
denom ^ A.card * ∑ n : Fin (A.card + 1),
|
| 413 |
+
branchingBound (V := V) (B := Fin R) lines rate denom b mass K N₁ N₂ low ^ n.val := by
|
| 414 |
+
have hbnd := selected_bad_completion_bound (V := V) (B := Fin R)
|
| 415 |
+
lines rate denom b mass hd hb hm hmass K J h N₁ N₂ hK hh low
|
| 416 |
+
(by simpa only [Fintype.card_fin] using hsize) herr hN₁ hN₂
|
| 417 |
+
(Finset.univ \ A) (g,∅)
|
| 418 |
+
have heq : Fintype.card V - (Finset.univ \ A).card = A.card := by
|
| 419 |
+
rw [Finset.card_sdiff_of_subset (Finset.subset_univ A)]
|
| 420 |
+
simp only [Finset.card_univ]
|
| 421 |
+
have := Finset.card_le_card (Finset.subset_univ A)
|
| 422 |
+
simp only [Finset.card_univ] at this
|
| 423 |
+
omega
|
| 424 |
+
rw [Fin.sum_univ_eq_sum_range] at hbnd ⊢
|
| 425 |
+
simp only [heq, StaticCertificates.weight, Finset.prod_empty, one_mul] at hbnd
|
| 426 |
+
apply le_trans _ hbnd
|
| 427 |
+
apply Finset.sum_le_sum
|
| 428 |
+
intro f hf
|
| 429 |
+
split_ifs with hfi
|
| 430 |
+
· apply bad_mass_le_selected_event weight rate lines f g hfi.1 R J K t low A
|
| 431 |
+
intro v hv
|
| 432 |
+
exact hfi.2 v (Finset.mem_sdiff.mp hv).2
|
| 433 |
+
· exact ENNReal.toReal_nonneg
|
| 434 |
+
|
| 435 |
+
end SharpRamseyFive.SelectionBridge
|
| 436 |
+
|
| 437 |
+
namespace SharpRamseyFive.SelectionBridge
|
| 438 |
+
open MeasureTheory ProbabilityTheory
|
| 439 |
+
open scoped BigOperators NNReal
|
| 440 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 441 |
+
open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations
|
| 442 |
+
open SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedPrograms
|
| 443 |
+
open Classical
|
| 444 |
+
variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 445 |
+
[Fintype H] [DecidableEq H]
|
| 446 |
+
|
| 447 |
+
def labelled (f : V → H) (v : V) : H × V := (f v, v)
|
| 448 |
+
|
| 449 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 450 |
+
lemma labelled_injective (f : V → H) : Function.Injective (labelled f) := by
|
| 451 |
+
intro u v h
|
| 452 |
+
exact congrArg Prod.snd h
|
| 453 |
+
|
| 454 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 455 |
+
lemma labelled_map_injective : Function.Injective (labelled : (V → H) → (V → H × V)) := by
|
| 456 |
+
intro f g h
|
| 457 |
+
funext v
|
| 458 |
+
exact congrArg Prod.fst (congrFun h v)
|
| 459 |
+
|
| 460 |
+
end SharpRamseyFive.SelectionBridge
|
| 461 |
+
end
|
| 462 |
+
|
| 463 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/ComponentLabelWitness.lean
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.ExternalMass
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
namespace SharpRamseyFive.TupleComponents
|
| 12 |
+
open MeasureTheory ProbabilityTheory
|
| 13 |
+
open scoped BigOperators NNReal
|
| 14 |
+
open SharpRamseyFive.PoissonScore
|
| 15 |
+
open Classical
|
| 16 |
+
variable {D V C : Type} [Fintype D] [DecidableEq D]
|
| 17 |
+
[Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]
|
| 18 |
+
variable (label : D → Option C) (R : ℕ)
|
| 19 |
+
variable (color : V → C) (s : V → Finset D) (b : ℝ) (own : V → Fin R → Bool)
|
| 20 |
+
omit [Fintype D] [DecidableEq V] in
|
| 21 |
+
lemma componentLabel_witness (weight : D → ℝ≥0) (t : ℝ) (d : D)
|
| 22 |
+
(c : (strongGraph weight s t).ConnectedComponent)
|
| 23 |
+
(hc : componentLabel weight s t d = some c) :
|
| 24 |
+
∃ v, d ∈ s v ∧ (strongGraph weight s t).connectedComponentMk v = c := by
|
| 25 |
+
unfold componentLabel at hc
|
| 26 |
+
split_ifs at hc with h h'
|
| 27 |
+
exact ⟨h.choose, h.choose_spec, Option.some.inj hc⟩
|
| 28 |
+
omit [DecidableEq V] in
|
| 29 |
+
|
| 30 |
+
lemma simple_inside_univ (weight : D → ℝ≥0) (t : ℝ) (v : V)
|
| 31 |
+
(hsingle : ∀ u, (strongGraph weight s t).connectedComponentMk u =
|
| 32 |
+
(strongGraph weight s t).connectedComponentMk v → u = v) :
|
| 33 |
+
inside (componentLabel weight s t) ((strongGraph weight s t).connectedComponentMk v)
|
| 34 |
+
(s v) = Finset.univ := by
|
| 35 |
+
apply Finset.eq_univ_of_forall
|
| 36 |
+
intro d
|
| 37 |
+
obtain ⟨u, hu, hc⟩ := componentLabel_witness s weight t d.val _ d.property
|
| 38 |
+
have he := hsingle u hc
|
| 39 |
+
simpa [inside, he] using hu
|
| 40 |
+
|
| 41 |
+
omit [DecidableEq D] [Fintype C] in
|
| 42 |
+
lemma blockTrunc_eq_indicator (J : ℕ) (c : C) (x : Block label R (some c) → ℕ) :
|
| 43 |
+
blockTrunc label R J (some c) x =
|
| 44 |
+
(overloaded Finset.univ J)ᶜ.indicator (fun _ => (1 : ℝ)) (unblock label R c x) := by
|
| 45 |
+
by_cases he : unblock label R c x ∈ overloaded Finset.univ J
|
| 46 |
+
· simp only [Set.indicator_of_notMem (show unblock label R c x ∉
|
| 47 |
+
(overloaded Finset.univ J)ᶜ by simpa using he)]
|
| 48 |
+
obtain ⟨d, _, hd⟩ := he
|
| 49 |
+
apply Finset.prod_eq_zero (Finset.mem_univ d)
|
| 50 |
+
change lineTrunc R J (fun r => x ⟨(r,d), d.property⟩) = 0
|
| 51 |
+
have hn : ¬ (Finset.univ.filter (fun r => x ⟨(r,d), d.property⟩ ≠ 0)).card < J := by
|
| 52 |
+
exact not_lt.mpr hd
|
| 53 |
+
simp only [lineTrunc, ite_eq_right hn]
|
| 54 |
+
· rw [Set.indicator_of_mem (show unblock label R c x ∈
|
| 55 |
+
(overloaded Finset.univ J)ᶜ by simpa using he)]
|
| 56 |
+
apply Finset.prod_eq_one
|
| 57 |
+
intro d _
|
| 58 |
+
change lineTrunc R J (fun r => x ⟨(r,d), d.property⟩) = 1
|
| 59 |
+
have hd : (Finset.univ.filter (fun r => x ⟨(r,d), d.property⟩ ≠ 0)).card < J := by
|
| 60 |
+
by_contra hn
|
| 61 |
+
exact he ⟨d, Finset.mem_univ _, not_lt.mp hn⟩
|
| 62 |
+
simp only [lineTrunc, ite_eq_left hd]
|
| 63 |
+
|
| 64 |
+
omit [DecidableEq V] in
|
| 65 |
+
omit [Fintype C] in
|
| 66 |
+
lemma componentFactor_eq_single (J : ℕ) (c : C) (v : {v : V // color v = c})
|
| 67 |
+
(hsingle : ∀ u, color u = c → u = v.val)
|
| 68 |
+
(hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c)
|
| 69 |
+
(hin : inside label c (s v) = Finset.univ)
|
| 70 |
+
(z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) :
|
| 71 |
+
componentFactor label R color s b own J c z x =
|
| 72 |
+
(overloaded (inside label c (s v)) J)ᶜ.indicator
|
| 73 |
+
(maskedTerm (inside label c (s v)) b (own v) (touched label R c (s v) z))
|
| 74 |
+
(unblock label R c x) := by
|
| 75 |
+
have hp : (∏ u : {v : V // color v = c}, scoreTerm (s u) b (own u) (fill label R c z x)) =
|
| 76 |
+
scoreTerm (s v) b (own v) (fill label R c z x) := by
|
| 77 |
+
apply Finset.prod_eq_single v
|
| 78 |
+
· intro u _ huv
|
| 79 |
+
exfalso
|
| 80 |
+
exact huv (Subtype.ext (hsingle u u.property))
|
| 81 |
+
· simp
|
| 82 |
+
rw [componentFactor, hp, scoreTerm_eq_masked label R c (s v) b (own v) hcompat,
|
| 83 |
+
blockTrunc_eq_indicator label R J c, hin]
|
| 84 |
+
by_cases he : unblock label R c x ∈ (overloaded Finset.univ J)ᶜ <;> simp [he]
|
| 85 |
+
omit [DecidableEq V] in
|
| 86 |
+
omit [Fintype C] in
|
| 87 |
+
|
| 88 |
+
lemma simple_component_integral (rate : D → ℝ≥0) (J : ℕ)
|
| 89 |
+
(c : C) (v : {v : V // color v = c})
|
| 90 |
+
(hsingle : ∀ u, color u = c → u = v.val)
|
| 91 |
+
(hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c)
|
| 92 |
+
(hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) :
|
| 93 |
+
(∫ x, componentFactor label R color s b own J c z x
|
| 94 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) =
|
| 95 |
+
∫ w, (overloaded (inside label c (s v)) J)ᶜ.indicator
|
| 96 |
+
(maskedTerm (inside label c (s v)) b (own v) (touched label R c (s v) z)) w
|
| 97 |
+
∂scheduleMeasure (fun d : IntDir label c => rate d) R := by
|
| 98 |
+
simp_rw [componentFactor_eq_single label R color s b own J c v hsingle hcompat hin]
|
| 99 |
+
exact (measurePreserving_unblock label R rate c).integral_comp
|
| 100 |
+
(unblockEquiv label R c).measurableEmbedding _
|
| 101 |
+
omit [DecidableEq V] in
|
| 102 |
+
omit [Fintype C] in
|
| 103 |
+
|
| 104 |
+
lemma simple_component_attenuation (rate : D → ℝ≥0) (J : ℕ)
|
| 105 |
+
(c : C) (v : {v : V // color v = c})
|
| 106 |
+
(hsingle : ∀ u, color u = c → u = v.val)
|
| 107 |
+
(hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c)
|
| 108 |
+
(hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ)
|
| 109 |
+
{L base delta alpha : ℝ} (hL : 10000 ≤ L)
|
| 110 |
+
(hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) =
|
| 111 |
+
L * (base + delta - alpha))
|
| 112 |
+
(hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base)
|
| 113 |
+
(ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ}
|
| 114 |
+
(hN : N ≤ (untouchedBatches (touched label R c (s v) z)).card) (hK : K ≤ N) :
|
| 115 |
+
|∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x
|
| 116 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤
|
| 117 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) *
|
| 118 |
+
(|delta| ^ N + alpha ^ K +
|
| 119 |
+
∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J) := by
|
| 120 |
+
rw [simple_component_integral label R color s _ own rate J c v hsingle hcompat hin z]
|
| 121 |
+
exact simple_singleton_truncated _ _ J (own v) (touched label R c (s v) z)
|
| 122 |
+
hL hmass hint hbase ha hd hN hK
|
| 123 |
+
omit [Fintype C] in
|
| 124 |
+
|
| 125 |
+
lemma nonsimple_component_attenuation (rate : D → ℝ≥0) (J : ℕ)
|
| 126 |
+
(c : C) (v : {v : V // color v = c}) (z : Block label R none → ℕ)
|
| 127 |
+
(hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c)
|
| 128 |
+
{L lam base : ℝ} (hL : 10000 ≤ L)
|
| 129 |
+
(hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * lam)
|
| 130 |
+
(hlam : (37 / 50 : ℝ) ≤ lam) (hbase : (37 / 50 : ℝ) ≤ base) :
|
| 131 |
+
(∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x|
|
| 132 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) ≤
|
| 133 |
+
Real.exp (-(7 / 10 : ℝ) * (L * R)) := by
|
| 134 |
+
apply (component_integral_abs_le label R color s own rate J c v z hcompat
|
| 135 |
+
(show 0 ≤ L by linarith) (by norm_num : (0 : ℝ) ≤ 37 / 50) hmass hlam hbase).trans
|
| 136 |
+
have he : (2 : ℝ) ≤ Real.exp ((1 / 25 : ℝ) * L) := by
|
| 137 |
+
have := Real.add_one_le_exp ((1 / 25 : ℝ) * L)
|
| 138 |
+
linarith
|
| 139 |
+
have hmul := mul_le_mul_of_nonneg_right he (Real.exp_pos (-L * (37 / 50 : ℝ))).le
|
| 140 |
+
rw [← Real.exp_add] at hmul
|
| 141 |
+
have hpow := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ 2 * Real.exp (-L * (37 / 50 : ℝ))) hmul R
|
| 142 |
+
rw [← Real.exp_nat_mul] at hpow
|
| 143 |
+
convert hpow using 1 ; congr 1 ; ring
|
| 144 |
+
|
| 145 |
+
end SharpRamseyFive.TupleComponents
|
| 146 |
+
|
| 147 |
+
namespace SharpRamseyFive.TupleMultiplicity
|
| 148 |
+
open scoped BigOperators
|
| 149 |
+
open Classical
|
| 150 |
+
variable {V H : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
|
| 151 |
+
|
| 152 |
+
abbrev RepresentativeMap (V : Type*) := {r : V → V // ∀ v, r (r v) = r v}
|
| 153 |
+
abbrev Representatives (r : RepresentativeMap V) := {v : V // r.val v = v}
|
| 154 |
+
|
| 155 |
+
noncomputable def chosen (f : V → H) (v : V) : V :=
|
| 156 |
+
Classical.choose (show ∃ w, f w = f v from ⟨v, rfl⟩)
|
| 157 |
+
|
| 158 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 159 |
+
lemma chosen_spec (f : V → H) (v : V) : f (chosen f v) = f v :=
|
| 160 |
+
Classical.choose_spec (show ∃ w, f w = f v from ⟨v, rfl⟩)
|
| 161 |
+
|
| 162 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 163 |
+
lemma chosen_eq (f : V → H) {v w : V} (h : f v = f w) :
|
| 164 |
+
chosen f v = chosen f w := by
|
| 165 |
+
unfold chosen
|
| 166 |
+
congr 1
|
| 167 |
+
funext x
|
| 168 |
+
rw [h]
|
| 169 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 170 |
+
|
| 171 |
+
lemma chosen_idempotent (f : V → H) : ∀ v, chosen f (chosen f v) = chosen f v := by
|
| 172 |
+
intro v
|
| 173 |
+
exact chosen_eq f (chosen_spec f v)
|
| 174 |
+
|
| 175 |
+
noncomputable def representatives (f : V → H) : RepresentativeMap V :=
|
| 176 |
+
⟨chosen f, chosen_idempotent f⟩
|
| 177 |
+
|
| 178 |
+
noncomputable def assignment (f : V → H) : Representatives (representatives f) ↪ H where
|
| 179 |
+
toFun v := f v
|
| 180 |
+
inj' := by
|
| 181 |
+
intro v w h
|
| 182 |
+
apply Subtype.ext
|
| 183 |
+
have := chosen_eq f h
|
| 184 |
+
change chosen f v.val = chosen f w.val at this
|
| 185 |
+
simpa only [show chosen f v.val = v.val from v.property,
|
| 186 |
+
show chosen f w.val = w.val from w.property] using this
|
| 187 |
+
|
| 188 |
+
noncomputable def decode (r : RepresentativeMap V) (h : Representatives r ↪ H) : V → H :=
|
| 189 |
+
fun v => h ⟨r.val v, r.property v⟩
|
| 190 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 191 |
+
|
| 192 |
+
lemma decode_assignment (f : V → H) :
|
| 193 |
+
decode (representatives f) (assignment f) = f := by
|
| 194 |
+
funext v
|
| 195 |
+
exact chosen_spec f v
|
| 196 |
+
|
| 197 |
+
noncomputable def encode (f : V → H) :
|
| 198 |
+
(r : RepresentativeMap V) × (Representatives r ↪ H) :=
|
| 199 |
+
⟨representatives f, assignment f⟩
|
| 200 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 201 |
+
|
| 202 |
+
lemma encode_injective : Function.Injective (encode (V := V) (H := H)) := by
|
| 203 |
+
intro f g h
|
| 204 |
+
have := congrArg (fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) =>
|
| 205 |
+
decode z.1 z.2) h
|
| 206 |
+
simpa only [encode, decode_assignment] using this
|
| 207 |
+
|
| 208 |
+
lemma representativeMap_card_le :
|
| 209 |
+
Fintype.card (RepresentativeMap V) ≤ Fintype.card V ^ Fintype.card V := by
|
| 210 |
+
calc
|
| 211 |
+
_ ≤ Fintype.card (V → V) := Fintype.card_subtype_le _
|
| 212 |
+
_ = _ := by simp
|
| 213 |
+
|
| 214 |
+
lemma representatives_card_le (r : RepresentativeMap V) :
|
| 215 |
+
Fintype.card (Representatives r) ≤ Fintype.card V := Fintype.card_subtype_le _
|
| 216 |
+
|
| 217 |
+
theorem sum_tuples_le_representative_assignments (F : (V → H) → ℝ)
|
| 218 |
+
(hF : ∀ f, 0 ≤ F f) :
|
| 219 |
+
(∑ f : V → H, F f) ≤
|
| 220 |
+
∑ r : RepresentativeMap V, ∑ h : Representatives r ↪ H, F (decode r h) := by
|
| 221 |
+
rw [← Fintype.sum_sigma (fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) =>
|
| 222 |
+
F (decode z.1 z.2))]
|
| 223 |
+
let e := encode (V := V) (H := H)
|
| 224 |
+
let G := fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) => F (decode z.1 z.2)
|
| 225 |
+
have he : (∑ f : V → H, F f) = ∑ z ∈ Finset.univ.image e, G z := by
|
| 226 |
+
rw [Finset.sum_image (fun _ _ _ _ h => encode_injective h)]
|
| 227 |
+
apply Finset.sum_congr rfl
|
| 228 |
+
intro f _
|
| 229 |
+
simp only [G, encode, decode_assignment]
|
| 230 |
+
rw [he]
|
| 231 |
+
exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun z _ _ => hF _)
|
| 232 |
+
|
| 233 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 234 |
+
|
| 235 |
+
lemma range_decode (r : RepresentativeMap V) (h : Representatives r ↪ H) :
|
| 236 |
+
Set.range (decode r h) = Set.range h := by
|
| 237 |
+
ext a
|
| 238 |
+
constructor
|
| 239 |
+
· rintro ⟨v,rfl⟩
|
| 240 |
+
exact ⟨⟨r.val v,r.property v⟩,rfl⟩
|
| 241 |
+
· rintro ⟨v,rfl⟩
|
| 242 |
+
refine ⟨v, ?_⟩
|
| 243 |
+
apply congrArg h
|
| 244 |
+
exact Subtype.ext v.property
|
| 245 |
+
|
| 246 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 247 |
+
lemma fiber_decode (r : RepresentativeMap V) (h : Representatives r ↪ H)
|
| 248 |
+
(v : V) (w : Representatives r) : decode r h v = h w ↔ r.val v = w.val := by
|
| 249 |
+
constructor
|
| 250 |
+
· intro he
|
| 251 |
+
exact congrArg Subtype.val (h.injective he)
|
| 252 |
+
· intro he
|
| 253 |
+
exact congrArg h (Subtype.ext he)
|
| 254 |
+
end SharpRamseyFive.TupleMultiplicity
|
| 255 |
+
|
| 256 |
+
namespace SharpRamseyFive.TupleComponents
|
| 257 |
+
open MeasureTheory ProbabilityTheory
|
| 258 |
+
open scoped BigOperators NNReal
|
| 259 |
+
open SharpRamseyFive.PoissonScore
|
| 260 |
+
open Classical
|
| 261 |
+
variable {D V C : Type} [Fintype D] [DecidableEq D]
|
| 262 |
+
[Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]
|
| 263 |
+
omit [DecidableEq V] in
|
| 264 |
+
|
| 265 |
+
lemma mass_inside_eq (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (v : V) :
|
| 266 |
+
mass (fun d : IntDir (componentLabel weight s t)
|
| 267 |
+
((strongGraph weight s t).connectedComponentMk v) => rate d)
|
| 268 |
+
(inside (componentLabel weight s t) _ (s v)) =
|
| 269 |
+
mass rate (internalPart weight s t v) := by
|
| 270 |
+
unfold mass
|
| 271 |
+
apply Finset.sum_bij (fun d _ => d.val)
|
| 272 |
+
· intro d hd
|
| 273 |
+
exact (internalPart_iff_label weight s t v d.val).mpr
|
| 274 |
+
⟨(Finset.mem_filter.mp hd).2, d.property⟩
|
| 275 |
+
· intro a _ b _ hab
|
| 276 |
+
exact Subtype.ext hab
|
| 277 |
+
· intro d hd
|
| 278 |
+
obtain ⟨hm, hl⟩ := (internalPart_iff_label weight s t v d).mp hd
|
| 279 |
+
exact ⟨⟨d,hl⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _,hm⟩,rfl⟩
|
| 280 |
+
· intro d _
|
| 281 |
+
rfl
|
| 282 |
+
|
| 283 |
+
omit [Fintype D] [DecidableEq D] in
|
| 284 |
+
lemma mass_scaled (L : ℝ≥0) (weight : D → ℝ≥0) (S : Finset D) :
|
| 285 |
+
mass (fun d => L * weight d) S = (L : ℝ) * mass weight S := by
|
| 286 |
+
simp only [mass, NNReal.coe_mul, Finset.mul_sum]
|
| 287 |
+
|
| 288 |
+
lemma source_inside_mass_lower (weight : D → ℝ≥0) (s : V → Finset D)
|
| 289 |
+
{p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p)
|
| 290 |
+
(hs : ∀ v, (3 / 4 : ℝ) ≤ mass weight (s v)) (v : V) :
|
| 291 |
+
(37 / 50 : ℝ) ≤ mass (fun d : IntDir (componentLabel weight s (1 / (100 * p)))
|
| 292 |
+
((strongGraph weight s (1 / (100 * p))).connectedComponentMk v) => weight d)
|
| 293 |
+
(inside (componentLabel weight s (1 / (100 * p))) _ (s v)) := by
|
| 294 |
+
rw [mass_inside_eq]
|
| 295 |
+
exact source_internal_mass_lower weight s hp hc hs v
|
| 296 |
+
|
| 297 |
+
omit [Fintype D] [Fintype V] in
|
| 298 |
+
|
| 299 |
+
lemma repeats_same_component (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ)
|
| 300 |
+
{v w : V} (he : s v = s w) (hm : t < mass weight (s v)) :
|
| 301 |
+
(strongGraph weight s t).connectedComponentMk v =
|
| 302 |
+
(strongGraph weight s t).connectedComponentMk w := by
|
| 303 |
+
by_cases hvw : v = w
|
| 304 |
+
· exact congrArg _ hvw
|
| 305 |
+
· apply SimpleGraph.ConnectedComponent.connectedComponentMk_eq_of_adj
|
| 306 |
+
exact ⟨hvw, by simpa only [← he, Finset.inter_self] using hm⟩
|
| 307 |
+
|
| 308 |
+
variable (label : D → Option C) (R : ℕ) (color : V → C)
|
| 309 |
+
(s : V → Finset D) (own : V → Fin R → Bool)
|
| 310 |
+
|
| 311 |
+
def hitBatches {R : ℕ} (mask : Fin R → Bool) : Finset (Fin R) :=
|
| 312 |
+
Finset.univ.filter (fun r => mask r = true)
|
| 313 |
+
|
| 314 |
+
def BAD {R : ℕ} (mask : Fin R → Bool) : Prop := R / 2 ≤ (hitBatches mask).card
|
| 315 |
+
|
| 316 |
+
lemma batches_partition {R : ℕ} (mask : Fin R → Bool) :
|
| 317 |
+
(hitBatches mask).card + (untouchedBatches mask).card = R := by
|
| 318 |
+
have h := Finset.card_filter_add_card_filter_not (s := Finset.univ) (fun r : Fin R => mask r = true)
|
| 319 |
+
simpa only [hitBatches, untouchedBatches, Bool.not_eq_true, Finset.card_univ, Fintype.card_fin] using h
|
| 320 |
+
|
| 321 |
+
lemma untouched_of_not_bad {R : ℕ} (mask : Fin R → Bool) (h : ¬ BAD mask) :
|
| 322 |
+
R / 2 ≤ (untouchedBatches mask).card := by
|
| 323 |
+
have hp := batches_partition mask
|
| 324 |
+
simp only [BAD, not_le] at h
|
| 325 |
+
omega
|
| 326 |
+
|
| 327 |
+
omit [Fintype C] in
|
| 328 |
+
|
| 329 |
+
theorem simple_component_designations_raw (rate : D → ℝ≥0) (J : ℕ)
|
| 330 |
+
(c : C) (v : {v : V // color v = c})
|
| 331 |
+
(hsingle : ∀ u, color u = c → u = v.val)
|
| 332 |
+
(hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c)
|
| 333 |
+
(hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ)
|
| 334 |
+
{L base delta alpha : ℝ} (hL : 10000 ≤ L)
|
| 335 |
+
(hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) =
|
| 336 |
+
L * (base + delta - alpha))
|
| 337 |
+
(hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base)
|
| 338 |
+
(ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {K : ℕ} (hK : K ≤ R / 2) :
|
| 339 |
+
|∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x
|
| 340 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤
|
| 341 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) *
|
| 342 |
+
(|delta| ^ (R / 2) + alpha ^ K +
|
| 343 |
+
∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J +
|
| 344 |
+
if BAD (touched label R c (s v) z) then 1 else 0) := by
|
| 345 |
+
by_cases hg : ¬ BAD (touched label R c (s v) z)
|
| 346 |
+
· simp only [ite_eq_right hg, add_zero]
|
| 347 |
+
exact simple_component_attenuation label R color s own rate J c v hsingle hcompat hin z
|
| 348 |
+
hL hmass hint hbase ha hd (untouched_of_not_bad _ hg) hK
|
| 349 |
+
· simp only [not_not] at hg
|
| 350 |
+
simp only [ite_eq_left hg]
|
| 351 |
+
have hn := nonsimple_component_attenuation label R color s own rate J c v z
|
| 352 |
+
hcompat hL hmass hint hbase
|
| 353 |
+
have hat : Real.exp (-(7 / 10 : ℝ) * (L * R)) ≤
|
| 354 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) := by
|
| 355 |
+
apply Real.exp_le_exp.mpr
|
| 356 |
+
have hLR : 0 ≤ L * (R : ℝ) := mul_nonneg (by linarith) (by positivity)
|
| 357 |
+
nlinarith
|
| 358 |
+
calc
|
| 359 |
+
_ ≤ ∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x|
|
| 360 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := abs_integral_le_integral_abs
|
| 361 |
+
_ ≤ _ := hn
|
| 362 |
+
_ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := hat
|
| 363 |
+
_ ≤ _ := by
|
| 364 |
+
apply le_mul_of_one_le_right (Real.exp_pos _).le
|
| 365 |
+
have he : 0 ≤ ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J := by positivity
|
| 366 |
+
have haK : 0 ≤ alpha ^ K := pow_nonneg ha K
|
| 367 |
+
have hdN : 0 ≤ |delta| ^ (R / 2) := by positivity
|
| 368 |
+
linarith
|
| 369 |
+
omit [Fintype C] in
|
| 370 |
+
|
| 371 |
+
theorem simple_component_designations (rate : D → ℝ≥0) (J : ℕ)
|
| 372 |
+
(c : C) (v : {v : V // color v = c})
|
| 373 |
+
(hsingle : ∀ u, color u = c → u = v.val)
|
| 374 |
+
(hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c)
|
| 375 |
+
(hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ)
|
| 376 |
+
{L base delta alpha : ℝ} (hL : 10000 ≤ L)
|
| 377 |
+
(hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) =
|
| 378 |
+
L * (base + delta - alpha))
|
| 379 |
+
(hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base)
|
| 380 |
+
(ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {K : ℕ} (hK : K ≤ R / 2) :
|
| 381 |
+
|∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x
|
| 382 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤
|
| 383 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) *
|
| 384 |
+
(|delta| ^ (R / 2) + alpha ^ K +
|
| 385 |
+
(if R < J then 0 else
|
| 386 |
+
∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J) +
|
| 387 |
+
if BAD (touched label R c (s v) z) then 1 else 0) := by
|
| 388 |
+
by_cases hRJ : R < J
|
| 389 |
+
· simp only [ite_eq_left hRJ, add_zero]
|
| 390 |
+
by_cases hg : ¬ BAD (touched label R c (s v) z)
|
| 391 |
+
· simp only [ite_eq_right hg, add_zero]
|
| 392 |
+
rw [simple_component_integral label R color s _ own rate J c v hsingle hcompat hin z]
|
| 393 |
+
simp_rw [overloaded_eq_empty _ hRJ, Set.compl_empty, Set.indicator_univ]
|
| 394 |
+
exact simple_singleton_attenuation _ _ (own v) (touched label R c (s v) z)
|
| 395 |
+
hL hmass hint hbase ha hd (untouched_of_not_bad _ hg) hK
|
| 396 |
+
· simp only [not_not] at hg
|
| 397 |
+
simp only [ite_eq_left hg]
|
| 398 |
+
have hn := nonsimple_component_attenuation label R color s own rate J c v z
|
| 399 |
+
hcompat hL hmass hint hbase
|
| 400 |
+
have hat : Real.exp (-(7 / 10 : ℝ) * (L * R)) ≤
|
| 401 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) := by
|
| 402 |
+
apply Real.exp_le_exp.mpr
|
| 403 |
+
have hLR : 0 ≤ L * (R : ℝ) := mul_nonneg (by linarith) (by positivity)
|
| 404 |
+
nlinarith
|
| 405 |
+
calc
|
| 406 |
+
_ ≤ ∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x|
|
| 407 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := abs_integral_le_integral_abs
|
| 408 |
+
_ ≤ _ := hn
|
| 409 |
+
_ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := hat
|
| 410 |
+
_ ≤ _ := by
|
| 411 |
+
apply le_mul_of_one_le_right (Real.exp_pos _).le
|
| 412 |
+
have haK : 0 ≤ alpha ^ K := pow_nonneg ha K
|
| 413 |
+
have hdN : 0 ≤ |delta| ^ (R / 2) := by positivity
|
| 414 |
+
linarith
|
| 415 |
+
· simpa only [ite_eq_right hRJ] using
|
| 416 |
+
simple_component_designations_raw label R color s own rate J c v hsingle
|
| 417 |
+
hcompat hin z hL hmass hint hbase ha hd hK
|
| 418 |
+
|
| 419 |
+
end SharpRamseyFive.TupleComponents
|
| 420 |
+
|
| 421 |
+
namespace SharpRamseyFive.HighMoment
|
| 422 |
+
open MeasureTheory ProbabilityTheory
|
| 423 |
+
open scoped BigOperators NNReal
|
| 424 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 425 |
+
open Classical
|
| 426 |
+
variable {D H : Type} [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H]
|
| 427 |
+
variable (R : ℕ) (s : H → Finset D) (b : ℝ) (own : H → Fin R → Bool)
|
| 428 |
+
|
| 429 |
+
noncomputable def allTrunc (J : ℕ) (ω : Fin R × D → ℕ) : ℝ :=
|
| 430 |
+
∏ d : D, lineTrunc R J (fun r => ω (r,d))
|
| 431 |
+
|
| 432 |
+
omit [DecidableEq D] in
|
| 433 |
+
lemma allTrunc_range (J : ℕ) (ω : Fin R × D → ℕ) :
|
| 434 |
+
allTrunc R J ω ∈ Set.Icc (0 : ℝ) 1 := by
|
| 435 |
+
constructor
|
| 436 |
+
· exact Finset.prod_nonneg (fun _ _ => (lineTrunc_range R J _).1)
|
| 437 |
+
· exact Finset.prod_le_one₀ (fun _ _ => (lineTrunc_range R J _).1)
|
| 438 |
+
(fun _ _ => (lineTrunc_range R J _).2)
|
| 439 |
+
|
| 440 |
+
omit [Fintype H] [DecidableEq H] in
|
| 441 |
+
omit [Fintype D] [DecidableEq D] in
|
| 442 |
+
lemma scoreTerm_abs_le (hb : b ∈ Set.Icc (0 : ℝ) 1) (h : H) (ω : Fin R × D → ℕ) :
|
| 443 |
+
|scoreTerm (s h) b (own h) (fun r d => ω (r,d))| ≤ 1 := by
|
| 444 |
+
simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm]
|
| 445 |
+
using abs_maskedTerm_le_one (s h) hb (own h) (fun _ => false) (fun r d => ω (r,d))
|
| 446 |
+
omit [Fintype H] [DecidableEq H] in
|
| 447 |
+
omit [DecidableEq D] in
|
| 448 |
+
|
| 449 |
+
lemma truncated_tuple_abs_le (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1)
|
| 450 |
+
{V : Type} [Fintype V] (f : V → H) (ω : Fin R × D → ℕ) :
|
| 451 |
+
|allTrunc R J ω * ∏ v, scoreTerm (s (f v)) b (own (f v)) (fun r d => ω (r,d))| ≤ 1 := by
|
| 452 |
+
rw [abs_mul, abs_of_nonneg (allTrunc_range R J ω).1, Finset.abs_prod]
|
| 453 |
+
exact (mul_le_of_le_one_left (by positivity) (allTrunc_range R J ω).2).trans
|
| 454 |
+
(Finset.prod_le_one₀ (fun _ _ => abs_nonneg _)
|
| 455 |
+
(fun _ _ => scoreTerm_abs_le R s b own hb _ ω))
|
| 456 |
+
|
| 457 |
+
end SharpRamseyFive.HighMoment
|
| 458 |
+
end
|
| 459 |
+
|
| 460 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/ExternalMass.lean
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.ForcedHits
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
namespace SharpRamseyFive.PoissonScore
|
| 12 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 13 |
+
variable {κ : Type*}
|
| 14 |
+
variable {κ : Type*} [Fintype κ] [DecidableEq κ]
|
| 15 |
+
section ComponentGeometry
|
| 16 |
+
variable {H : Type*} [Fintype H] [DecidableEq H]
|
| 17 |
+
omit [Fintype ι] in
|
| 18 |
+
lemma external_mass_le (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 19 |
+
{t : ℝ} (ht : 0 ≤ t) (h : H) :
|
| 20 |
+
mass rate (externalPart rate s t h) ≤ (Fintype.card H - 1 : ℕ) * t := by
|
| 21 |
+
classical
|
| 22 |
+
let K := otherComponents rate s t h
|
| 23 |
+
have hK : K ⊆ Finset.univ.erase h := by
|
| 24 |
+
intro k hk
|
| 25 |
+
simp only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] at hk
|
| 26 |
+
simp only [Finset.mem_erase, Finset.mem_univ, and_true]
|
| 27 |
+
intro he
|
| 28 |
+
subst k
|
| 29 |
+
exact hk rfl
|
| 30 |
+
have hc : K.card ≤ Fintype.card H - 1 := by
|
| 31 |
+
simpa only [Finset.card_erase_of_mem (Finset.mem_univ h), Finset.card_univ] using
|
| 32 |
+
Finset.card_le_card hK
|
| 33 |
+
calc
|
| 34 |
+
_ ≤ ∑ k ∈ K, mass rate (s h ∩ s k) := external_mass_le_sum rate s t h
|
| 35 |
+
_ ≤ K.card * t := by
|
| 36 |
+
simpa only [nsmul_eq_mul] using Finset.sum_le_card_nsmul K
|
| 37 |
+
(fun k => mass rate (s h ∩ s k)) t (by
|
| 38 |
+
intro k hk
|
| 39 |
+
apply cross_component_overlap rate s t
|
| 40 |
+
simpa only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] using hk)
|
| 41 |
+
_ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hc) ht
|
| 42 |
+
|
| 43 |
+
omit [Fintype ι] in
|
| 44 |
+
|
| 45 |
+
lemma internal_mass_lower (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 46 |
+
{t c : ℝ} (ht : 0 ≤ t) (hs : ∀ h, c ≤ mass rate (s h)) (h : H) :
|
| 47 |
+
c - (Fintype.card H - 1 : ℕ) * t ≤ mass rate (internalPart rate s t h) := by
|
| 48 |
+
have := external_mass_le rate s ht h
|
| 49 |
+
have := internal_external_mass rate s t h
|
| 50 |
+
have := hs h
|
| 51 |
+
linarith
|
| 52 |
+
|
| 53 |
+
omit [Fintype ι] [Fintype H] [DecidableEq H] in
|
| 54 |
+
lemma internal_parts_disjoint (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 55 |
+
(t : ℝ) {h k : H} (hc : (strongGraph rate s t).connectedComponentMk h ≠
|
| 56 |
+
(strongGraph rate s t).connectedComponentMk k) :
|
| 57 |
+
Disjoint (internalPart rate s t h) (internalPart rate s t k) := by
|
| 58 |
+
classical
|
| 59 |
+
apply Finset.disjoint_left.mpr
|
| 60 |
+
intro i hi hk
|
| 61 |
+
simp only [internalPart, Finset.mem_filter] at hi hk
|
| 62 |
+
exact hi.2 ⟨h, k, hi.1, hk.1, hc⟩
|
| 63 |
+
|
| 64 |
+
noncomputable def componentLabel (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 65 |
+
(t : ℝ) (i : ι) : Option (strongGraph rate s t).ConnectedComponent := by
|
| 66 |
+
classical
|
| 67 |
+
exact if hi : ∃ h, i ∈ s h then
|
| 68 |
+
if External rate s t i then none else
|
| 69 |
+
some ((strongGraph rate s t).connectedComponentMk hi.choose)
|
| 70 |
+
else none
|
| 71 |
+
|
| 72 |
+
omit [Fintype ι] [DecidableEq H] in
|
| 73 |
+
lemma componentLabel_external (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 74 |
+
(t : ℝ) {i : ι} (hi : External rate s t i) :
|
| 75 |
+
componentLabel rate s t i = none := by
|
| 76 |
+
classical
|
| 77 |
+
simp only [componentLabel, hi, ↓reduceIte]
|
| 78 |
+
split_ifs <;> rfl
|
| 79 |
+
|
| 80 |
+
omit [Fintype ι] [DecidableEq H] in
|
| 81 |
+
lemma componentLabel_internal (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 82 |
+
(t : ℝ) {h : H} {i : ι} (hi : i ∈ internalPart rate s t h) :
|
| 83 |
+
componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by
|
| 84 |
+
classical
|
| 85 |
+
simp only [internalPart, Finset.mem_filter] at hi
|
| 86 |
+
have hex : ∃ k, i ∈ s k := ⟨h, hi.1⟩
|
| 87 |
+
have he := hex.choose_spec
|
| 88 |
+
have hc : (strongGraph rate s t).connectedComponentMk hex.choose =
|
| 89 |
+
(strongGraph rate s t).connectedComponentMk h := by
|
| 90 |
+
by_contra hn
|
| 91 |
+
exact hi.2 ⟨hex.choose, h, he, hi.1, hn⟩
|
| 92 |
+
simp only [componentLabel, dite_eq_left hex, ite_eq_right hi.2, hc]
|
| 93 |
+
omit [Fintype ι] [DecidableEq H] in
|
| 94 |
+
|
| 95 |
+
lemma internalPart_iff_label (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 96 |
+
(t : ℝ) (h : H) (i : ι) :
|
| 97 |
+
i ∈ internalPart rate s t h ↔ i ∈ s h ∧
|
| 98 |
+
componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by
|
| 99 |
+
classical
|
| 100 |
+
constructor
|
| 101 |
+
· intro hi
|
| 102 |
+
exact ⟨(Finset.mem_filter.mp hi).1, componentLabel_internal rate s t hi⟩
|
| 103 |
+
· rintro ⟨hi, he⟩
|
| 104 |
+
apply Finset.mem_filter.mpr
|
| 105 |
+
refine ⟨hi, ?_⟩
|
| 106 |
+
intro hn
|
| 107 |
+
rw [componentLabel_external rate s t hn] at he
|
| 108 |
+
cases he
|
| 109 |
+
|
| 110 |
+
omit [Fintype ι] [DecidableEq H] in
|
| 111 |
+
|
| 112 |
+
lemma direction_internal_or_external (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 113 |
+
(t : ℝ) {h : H} {i : ι} (hi : i ∈ s h) :
|
| 114 |
+
componentLabel rate s t i = none ∨
|
| 115 |
+
componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by
|
| 116 |
+
classical
|
| 117 |
+
by_cases he : External rate s t i
|
| 118 |
+
· exact Or.inl (componentLabel_external rate s t he)
|
| 119 |
+
· exact Or.inr (componentLabel_internal rate s t (Finset.mem_filter.mpr ⟨hi, he⟩))
|
| 120 |
+
omit [Fintype ι] in
|
| 121 |
+
|
| 122 |
+
lemma source_internal_mass_lower (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 123 |
+
{p : ℕ} (hp : 0 < p) (hc : Fintype.card H ≤ p)
|
| 124 |
+
(hs : ∀ h, (3 / 4 : ℝ) ≤ mass rate (s h)) (h : H) :
|
| 125 |
+
(37 / 50 : ℝ) ≤ mass rate (internalPart rate s (1 / (100 * p)) h) := by
|
| 126 |
+
have ht : (0 : ℝ) ≤ 1 / (100 * p : ℝ) := by positivity
|
| 127 |
+
have hl := internal_mass_lower rate s ht hs h
|
| 128 |
+
have hh : (0 : ℝ) < p := by exact_mod_cast hp
|
| 129 |
+
have hcard : ((Fintype.card H - 1 : ℕ) : ℝ) ≤ (p : ℝ) := by
|
| 130 |
+
exact_mod_cast ((Nat.sub_le (Fintype.card H) 1).trans hc)
|
| 131 |
+
have hm : ((Fintype.card H - 1 : ℕ) : ℝ) * (1 / (100 * p)) ≤ (1 / 100 : ℝ) := by
|
| 132 |
+
calc
|
| 133 |
+
_ ≤ (p : ℝ) * (1 / (100 * p)) := mul_le_mul_of_nonneg_right hcard ht
|
| 134 |
+
_ = _ := by field_simp
|
| 135 |
+
linarith
|
| 136 |
+
|
| 137 |
+
end ComponentGeometry
|
| 138 |
+
|
| 139 |
+
end SharpRamseyFive.PoissonScore
|
| 140 |
+
|
| 141 |
+
namespace SharpRamseyFive.TupleComponents
|
| 142 |
+
open MeasureTheory ProbabilityTheory
|
| 143 |
+
open scoped BigOperators NNReal
|
| 144 |
+
open SharpRamseyFive.PoissonScore
|
| 145 |
+
open Classical
|
| 146 |
+
variable {D V C : Type} [Fintype D] [DecidableEq D]
|
| 147 |
+
[Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]
|
| 148 |
+
variable (label : D → Option C) (R : ℕ)
|
| 149 |
+
|
| 150 |
+
abbrev Block (c : Option C) := {i : Fin R × D // label i.2 = c}
|
| 151 |
+
noncomputable def fill (c : C) (z : Block label R none → ℕ)
|
| 152 |
+
(x : Block label R (some c) → ℕ) (r : Fin R) (d : D) : ℕ :=
|
| 153 |
+
if he : label d = none then z ⟨(r,d), he⟩ else
|
| 154 |
+
if hi : label d = some c then x ⟨(r,d), hi⟩ else 0
|
| 155 |
+
|
| 156 |
+
omit [Fintype D] [DecidableEq D] [Fintype C] in
|
| 157 |
+
lemma fill_restrict (c : C) (ω : Fin R × D → ℕ) {d : D}
|
| 158 |
+
(hd : label d = none ∨ label d = some c) (r : Fin R) :
|
| 159 |
+
fill label R c (fun i => ω i) (fun i => ω i) r d = ω (r,d) := by
|
| 160 |
+
rcases hd with hd | hd <;> simp [fill, hd]
|
| 161 |
+
|
| 162 |
+
noncomputable def lineTrunc (J : ℕ) (ω : Fin R → ℕ) : ℝ :=
|
| 163 |
+
if (Finset.univ.filter (fun r => ω r ≠ 0)).card < J then 1 else 0
|
| 164 |
+
|
| 165 |
+
noncomputable def blockTrunc (J : ℕ) (c : Option C) (ω : Block label R c → ℕ) : ℝ :=
|
| 166 |
+
∏ d : {d : D // label d = c}, lineTrunc R J (fun r => ω ⟨(r,d), d.property⟩)
|
| 167 |
+
|
| 168 |
+
lemma lineTrunc_range (J : ℕ) (ω : Fin R → ℕ) :
|
| 169 |
+
lineTrunc R J ω ∈ Set.Icc (0 : ℝ) 1 := by unfold lineTrunc; split_ifs <;> norm_num
|
| 170 |
+
|
| 171 |
+
omit [DecidableEq D] [Fintype C] in
|
| 172 |
+
lemma blockTrunc_range (J : ℕ) (c : Option C) (ω : Block label R c → ℕ) :
|
| 173 |
+
blockTrunc label R J c ω ∈ Set.Icc (0 : ℝ) 1 := by
|
| 174 |
+
constructor
|
| 175 |
+
· exact Finset.prod_nonneg (fun _ _ => (lineTrunc_range R J _).1)
|
| 176 |
+
· exact Finset.prod_le_one₀ (fun _ _ => (lineTrunc_range R J _).1)
|
| 177 |
+
(fun _ _ => (lineTrunc_range R J _).2)
|
| 178 |
+
|
| 179 |
+
lemma prod_fibers {A K : Type} [Fintype A] [Fintype K] [DecidableEq K]
|
| 180 |
+
(col : A → K) (f : A → ℝ) :
|
| 181 |
+
(∏ c : K, ∏ a : {a : A // col a = c}, f a) = ∏ a, f a := by
|
| 182 |
+
classical
|
| 183 |
+
calc
|
| 184 |
+
_ = ∏ c : K, ∏ a ∈ Finset.univ.filter (fun a => col a = c), f a := by
|
| 185 |
+
apply Finset.prod_congr rfl
|
| 186 |
+
intro c _
|
| 187 |
+
symm
|
| 188 |
+
exact Finset.prod_subtype _ (by simp) f
|
| 189 |
+
_ = _ := by
|
| 190 |
+
simpa using Finset.prod_fiberwise Finset.univ col f
|
| 191 |
+
|
| 192 |
+
omit [DecidableEq D] in
|
| 193 |
+
lemma trunc_split (J : ℕ) (ω : Fin R × D → ℕ) :
|
| 194 |
+
(∏ d : D, lineTrunc R J (fun r => ω (r,d))) =
|
| 195 |
+
blockTrunc label R J none (fun i => ω i) *
|
| 196 |
+
∏ c : C, blockTrunc label R J (some c) (fun i => ω i) := by
|
| 197 |
+
rw [← Fintype.prod_option (fun c => blockTrunc label R J c (fun i => ω i))]
|
| 198 |
+
exact (prod_fibers label (fun d => lineTrunc R J (fun r => ω (r,d)))).symm
|
| 199 |
+
|
| 200 |
+
omit [Fintype D] [DecidableEq D] in
|
| 201 |
+
lemma emptyIndicator_congr (s : Finset D) (ω ν : D → ℕ)
|
| 202 |
+
(he : ∀ d ∈ s, ω d = ν d) : emptyIndicator s ω = emptyIndicator s ν := by
|
| 203 |
+
have h : ω ∈ emptyEvent s ↔ ν ∈ emptyEvent s := by
|
| 204 |
+
simp only [emptyEvent, Set.mem_pi, Set.mem_singleton_iff, Finset.mem_coe]
|
| 205 |
+
exact forall₂_congr (fun d hd => by rw [he d hd])
|
| 206 |
+
by_cases hω : ω ∈ emptyEvent s
|
| 207 |
+
· simp [emptyIndicator, hω, h.mp hω]
|
| 208 |
+
· simp [emptyIndicator, hω, (not_congr h).mp hω]
|
| 209 |
+
omit [Fintype D] [DecidableEq D] in
|
| 210 |
+
|
| 211 |
+
lemma scoreTerm_congr (s : Finset D) (b : ℝ) (own : Fin R → Bool)
|
| 212 |
+
(ω ν : Fin R → D → ℕ) (he : ∀ r d, d ∈ s → ω r d = ν r d) :
|
| 213 |
+
scoreTerm s b own ω = scoreTerm s b own ν := by
|
| 214 |
+
unfold scoreTerm
|
| 215 |
+
apply Finset.prod_congr rfl
|
| 216 |
+
intro r _
|
| 217 |
+
simp only [centeredFactor, emptyIndicator_congr s (ω r) (ν r) (he r)]
|
| 218 |
+
|
| 219 |
+
variable (color : V → C) (s : V → Finset D) (b : ℝ) (own : V → Fin R → Bool)
|
| 220 |
+
|
| 221 |
+
noncomputable def componentFactor (J : ℕ) (c : C)
|
| 222 |
+
(z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : ℝ :=
|
| 223 |
+
blockTrunc label R J (some c) x *
|
| 224 |
+
∏ v : {v : V // color v = c}, scoreTerm (s v) b (own v) (fill label R c z x)
|
| 225 |
+
|
| 226 |
+
omit [DecidableEq V] in
|
| 227 |
+
omit [Fintype C] in
|
| 228 |
+
omit [DecidableEq D] in
|
| 229 |
+
lemma componentFactor_bound (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) (c : C)
|
| 230 |
+
(z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) :
|
| 231 |
+
|componentFactor label R color s b own J c z x| ≤ 1 := by
|
| 232 |
+
rw [componentFactor, abs_mul, Finset.abs_prod]
|
| 233 |
+
have htrunc : |blockTrunc label R J (some c) x| ≤ 1 := by
|
| 234 |
+
rw [abs_of_nonneg (blockTrunc_range label R J (some c) x).1]
|
| 235 |
+
exact (blockTrunc_range label R J (some c) x).2
|
| 236 |
+
refine (mul_le_of_le_one_left (Finset.prod_nonneg (fun _ _ => abs_nonneg _))
|
| 237 |
+
htrunc).trans ?_
|
| 238 |
+
apply Finset.prod_le_one₀ (fun _ _ => abs_nonneg _)
|
| 239 |
+
intro vertex _
|
| 240 |
+
simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm]
|
| 241 |
+
using abs_maskedTerm_le_one (s vertex) hb (own vertex) (fun _ => false)
|
| 242 |
+
(fill label R c z x)
|
| 243 |
+
|
| 244 |
+
omit [DecidableEq V] in
|
| 245 |
+
omit [DecidableEq D] in
|
| 246 |
+
lemma tuple_pointwise_split (J : ℕ)
|
| 247 |
+
(hcompat : ∀ v d, d ∈ s v → label d = none ∨ label d = some (color v))
|
| 248 |
+
(ω : Fin R × D → ℕ) :
|
| 249 |
+
(∏ d : D, lineTrunc R J (fun r => ω (r,d))) *
|
| 250 |
+
(∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d))) =
|
| 251 |
+
blockTrunc label R J none (fun i => ω i) *
|
| 252 |
+
∏ c : C, componentFactor label R color s b own J c
|
| 253 |
+
(fun i => ω i) (fun i => ω i) := by
|
| 254 |
+
have he (c : C) (v : {v : V // color v = c}) :
|
| 255 |
+
scoreTerm (s v) b (own v)
|
| 256 |
+
(fill label R c (fun i => ω i) (fun i => ω i)) =
|
| 257 |
+
scoreTerm (s v) b (own v) (fun r d => ω (r,d)) := by
|
| 258 |
+
apply scoreTerm_congr R
|
| 259 |
+
intro r d hd
|
| 260 |
+
apply fill_restrict label R c ω _ r
|
| 261 |
+
simpa only [v.property] using hcompat v d hd
|
| 262 |
+
simp_rw [componentFactor, he]
|
| 263 |
+
rw [Finset.prod_mul_distrib, prod_fibers color (fun v => scoreTerm (s v) b (own v) (fun r d => ω (r,d)))]
|
| 264 |
+
rw [trunc_split label R J ω]
|
| 265 |
+
ring
|
| 266 |
+
|
| 267 |
+
omit [DecidableEq V] in
|
| 268 |
+
omit [DecidableEq D] in
|
| 269 |
+
|
| 270 |
+
theorem tuple_integral_split (rate : D → ℝ≥0) (J : ℕ)
|
| 271 |
+
(hb : b ∈ Set.Icc (0 : ℝ) 1)
|
| 272 |
+
(hcompat : ∀ v d, d ∈ s v → label d = none ∨ label d = some (color v)) :
|
| 273 |
+
(∫ ω, (∏ d : D, lineTrunc R J (fun r => ω (r,d))) *
|
| 274 |
+
(∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d)))
|
| 275 |
+
∂batchMeasure (fun i : Fin R × D => rate i.2)) =
|
| 276 |
+
∫ z, blockTrunc label R J none z * ∏ c : C,
|
| 277 |
+
∫ x, componentFactor label R color s b own J c z x
|
| 278 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)
|
| 279 |
+
∂batchMeasure (fun i : Block label R none => rate i.1.2) := by
|
| 280 |
+
have he := integral_external_components (fun i : Fin R × D => rate i.2)
|
| 281 |
+
(fun i => label i.2) (blockTrunc label R J none)
|
| 282 |
+
(componentFactor label R color s b own J)
|
| 283 |
+
(fun z => by rw [abs_of_nonneg (blockTrunc_range label R J none z).1];
|
| 284 |
+
exact (blockTrunc_range label R J none z).2)
|
| 285 |
+
(componentFactor_bound label R color s b own J hb)
|
| 286 |
+
rw [← he]
|
| 287 |
+
apply integral_congr_ae
|
| 288 |
+
exact Filter.Eventually.of_forall (tuple_pointwise_split label R color s b own J hcompat)
|
| 289 |
+
|
| 290 |
+
noncomputable def strongSplit (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) : ℝ := by
|
| 291 |
+
classical
|
| 292 |
+
let G := strongGraph weight s t
|
| 293 |
+
let label := componentLabel weight s t
|
| 294 |
+
exact ∫ z, blockTrunc label R J none z * ∏ c : G.ConnectedComponent,
|
| 295 |
+
∫ x, componentFactor label R G.connectedComponentMk s b own J c z x
|
| 296 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)
|
| 297 |
+
∂batchMeasure (fun i : Block label R none => rate i.1.2)
|
| 298 |
+
|
| 299 |
+
lemma strong_tuple_integral_split (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ)
|
| 300 |
+
(hb : b ∈ Set.Icc (0 : ℝ) 1) :
|
| 301 |
+
(∫ ω, (∏ d : D, lineTrunc R J (fun r => ω (r,d))) *
|
| 302 |
+
(∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d)))
|
| 303 |
+
∂batchMeasure (fun i : Fin R × D => rate i.2)) =
|
| 304 |
+
strongSplit R s b own weight rate t J := by
|
| 305 |
+
classical
|
| 306 |
+
unfold strongSplit
|
| 307 |
+
apply tuple_integral_split _ R _ s b own rate J hb
|
| 308 |
+
intro v d hd
|
| 309 |
+
exact direction_internal_or_external weight s t hd
|
| 310 |
+
|
| 311 |
+
abbrev IntDir (c : C) := {d : D // label d = some c}
|
| 312 |
+
|
| 313 |
+
noncomputable def inside (c : C) (S : Finset D) : Finset (IntDir label c) :=
|
| 314 |
+
Finset.univ.filter (fun d => d.val ∈ S)
|
| 315 |
+
|
| 316 |
+
noncomputable def touched (_c : C) (S : Finset D) (z : Block label R none → ℕ)
|
| 317 |
+
(r : Fin R) : Bool :=
|
| 318 |
+
decide (∃ d : {d : D // label d = none}, d.val ∈ S ∧ z ⟨(r,d), d.property⟩ ≠ 0)
|
| 319 |
+
|
| 320 |
+
noncomputable def unblock (c : C) (x : Block label R (some c) → ℕ) :
|
| 321 |
+
Fin R → IntDir label c → ℕ := fun r d => x ⟨(r,d), d.property⟩
|
| 322 |
+
|
| 323 |
+
omit [Fintype C] in
|
| 324 |
+
lemma fill_empty_iff (c : C) (S : Finset D)
|
| 325 |
+
(hc : ∀ d ∈ S, label d = none ∨ label d = some c)
|
| 326 |
+
(z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) (r : Fin R) :
|
| 327 |
+
fill label R c z x r ∈ emptyEvent S ↔
|
| 328 |
+
touched label R c S z r = false ∧
|
| 329 |
+
unblock label R c x r ∈ emptyEvent (inside label c S) := by
|
| 330 |
+
simp only [emptyEvent, Set.mem_pi, Set.mem_singleton_iff, Finset.mem_coe]
|
| 331 |
+
constructor
|
| 332 |
+
· intro h
|
| 333 |
+
constructor
|
| 334 |
+
· simp only [touched, decide_eq_false_iff_not, not_exists, not_and]
|
| 335 |
+
intro d hd
|
| 336 |
+
have := h d hd
|
| 337 |
+
simpa [fill, d.property] using this
|
| 338 |
+
· intro d hd
|
| 339 |
+
have := h d (Finset.mem_filter.mp hd).2
|
| 340 |
+
simpa [fill, d.property, unblock] using this
|
| 341 |
+
· rintro ⟨he, hi⟩ d hd
|
| 342 |
+
rcases hc d hd with hd0 | hdc
|
| 343 |
+
· have hz : z ⟨(r,d), hd0⟩ = 0 := by
|
| 344 |
+
have he' : ¬ ∃ d : {d : D // label d = none},
|
| 345 |
+
d.val ∈ S ∧ z ⟨(r,d), d.property⟩ ≠ 0 := by
|
| 346 |
+
simpa only [touched, decide_eq_false_iff_not] using he
|
| 347 |
+
by_contra hn
|
| 348 |
+
exact he' ⟨⟨d,hd0⟩, hd, hn⟩
|
| 349 |
+
simpa [fill, hd0] using hz
|
| 350 |
+
· have hz := hi ⟨d,hdc⟩ (by simp [inside, hd])
|
| 351 |
+
simpa [fill, hdc, unblock] using hz
|
| 352 |
+
omit [Fintype C] in
|
| 353 |
+
|
| 354 |
+
lemma scoreTerm_eq_masked (c : C) (S : Finset D) (B : ℝ) (o : Fin R → Bool)
|
| 355 |
+
(hc : ∀ d ∈ S, label d = none ∨ label d = some c)
|
| 356 |
+
(z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) :
|
| 357 |
+
scoreTerm S B o (fill label R c z x) =
|
| 358 |
+
maskedTerm (inside label c S) B o (touched label R c S z) (unblock label R c x) := by
|
| 359 |
+
apply Finset.prod_congr rfl
|
| 360 |
+
intro r _
|
| 361 |
+
have hh := fill_empty_iff label R c S hc z x r
|
| 362 |
+
cases ho : o r <;> simp only [maskedFactor, Bool.false_eq_true, ↓reduceIte]
|
| 363 |
+
by_cases he : touched label R c S z r = true
|
| 364 |
+
· have hn : fill label R c z x r ∉ emptyEvent S := by simpa [he] using hh
|
| 365 |
+
simp [he, centeredFactor, emptyIndicator, hn]
|
| 366 |
+
· have ht : touched label R c S z r = false := Bool.eq_false_of_not_eq_true he
|
| 367 |
+
simp only [ht, true_and] at hh
|
| 368 |
+
by_cases hi : unblock label R c x r ∈ emptyEvent (inside label c S)
|
| 369 |
+
· simp [ht, centeredFactor, emptyIndicator, hi, hh.mpr hi]
|
| 370 |
+
· simp [ht, centeredFactor, emptyIndicator, hi, (not_congr hh).mpr hi]
|
| 371 |
+
|
| 372 |
+
noncomputable def blockCoords (c : C) : (Fin R × IntDir label c) ≃ Block label R (some c) where
|
| 373 |
+
toFun i := ⟨(i.1,i.2), i.2.property⟩
|
| 374 |
+
invFun i := (i.1.1, ⟨i.1.2, i.property⟩)
|
| 375 |
+
left_inv _ := rfl
|
| 376 |
+
right_inv _ := rfl
|
| 377 |
+
|
| 378 |
+
noncomputable def unblockEquiv (c : C) :
|
| 379 |
+
(Block label R (some c) → ℕ) ≃ᵐ (Fin R → IntDir label c → ℕ) :=
|
| 380 |
+
(MeasurableEquiv.piCongrLeft (fun _ : Block label R (some c) => ℕ)
|
| 381 |
+
(blockCoords label R c)).symm.trans (MeasurableEquiv.curry (Fin R) (IntDir label c) ℕ)
|
| 382 |
+
|
| 383 |
+
omit [Fintype D] [DecidableEq D] [Fintype C] [DecidableEq C] in
|
| 384 |
+
@[simp] lemma unblockEquiv_apply (c : C) (x : Block label R (some c) → ℕ) :
|
| 385 |
+
unblockEquiv label R c x = unblock label R c x := rfl
|
| 386 |
+
|
| 387 |
+
omit [Fintype C] in
|
| 388 |
+
omit [DecidableEq D] in
|
| 389 |
+
lemma measurePreserving_unblock (rate : D → ℝ≥0) (c : C) :
|
| 390 |
+
MeasurePreserving (unblockEquiv label R c)
|
| 391 |
+
(batchMeasure (fun i : Block label R (some c) => rate i.1.2))
|
| 392 |
+
(scheduleMeasure (fun d : IntDir label c => rate d) R) := by
|
| 393 |
+
exact (measurePreserving_uncurry_schedule (fun d : IntDir label c => rate d) R).symm.comp
|
| 394 |
+
(measurePreserving_piCongrLeft
|
| 395 |
+
(fun i : Block label R (some c) => poissonMeasure (rate i.1.2))
|
| 396 |
+
(blockCoords label R c)).symm
|
| 397 |
+
|
| 398 |
+
omit [DecidableEq D] [Fintype C] in
|
| 399 |
+
lemma integrable_block_bounded (rate : D → ℝ≥0) (c : Option C)
|
| 400 |
+
(f : (Block label R c → ℕ) → ℝ) (h : ∀ x, |f x| ≤ 1) :
|
| 401 |
+
Integrable f (batchMeasure (fun i : Block label R c => rate i.1.2)) := by
|
| 402 |
+
apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable 1
|
| 403 |
+
exact Filter.Eventually.of_forall (fun x => by simpa only [Real.norm_eq_abs] using h x)
|
| 404 |
+
omit [Fintype C] in
|
| 405 |
+
omit [DecidableEq D] in
|
| 406 |
+
|
| 407 |
+
lemma componentFactor_abs_le_term (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1)
|
| 408 |
+
(c : C) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ)
|
| 409 |
+
(v : {v : V // color v = c}) :
|
| 410 |
+
|componentFactor label R color s b own J c z x| ≤
|
| 411 |
+
|scoreTerm (s v) b (own v) (fill label R c z x)| := by
|
| 412 |
+
have hterm (u : V) : |scoreTerm (s u) b (own u) (fill label R c z x)| ≤ 1 := by
|
| 413 |
+
simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm]
|
| 414 |
+
using abs_maskedTerm_le_one (s u) hb (own u) (fun _ => false) (fill label R c z x)
|
| 415 |
+
rw [componentFactor, abs_mul, Finset.abs_prod]
|
| 416 |
+
have hp : (∏ u : {v : V // color v = c},
|
| 417 |
+
|scoreTerm (s u) b (own u) (fill label R c z x)|) ≤
|
| 418 |
+
|scoreTerm (s v) b (own v) (fill label R c z x)| := by
|
| 419 |
+
rw [← Finset.prod_erase_mul _ _ (Finset.mem_univ v)]
|
| 420 |
+
have he : (∏ u ∈ Finset.univ.erase v,
|
| 421 |
+
|scoreTerm (s u) b (own u) (fill label R c z x)|) ≤ 1 :=
|
| 422 |
+
Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun u _ => hterm u)
|
| 423 |
+
simpa using mul_le_mul_of_nonneg_right he (abs_nonneg
|
| 424 |
+
(scoreTerm (s v) b (own v) (fill label R c z x)))
|
| 425 |
+
calc
|
| 426 |
+
_ ≤ ∏ u : {v : V // color v = c},
|
| 427 |
+
|scoreTerm (s u) b (own u) (fill label R c z x)| := by
|
| 428 |
+
apply mul_le_of_le_one_left (Finset.prod_nonneg (fun _ _ => abs_nonneg _))
|
| 429 |
+
rw [abs_of_nonneg (blockTrunc_range label R J (some c) x).1]
|
| 430 |
+
exact (blockTrunc_range label R J (some c) x).2
|
| 431 |
+
_ ≤ _ := hp
|
| 432 |
+
|
| 433 |
+
omit [Fintype C] in
|
| 434 |
+
|
| 435 |
+
lemma component_integral_abs_le (rate : D → ℝ≥0) (J : ℕ)
|
| 436 |
+
(c : C) (v : {v : V // color v = c}) (z : Block label R none → ℕ)
|
| 437 |
+
(hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c)
|
| 438 |
+
{L lam base a : ℝ} (hL : 0 ≤ L) (ha : 0 ≤ a)
|
| 439 |
+
(hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * lam)
|
| 440 |
+
(hlam : a ≤ lam) (hbase : a ≤ base) :
|
| 441 |
+
(∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x|
|
| 442 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) ≤
|
| 443 |
+
(2 * Real.exp (-L * a)) ^ R := by
|
| 444 |
+
have hb : Real.exp (-L * base) ∈ Set.Icc (0 : ℝ) 1 :=
|
| 445 |
+
⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩
|
| 446 |
+
let f := fun w => |maskedTerm (inside label c (s v)) (Real.exp (-L * base))
|
| 447 |
+
(own v) (touched label R c (s v) z) w|
|
| 448 |
+
have he (x : Block label R (some c) → ℕ) :
|
| 449 |
+
|scoreTerm (s v) (Real.exp (-L * base)) (own v) (fill label R c z x)| =
|
| 450 |
+
f (unblockEquiv label R c x) := by
|
| 451 |
+
rw [scoreTerm_eq_masked label R c (s v) _ _ hcompat]
|
| 452 |
+
rfl
|
| 453 |
+
calc
|
| 454 |
+
_ ≤ ∫ x, f (unblockEquiv label R c x)
|
| 455 |
+
∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := by
|
| 456 |
+
apply integral_mono
|
| 457 |
+
· apply integrable_block_bounded label R rate (some c)
|
| 458 |
+
intro x
|
| 459 |
+
rw [abs_abs]
|
| 460 |
+
exact componentFactor_bound label R color s _ own J hb c z x
|
| 461 |
+
· apply integrable_block_bounded label R rate (some c)
|
| 462 |
+
intro x
|
| 463 |
+
dsimp only [f]
|
| 464 |
+
rw [abs_abs]
|
| 465 |
+
exact abs_maskedTerm_le_one _ hb _ _ _
|
| 466 |
+
· intro x
|
| 467 |
+
dsimp only
|
| 468 |
+
rw [← he x]
|
| 469 |
+
exact componentFactor_abs_le_term label R color s _ own J hb c z x v
|
| 470 |
+
_ = ∫ w, f w ∂scheduleMeasure (fun d : IntDir label c => rate d) R :=
|
| 471 |
+
(measurePreserving_unblock label R rate c).integral_comp
|
| 472 |
+
(unblockEquiv label R c).measurableEmbedding f
|
| 473 |
+
_ ≤ _ := integral_abs_maskedTerm_exp_le _ _ _ _ hL hmass hlam hbase
|
| 474 |
+
|
| 475 |
+
end SharpRamseyFive.TupleComponents
|
| 476 |
+
end
|
| 477 |
+
|
| 478 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/ForcedHits.lean
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.IntegralTypicalScoreSq
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
namespace SharpRamseyFive.PoissonScore
|
| 12 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 13 |
+
variable {κ : Type*}
|
| 14 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 15 |
+
lemma forcedHits_le_one {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) :
|
| 16 |
+
forcedHits i T ω ≤ 1 := Finset.prod_le_one₀ (fun _ _ => hitIndicator_nonneg _ _)
|
| 17 |
+
(fun _ _ => hitIndicator_le_one _ _)
|
| 18 |
+
|
| 19 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 20 |
+
lemma abs_maskedTerm_mul_forcedHits {R : ℕ} (s : Finset ι) (i : ι)
|
| 21 |
+
(T : Finset (Fin R)) (b : ℝ) (own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) :
|
| 22 |
+
|maskedTerm s b own touched ω| * forcedHits i T ω =
|
| 23 |
+
∏ r, (|maskedFactor s b (own r) (touched r) (ω r)| *
|
| 24 |
+
if r ∈ T then hitIndicator i (ω r) else 1) := by
|
| 25 |
+
simp only [maskedTerm, Finset.abs_prod, Finset.prod_mul_distrib,
|
| 26 |
+
Finset.prod_ite_mem, Finset.univ_inter, forcedHits]
|
| 27 |
+
omit [DecidableEq ι] in
|
| 28 |
+
|
| 29 |
+
lemma integral_abs_maskedTerm_forcedHits_le (rate : ι → ℝ≥0) {R : ℕ}
|
| 30 |
+
(s : Finset ι) (i : ι) (hi : i ∈ s) (T : Finset (Fin R))
|
| 31 |
+
(own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L)
|
| 32 |
+
(hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) :
|
| 33 |
+
(∫ ω, |maskedTerm s (Real.exp (-L * base)) own touched ω| * forcedHits i T ω
|
| 34 |
+
∂scheduleMeasure rate R) ≤
|
| 35 |
+
(2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ T.card := by
|
| 36 |
+
simp_rw [abs_maskedTerm_mul_forcedHits]
|
| 37 |
+
unfold scheduleMeasure
|
| 38 |
+
rw [integral_fintype_prod_eq_prod (f := fun r ω =>
|
| 39 |
+
|maskedFactor s (Real.exp (-L * base)) (own r) (touched r) ω| *
|
| 40 |
+
if r ∈ T then hitIndicator i ω else 1)]
|
| 41 |
+
calc
|
| 42 |
+
_ ≤ ∏ r, (2 * Real.exp (-L * c)) * (if r ∈ T then (rate i : ℝ) else 1) := by
|
| 43 |
+
apply Finset.prod_le_prod₀
|
| 44 |
+
· intro r _
|
| 45 |
+
apply integral_nonneg
|
| 46 |
+
intro ω
|
| 47 |
+
apply mul_nonneg (abs_nonneg _)
|
| 48 |
+
split
|
| 49 |
+
· exact hitIndicator_nonneg _ _
|
| 50 |
+
· norm_num
|
| 51 |
+
· intro r _
|
| 52 |
+
by_cases hr : r ∈ T
|
| 53 |
+
· simp only [hr, ↓reduceIte]
|
| 54 |
+
have h := integral_abs_maskedFactor_hit_le rate s i hi (own r) (touched r) hL hbase
|
| 55 |
+
have he := Real.exp_pos (-L * c)
|
| 56 |
+
have hi0 : 0 ≤ (rate i : ℝ) := (rate i).coe_nonneg
|
| 57 |
+
nlinarith
|
| 58 |
+
· simp only [hr, ↓reduceIte, mul_one]
|
| 59 |
+
exact integral_abs_maskedFactor_exp_le rate s _ _ hL hmass hlam hbase
|
| 60 |
+
_ = _ := by rw [Finset.prod_mul_distrib]; simp [Finset.prod_ite_mem]
|
| 61 |
+
|
| 62 |
+
def hitBatches {R : ℕ} (i : ι) (ω : Fin R → ι → ℕ) : Finset (Fin R) :=
|
| 63 |
+
Finset.univ.filter (fun r => ω r i ≠ 0)
|
| 64 |
+
|
| 65 |
+
def overloaded {R : ℕ} (s : Finset ι) (J : ℕ) : Set (Fin R → ι → ℕ) :=
|
| 66 |
+
{ω | ∃ i ∈ s, J ≤ (hitBatches i ω).card}
|
| 67 |
+
|
| 68 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 69 |
+
|
| 70 |
+
lemma overloaded_eq_empty {R J : ℕ} (s : Finset ι) (h : R < J) :
|
| 71 |
+
(overloaded s J : Set (Fin R → ι → ℕ)) = ∅ := by
|
| 72 |
+
apply Set.eq_empty_iff_forall_notMem.mpr
|
| 73 |
+
intro ω he
|
| 74 |
+
obtain ⟨i, hi, hJ⟩ := he
|
| 75 |
+
have hc : (hitBatches i ω).card ≤ R := by
|
| 76 |
+
simpa only [hitBatches, Finset.card_univ, Fintype.card_fin] using
|
| 77 |
+
Finset.card_le_card (Finset.filter_subset (fun r : Fin R => ω r i ≠ 0) Finset.univ)
|
| 78 |
+
omega
|
| 79 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 80 |
+
|
| 81 |
+
lemma forcedHits_eq_one_of_subset {R : ℕ} (i : ι) (T : Finset (Fin R))
|
| 82 |
+
(ω : Fin R → ι → ℕ) (h : T ⊆ hitBatches i ω) : forcedHits i T ω = 1 := by
|
| 83 |
+
apply Finset.prod_eq_one
|
| 84 |
+
intro r hr
|
| 85 |
+
rw [hitIndicator_eq]
|
| 86 |
+
have hz : ω r i ≠ 0 := (Finset.mem_filter.mp (h hr)).2
|
| 87 |
+
simp [hz]
|
| 88 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 89 |
+
|
| 90 |
+
lemma overload_indicator_le_certificates {R : ℕ} (s : Finset ι) (J : ℕ)
|
| 91 |
+
(ω : Fin R → ι → ℕ) :
|
| 92 |
+
(overloaded s J).indicator (fun _ => (1 : ℝ)) ω ≤
|
| 93 |
+
∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i T ω := by
|
| 94 |
+
have hnonneg : ∀ i, 0 ≤ ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i T ω := by
|
| 95 |
+
intro i
|
| 96 |
+
exact Finset.sum_nonneg (fun T _ => forcedHits_nonneg i T ω)
|
| 97 |
+
by_cases h : ω ∈ overloaded s J
|
| 98 |
+
· rw [Set.indicator_of_mem h]
|
| 99 |
+
obtain ⟨i, hi, hcard⟩ := h
|
| 100 |
+
obtain ⟨T, hT, hTc⟩ := Finset.exists_subset_card_eq hcard
|
| 101 |
+
have hTm : T ∈ (Finset.univ : Finset (Fin R)).powersetCard J := by
|
| 102 |
+
simp only [Finset.mem_powersetCard]
|
| 103 |
+
exact ⟨Finset.subset_univ _, hTc⟩
|
| 104 |
+
calc
|
| 105 |
+
1 = forcedHits i T ω := (forcedHits_eq_one_of_subset i T ω hT).symm
|
| 106 |
+
_ ≤ ∑ U ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i U ω :=
|
| 107 |
+
Finset.single_le_sum (fun U _ => forcedHits_nonneg i U ω) hTm
|
| 108 |
+
_ ≤ _ := Finset.single_le_sum (fun i _ => hnonneg i) hi
|
| 109 |
+
· rw [Set.indicator_of_notMem h]
|
| 110 |
+
exact Finset.sum_nonneg (fun i _ => hnonneg i)
|
| 111 |
+
omit [DecidableEq ι] in
|
| 112 |
+
|
| 113 |
+
lemma integrable_abs_maskedTerm_forcedHits (rate : ι → ℝ≥0) {R : ℕ}
|
| 114 |
+
(s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Fin R → Bool)
|
| 115 |
+
(i : ι) (T : Finset (Fin R)) :
|
| 116 |
+
Integrable (fun ω => |maskedTerm s b own touched ω| * forcedHits i T ω)
|
| 117 |
+
(scheduleMeasure rate R) := by
|
| 118 |
+
apply integrable_schedule_of_abs_le rate _ 1
|
| 119 |
+
intro ω
|
| 120 |
+
rw [abs_mul, abs_abs, abs_of_nonneg (forcedHits_nonneg i T ω)]
|
| 121 |
+
exact (mul_le_of_le_one_left (forcedHits_nonneg i T ω)
|
| 122 |
+
(abs_maskedTerm_le_one s hb own touched ω)).trans (forcedHits_le_one i T ω)
|
| 123 |
+
|
| 124 |
+
omit [DecidableEq ι] in
|
| 125 |
+
|
| 126 |
+
lemma truncation_error_raw (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (J : ℕ)
|
| 127 |
+
(own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L) (hc : 0 ≤ c)
|
| 128 |
+
(hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) :
|
| 129 |
+
(∫ ω, (overloaded s J).indicator (fun ω =>
|
| 130 |
+
|maskedTerm s (Real.exp (-L * base)) own touched ω|) ω ∂scheduleMeasure rate R) ≤
|
| 131 |
+
(2 * Real.exp (-L * c)) ^ R * ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := by
|
| 132 |
+
have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 :=
|
| 133 |
+
⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩
|
| 134 |
+
let f := fun ω => |maskedTerm s (Real.exp (-L * base)) own touched ω|
|
| 135 |
+
have hf (i : ι) (T : Finset (Fin R)) := integrable_abs_maskedTerm_forcedHits rate s hb own touched i T
|
| 136 |
+
have hpoint (ω) : (overloaded s J).indicator f ω ≤
|
| 137 |
+
∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, f ω * forcedHits i T ω := by
|
| 138 |
+
have hh := mul_le_mul_of_nonneg_left (overload_indicator_le_certificates s J ω) (abs_nonneg
|
| 139 |
+
(maskedTerm s (Real.exp (-L * base)) own touched ω))
|
| 140 |
+
by_cases he : ω ∈ overloaded s J
|
| 141 |
+
· simpa [he, f, Finset.mul_sum] using hh
|
| 142 |
+
· simpa [he, f, Finset.mul_sum] using hh
|
| 143 |
+
calc
|
| 144 |
+
_ ≤ ∫ ω, ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J,
|
| 145 |
+
f ω * forcedHits i T ω ∂scheduleMeasure rate R := by
|
| 146 |
+
apply integral_mono
|
| 147 |
+
· apply integrable_schedule_of_abs_le rate _ 1
|
| 148 |
+
intro ω
|
| 149 |
+
by_cases h : ω ∈ overloaded s J
|
| 150 |
+
· simpa [h] using abs_maskedTerm_le_one s hb own touched ω
|
| 151 |
+
· simp [h]
|
| 152 |
+
· exact integrable_finsetSum _ (fun i _ => integrable_finsetSum _ (fun T _ => hf i T))
|
| 153 |
+
· exact hpoint
|
| 154 |
+
_ = ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J,
|
| 155 |
+
∫ ω, f ω * forcedHits i T ω ∂scheduleMeasure rate R := by
|
| 156 |
+
rw [integral_finsetSum _ (fun i _ => integrable_finsetSum _ (fun T _ => hf i T))]
|
| 157 |
+
apply Finset.sum_congr rfl
|
| 158 |
+
intro i hi
|
| 159 |
+
rw [integral_finsetSum _ (fun T _ => hf i T)]
|
| 160 |
+
_ ≤ ∑ i ∈ s, (2 * Real.exp (-L * c)) ^ R * ((R : ℝ) * (rate i : ℝ)) ^ J := by
|
| 161 |
+
apply Finset.sum_le_sum
|
| 162 |
+
intro i hi
|
| 163 |
+
calc
|
| 164 |
+
_ ≤ ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J,
|
| 165 |
+
(2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J := by
|
| 166 |
+
apply Finset.sum_le_sum
|
| 167 |
+
intro T hT
|
| 168 |
+
have hTJ := (Finset.mem_powersetCard.mp hT).2
|
| 169 |
+
simpa only [hTJ] using integral_abs_maskedTerm_forcedHits_le rate s i hi T
|
| 170 |
+
own touched hL hmass hlam hbase
|
| 171 |
+
_ = (R.choose J : ℝ) * ((2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J) := by simp
|
| 172 |
+
_ ≤ _ := by
|
| 173 |
+
have hchoose : (R.choose J : ℝ) ≤ (R : ℝ) ^ J := by exact_mod_cast Nat.choose_le_pow R J
|
| 174 |
+
calc
|
| 175 |
+
_ ≤ (R : ℝ) ^ J * ((2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J) :=
|
| 176 |
+
mul_le_mul_of_nonneg_right hchoose (by positivity)
|
| 177 |
+
_ = _ := by rw [mul_pow]; ring
|
| 178 |
+
_ = _ := (Finset.mul_sum _ _ _).symm
|
| 179 |
+
omit [DecidableEq ι] in
|
| 180 |
+
|
| 181 |
+
lemma truncation_error (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (J : ℕ)
|
| 182 |
+
(own touched : Fin R → Bool) {L lam base : ℝ} (hL : 10000 ≤ L)
|
| 183 |
+
(hmass : mass rate s = L * lam) (hlam : (37 / 50 : ℝ) ≤ lam)
|
| 184 |
+
(hbase : (37 / 50 : ℝ) ≤ base) :
|
| 185 |
+
(∫ ω, (overloaded s J).indicator (fun ω =>
|
| 186 |
+
|maskedTerm s (Real.exp (-L * base)) own touched ω|) ω ∂scheduleMeasure rate R) ≤
|
| 187 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) *
|
| 188 |
+
∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := by
|
| 189 |
+
have hraw := truncation_error_raw rate s J own touched (show 0 ≤ L by linarith)
|
| 190 |
+
(show (0 : ℝ) ≤ 37 / 50 by norm_num) hmass hlam hbase
|
| 191 |
+
apply hraw.trans
|
| 192 |
+
apply mul_le_mul_of_nonneg_right _ (Finset.sum_nonneg (fun _ _ => by positivity))
|
| 193 |
+
calc
|
| 194 |
+
(2 * Real.exp (-L * (37 / 50 : ℝ))) ^ R ≤
|
| 195 |
+
(2 * L * Real.exp (-L * (37 / 50 : ℝ))) ^ R := by
|
| 196 |
+
apply pow_le_pow_left₀ (by positivity)
|
| 197 |
+
have := Real.exp_pos (-L * (37 / 50 : ℝ))
|
| 198 |
+
nlinarith
|
| 199 |
+
_ ≤ _ := by simpa only [neg_mul, mul_comm L (37 / 50 : ℝ)] using two_mul_score_attenuation hL R
|
| 200 |
+
omit [DecidableEq ι] in
|
| 201 |
+
|
| 202 |
+
lemma abs_integral_compl_indicator_le (rate : ι → ℝ≥0) {R : ℕ}
|
| 203 |
+
(s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Fin R → Bool)
|
| 204 |
+
(E : Set (Fin R → ι → ℕ)) :
|
| 205 |
+
|∫ ω, Eᶜ.indicator (maskedTerm s b own touched) ω ∂scheduleMeasure rate R| ≤
|
| 206 |
+
|∫ ω, maskedTerm s b own touched ω ∂scheduleMeasure rate R| +
|
| 207 |
+
∫ ω, E.indicator (fun ω => |maskedTerm s b own touched ω|) ω ∂scheduleMeasure rate R := by
|
| 208 |
+
have hf := integrable_schedule_of_abs_le rate _ 1 (abs_maskedTerm_le_one s hb own touched)
|
| 209 |
+
have hEf : Integrable (E.indicator (maskedTerm s b own touched)) (scheduleMeasure rate R) := by
|
| 210 |
+
apply integrable_schedule_of_abs_le rate _ 1
|
| 211 |
+
intro ω
|
| 212 |
+
by_cases h : ω ∈ E
|
| 213 |
+
· simpa [h] using abs_maskedTerm_le_one s hb own touched ω
|
| 214 |
+
· simp [h]
|
| 215 |
+
have heq : Eᶜ.indicator (maskedTerm s b own touched) =
|
| 216 |
+
fun ω => maskedTerm s b own touched ω - E.indicator (maskedTerm s b own touched) ω := by
|
| 217 |
+
funext ω
|
| 218 |
+
by_cases h : ω ∈ E <;> simp [h]
|
| 219 |
+
rw [heq, integral_sub hf hEf]
|
| 220 |
+
apply (abs_sub _ _).trans
|
| 221 |
+
apply add_le_add le_rfl
|
| 222 |
+
have habs : (fun ω => |E.indicator (maskedTerm s b own touched) ω|) =
|
| 223 |
+
(E.indicator (fun ω => |maskedTerm s b own touched ω|)) := by
|
| 224 |
+
funext ω
|
| 225 |
+
by_cases h : ω ∈ E <;> simp [h]
|
| 226 |
+
rw [← habs]
|
| 227 |
+
exact abs_integral_le_integral_abs
|
| 228 |
+
|
| 229 |
+
omit [DecidableEq ι] in
|
| 230 |
+
|
| 231 |
+
lemma simple_singleton_truncated (rate : ι → ℝ≥0) {R : ℕ}
|
| 232 |
+
(s : Finset ι) (J : ℕ) (own touched : Fin R → Bool) {L base delta alpha : ℝ}
|
| 233 |
+
(hL : 10000 ≤ L) (hmass : mass rate s = L * (base + delta - alpha))
|
| 234 |
+
(hinternal : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base)
|
| 235 |
+
(ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ}
|
| 236 |
+
(hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) :
|
| 237 |
+
|∫ ω, (overloaded s J)ᶜ.indicator
|
| 238 |
+
(maskedTerm s (Real.exp (-L * base)) own touched) ω ∂scheduleMeasure rate R| ≤
|
| 239 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) *
|
| 240 |
+
(|delta| ^ N + alpha ^ K + ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J) := by
|
| 241 |
+
have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 :=
|
| 242 |
+
⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩
|
| 243 |
+
calc
|
| 244 |
+
_ ≤ _ := abs_integral_compl_indicator_le rate s hb own touched (overloaded s J)
|
| 245 |
+
_ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K) +
|
| 246 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) * ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J :=
|
| 247 |
+
add_le_add (simple_singleton_attenuation rate s own touched hL hmass hinternal hbase ha hd hN hK)
|
| 248 |
+
(truncation_error rate s J own touched hL hmass hinternal hbase)
|
| 249 |
+
_ = _ := by ring
|
| 250 |
+
|
| 251 |
+
omit [DecidableEq ι] in
|
| 252 |
+
lemma measurePreserving_uncurry_schedule (rate : ι → ℝ≥0) (R : ℕ) :
|
| 253 |
+
MeasurePreserving (MeasurableEquiv.curry (Fin R) ι ℕ).symm
|
| 254 |
+
(scheduleMeasure rate R) (batchMeasure (fun p : Fin R × ι => rate p.2)) := by
|
| 255 |
+
refine ⟨(MeasurableEquiv.curry (Fin R) ι ℕ).symm.measurable, ?_⟩
|
| 256 |
+
simpa only [Measure.infinitePi_eq_pi, scheduleMeasure, batchMeasure] using
|
| 257 |
+
Measure.infinitePi_map_curry_symm (fun (_ : Fin R) i => poissonMeasure (rate i))
|
| 258 |
+
|
| 259 |
+
variable {κ : Type*} [Fintype κ] [DecidableEq κ]
|
| 260 |
+
|
| 261 |
+
noncomputable def partitionEquiv (label : ι → κ) :
|
| 262 |
+
(ι → ℕ) ≃ᵐ (∀ c : κ, {i : ι // label i = c} → ℕ) :=
|
| 263 |
+
(MeasurableEquiv.piCongrLeft (fun _ : ι => ℕ) (Equiv.sigmaFiberEquiv label)).symm.trans
|
| 264 |
+
(MeasurableEquiv.piCurry (fun (c : κ) (_ : {i : ι // label i = c}) => ℕ))
|
| 265 |
+
|
| 266 |
+
omit [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] in
|
| 267 |
+
@[simp] lemma partitionEquiv_apply (label : ι → κ) (ω : ι → ℕ) (c : κ)
|
| 268 |
+
(i : {i : ι // label i = c}) : partitionEquiv label ω c i = ω i := rfl
|
| 269 |
+
|
| 270 |
+
omit [DecidableEq ι] in
|
| 271 |
+
lemma measurePreserving_partition (rate : ι → ℝ≥0) (label : ι → κ) :
|
| 272 |
+
MeasurePreserving (partitionEquiv label) (batchMeasure rate)
|
| 273 |
+
(Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))) := by
|
| 274 |
+
have hc : MeasurePreserving
|
| 275 |
+
(MeasurableEquiv.piCurry (fun (c : κ) (_ : {i : ι // label i = c}) => ℕ))
|
| 276 |
+
(Measure.pi (fun p : (c : κ) × {i : ι // label i = c} => poissonMeasure (rate p.2)))
|
| 277 |
+
(Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))) := by
|
| 278 |
+
refine ⟨(MeasurableEquiv.piCurry _).measurable, ?_⟩
|
| 279 |
+
simpa only [Measure.infinitePi_eq_pi, batchMeasure] using
|
| 280 |
+
Measure.infinitePi_map_piCurry (fun (c : κ) (i : {i : ι // label i = c}) =>
|
| 281 |
+
poissonMeasure (rate i))
|
| 282 |
+
exact hc.comp ((measurePreserving_piCongrLeft (fun i => poissonMeasure (rate i))
|
| 283 |
+
(Equiv.sigmaFiberEquiv label)).symm)
|
| 284 |
+
|
| 285 |
+
omit [DecidableEq ι] in
|
| 286 |
+
|
| 287 |
+
lemma integral_partition_prod (rate : ι → ℝ≥0) (label : ι → κ)
|
| 288 |
+
(f : ∀ c : κ, ({i : ι // label i = c} → ℕ) → ℝ) :
|
| 289 |
+
(∫ ω, ∏ c, f c (fun i => ω i) ∂batchMeasure rate) =
|
| 290 |
+
∏ c, ∫ ω, f c ω ∂batchMeasure (fun i : {i : ι // label i = c} => rate i) := by
|
| 291 |
+
calc
|
| 292 |
+
_ = ∫ ω, ∏ c, f c (ω c) ∂Measure.pi
|
| 293 |
+
(fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i)) :=
|
| 294 |
+
(measurePreserving_partition rate label).integral_comp
|
| 295 |
+
(partitionEquiv label).measurableEmbedding _
|
| 296 |
+
_ = _ := integral_fintype_prod_eq_prod _
|
| 297 |
+
|
| 298 |
+
noncomputable def externalEquiv (label : ι → Option κ) :
|
| 299 |
+
(ι → ℕ) ≃ᵐ ((∀ c : κ, {i : ι // label i = some c} → ℕ) ×
|
| 300 |
+
({i : ι // label i = none} → ℕ)) :=
|
| 301 |
+
(partitionEquiv label).trans (MeasurableEquiv.piOptionEquivProd
|
| 302 |
+
(fun c : Option κ => {i : ι // label i = c} → ℕ))
|
| 303 |
+
omit [DecidableEq ι] in
|
| 304 |
+
|
| 305 |
+
lemma measurePreserving_external (rate : ι → ℝ≥0) (label : ι → Option κ) :
|
| 306 |
+
MeasurePreserving (externalEquiv label) (batchMeasure rate)
|
| 307 |
+
((Measure.pi (fun c : κ => batchMeasure
|
| 308 |
+
(fun i : {i : ι // label i = some c} => rate i))).prod
|
| 309 |
+
(batchMeasure (fun i : {i : ι // label i = none} => rate i))) := by
|
| 310 |
+
have h : MeasurePreserving
|
| 311 |
+
(MeasurableEquiv.piOptionEquivProd
|
| 312 |
+
(fun c : Option κ => {i : ι // label i = c} → ℕ)).symm
|
| 313 |
+
((Measure.pi (fun c : κ => batchMeasure
|
| 314 |
+
(fun i : {i : ι // label i = some c} => rate i))).prod
|
| 315 |
+
(batchMeasure (fun i : {i : ι // label i = none} => rate i)))
|
| 316 |
+
(Measure.pi (fun c : Option κ => batchMeasure
|
| 317 |
+
(fun i : {i : ι // label i = c} => rate i))) :=
|
| 318 |
+
⟨(MeasurableEquiv.piOptionEquivProd _).symm.measurable,
|
| 319 |
+
Measure.pi_map_piOptionEquivProd (fun c : Option κ =>
|
| 320 |
+
batchMeasure (fun i : {i : ι // label i = c} => rate i))⟩
|
| 321 |
+
exact h.symm.comp (measurePreserving_partition rate label)
|
| 322 |
+
|
| 323 |
+
omit [DecidableEq ι] in
|
| 324 |
+
|
| 325 |
+
lemma integral_external_components (rate : ι → ℝ≥0) (label : ι → Option κ)
|
| 326 |
+
(weight : ({i : ι // label i = none} → ℕ) → ℝ)
|
| 327 |
+
(f : ∀ c : κ, ({i : ι // label i = none} → ℕ) →
|
| 328 |
+
({i : ι // label i = some c} → ℕ) → ℝ)
|
| 329 |
+
(hw : ∀ z, |weight z| ≤ 1) (hf : ∀ c z x, |f c z x| ≤ 1) :
|
| 330 |
+
(∫ ω, weight (fun i => ω i) * ∏ c, f c (fun i => ω i) (fun i => ω i)
|
| 331 |
+
∂batchMeasure rate) =
|
| 332 |
+
∫ z, weight z * ∏ c, ∫ x, f c z x
|
| 333 |
+
∂batchMeasure (fun i : {i : ι // label i = some c} => rate i)
|
| 334 |
+
∂batchMeasure (fun i : {i : ι // label i = none} => rate i) := by
|
| 335 |
+
let μ := Measure.pi (fun c : κ => batchMeasure
|
| 336 |
+
(fun i : {i : ι // label i = some c} => rate i))
|
| 337 |
+
let ν := batchMeasure (fun i : {i : ι // label i = none} => rate i)
|
| 338 |
+
let F : (∀ c : κ, {i : ι // label i = some c} → ℕ) ×
|
| 339 |
+
({i : ι // label i = none} → ℕ) → ℝ :=
|
| 340 |
+
fun p => weight p.2 * ∏ c, f c p.2 (p.1 c)
|
| 341 |
+
have hF : Integrable F (μ.prod ν) := by
|
| 342 |
+
apply Integrable.of_bound (measurable_of_countable F).aestronglyMeasurable 1
|
| 343 |
+
apply Filter.Eventually.of_forall
|
| 344 |
+
intro p
|
| 345 |
+
simp only [F, Real.norm_eq_abs, abs_mul, Finset.abs_prod]
|
| 346 |
+
exact (mul_le_of_le_one_left (by positivity) (hw _)).trans
|
| 347 |
+
(Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => hf _ _ _))
|
| 348 |
+
calc
|
| 349 |
+
_ = ∫ p, F p ∂μ.prod ν := (measurePreserving_external rate label).integral_comp
|
| 350 |
+
(externalEquiv label).measurableEmbedding F
|
| 351 |
+
_ = ∫ z, ∫ x, weight z * ∏ c, f c z (x c) ∂μ ∂ν :=
|
| 352 |
+
integral_prod_symm F hF
|
| 353 |
+
_ = _ := by
|
| 354 |
+
apply integral_congr_ae
|
| 355 |
+
apply Filter.Eventually.of_forall
|
| 356 |
+
intro z
|
| 357 |
+
dsimp only
|
| 358 |
+
rw [integral_const_mul]
|
| 359 |
+
congr 1
|
| 360 |
+
exact integral_fintype_prod_eq_prod _
|
| 361 |
+
|
| 362 |
+
section ComponentGeometry
|
| 363 |
+
|
| 364 |
+
variable {H : Type*} [Fintype H] [DecidableEq H]
|
| 365 |
+
|
| 366 |
+
noncomputable def strongGraph (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) :
|
| 367 |
+
SimpleGraph H where
|
| 368 |
+
Adj h k := h ≠ k ∧ t < mass rate (s h ∩ s k)
|
| 369 |
+
symm := ⟨by
|
| 370 |
+
intro h k hk
|
| 371 |
+
exact ⟨hk.1.symm, by simpa only [Finset.inter_comm] using hk.2⟩⟩
|
| 372 |
+
loopless := ⟨by intro h hh; exact hh.1 rfl⟩
|
| 373 |
+
|
| 374 |
+
omit [Fintype ι] [Fintype H] [DecidableEq H] in
|
| 375 |
+
lemma cross_component_overlap (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ)
|
| 376 |
+
{h k : H} (hd : (strongGraph rate s t).connectedComponentMk h ≠
|
| 377 |
+
(strongGraph rate s t).connectedComponentMk k) :
|
| 378 |
+
mass rate (s h ∩ s k) ≤ t := by
|
| 379 |
+
by_contra hn
|
| 380 |
+
have hk : h ≠ k := by intro e; exact hd (congrArg _ e)
|
| 381 |
+
exact hd (SimpleGraph.ConnectedComponent.connectedComponentMk_eq_of_adj
|
| 382 |
+
(G := strongGraph rate s t) ⟨hk, lt_of_not_ge hn⟩)
|
| 383 |
+
|
| 384 |
+
def External (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (i : ι) : Prop :=
|
| 385 |
+
∃ h k : H, i ∈ s h ∧ i ∈ s k ∧
|
| 386 |
+
(strongGraph rate s t).connectedComponentMk h ≠
|
| 387 |
+
(strongGraph rate s t).connectedComponentMk k
|
| 388 |
+
|
| 389 |
+
omit [Fintype ι] [Fintype H] [DecidableEq H] in
|
| 390 |
+
lemma external_iff_other (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ)
|
| 391 |
+
{h : H} {i : ι} (hi : i ∈ s h) :
|
| 392 |
+
External rate s t i ↔ ∃ k : H, i ∈ s k ∧
|
| 393 |
+
(strongGraph rate s t).connectedComponentMk h ≠
|
| 394 |
+
(strongGraph rate s t).connectedComponentMk k := by
|
| 395 |
+
classical
|
| 396 |
+
constructor
|
| 397 |
+
· rintro ⟨u, v, hu, hv, huv⟩
|
| 398 |
+
by_cases e : (strongGraph rate s t).connectedComponentMk h =
|
| 399 |
+
(strongGraph rate s t).connectedComponentMk u
|
| 400 |
+
· exact ⟨v, hv, by simpa only [e] using huv⟩
|
| 401 |
+
· exact ⟨u, hu, e⟩
|
| 402 |
+
· rintro ⟨k, hk, hd⟩
|
| 403 |
+
exact ⟨h, k, hi, hk, hd⟩
|
| 404 |
+
|
| 405 |
+
noncomputable def externalPart (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 406 |
+
(t : ℝ) (h : H) : Finset ι := by
|
| 407 |
+
classical
|
| 408 |
+
exact (s h).filter (External rate s t)
|
| 409 |
+
|
| 410 |
+
noncomputable def internalPart (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 411 |
+
(t : ℝ) (h : H) : Finset ι := by
|
| 412 |
+
classical
|
| 413 |
+
exact (s h).filter (fun i => ¬ External rate s t i)
|
| 414 |
+
|
| 415 |
+
omit [Fintype ι] [Fintype H] [DecidableEq H] in
|
| 416 |
+
lemma internal_external_mass (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 417 |
+
(t : ℝ) (h : H) :
|
| 418 |
+
mass rate (externalPart rate s t h) + mass rate (internalPart rate s t h) =
|
| 419 |
+
mass rate (s h) := by
|
| 420 |
+
classical
|
| 421 |
+
exact Finset.sum_filter_add_sum_filter_not _ _ _
|
| 422 |
+
|
| 423 |
+
noncomputable def otherComponents (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 424 |
+
(t : ℝ) (h : H) : Finset H := by
|
| 425 |
+
classical
|
| 426 |
+
exact Finset.univ.filter (fun k =>
|
| 427 |
+
(strongGraph rate s t).connectedComponentMk h ≠
|
| 428 |
+
(strongGraph rate s t).connectedComponentMk k)
|
| 429 |
+
|
| 430 |
+
omit [Fintype ι] [DecidableEq H] in
|
| 431 |
+
|
| 432 |
+
lemma external_mass_le_sum (rate : ι → ℝ≥0) (s : H → Finset ι)
|
| 433 |
+
(t : ℝ) (h : H) :
|
| 434 |
+
mass rate (externalPart rate s t h) ≤
|
| 435 |
+
∑ k ∈ otherComponents rate s t h, mass rate (s h ∩ s k) := by
|
| 436 |
+
classical
|
| 437 |
+
let K := otherComponents rate s t h
|
| 438 |
+
have hp (i : ι) (hi : i ∈ s h) :
|
| 439 |
+
(if External rate s t i then (rate i : ℝ) else 0) ≤
|
| 440 |
+
∑ k ∈ K, if i ∈ s k then (rate i : ℝ) else 0 := by
|
| 441 |
+
split_ifs with he
|
| 442 |
+
· obtain ⟨k, hk, hd⟩ := (external_iff_other rate s t hi).mp he
|
| 443 |
+
have hkK : k ∈ K := by
|
| 444 |
+
simpa only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] using hd
|
| 445 |
+
simpa only [ite_eq_left hk] using
|
| 446 |
+
(Finset.single_le_sum (f := fun j : H => if i ∈ s j then (rate i : ℝ) else 0)
|
| 447 |
+
(fun j (_ : j ∈ K) => by split_ifs <;> positivity) hkK :
|
| 448 |
+
(if i ∈ s k then (rate i : ℝ) else 0) ≤
|
| 449 |
+
∑ j ∈ K, if i ∈ s j then (rate i : ℝ) else 0)
|
| 450 |
+
· exact Finset.sum_nonneg (by intro k hk; split_ifs <;> positivity)
|
| 451 |
+
calc
|
| 452 |
+
_ = ∑ i ∈ s h, if External rate s t i then (rate i : ℝ) else 0 := by
|
| 453 |
+
simp only [externalPart, mass, Finset.sum_filter]
|
| 454 |
+
_ ≤ ∑ i ∈ s h, ∑ k ∈ K, if i ∈ s k then (rate i : ℝ) else 0 :=
|
| 455 |
+
Finset.sum_le_sum hp
|
| 456 |
+
_ = ∑ k ∈ K, mass rate (s h ∩ s k) := by
|
| 457 |
+
rw [Finset.sum_comm]
|
| 458 |
+
apply Finset.sum_congr rfl
|
| 459 |
+
intro k hk
|
| 460 |
+
rw [mass, ← Finset.filter_mem_eq_inter, Finset.sum_filter]
|
| 461 |
+
_ = _ := rfl
|
| 462 |
+
|
| 463 |
+
end ComponentGeometry
|
| 464 |
+
end SharpRamseyFive.PoissonScore
|
| 465 |
+
end
|
| 466 |
+
|
| 467 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/HighMoments.lean
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
open MeasureTheory ProbabilityTheory
|
| 9 |
+
open scoped BigOperators NNReal
|
| 10 |
+
|
| 11 |
+
namespace SharpRamseyFive.PoissonScore
|
| 12 |
+
|
| 13 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 14 |
+
|
| 15 |
+
noncomputable def batchMeasure (rate : ι → ℝ≥0) : Measure (ι → ℕ) :=
|
| 16 |
+
Measure.pi (fun i => poissonMeasure (rate i))
|
| 17 |
+
|
| 18 |
+
instance flat_HighMomentRecovered_1 (rate : ι → ℝ≥0) : IsProbabilityMeasure (batchMeasure rate) := by
|
| 19 |
+
unfold batchMeasure
|
| 20 |
+
infer_instance
|
| 21 |
+
|
| 22 |
+
def emptyEvent (s : Finset ι) : Set (ι → ℕ) :=
|
| 23 |
+
(s : Set ι).pi (fun _ => {0})
|
| 24 |
+
|
| 25 |
+
noncomputable def emptyIndicator (s : Finset ι) (ω : ι → ℕ) : ℝ :=
|
| 26 |
+
(emptyEvent s).indicator (fun _ => 1) ω
|
| 27 |
+
|
| 28 |
+
noncomputable def mass (rate : ι → ℝ≥0) (s : Finset ι) : ℝ :=
|
| 29 |
+
∑ i ∈ s, (rate i : ℝ)
|
| 30 |
+
|
| 31 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 32 |
+
lemma measurableSet_emptyEvent (s : Finset ι) : MeasurableSet (emptyEvent s) := by
|
| 33 |
+
exact MeasurableSet.pi (s.finite_toSet.countable) (fun _ _ => measurableSet_singleton 0)
|
| 34 |
+
|
| 35 |
+
omit [DecidableEq ι] in
|
| 36 |
+
lemma measure_emptyEvent (rate : ι → ℝ≥0) (s : Finset ι) :
|
| 37 |
+
batchMeasure rate (emptyEvent s) = ENNReal.ofReal (Real.exp (-mass rate s)) := by
|
| 38 |
+
rw [batchMeasure, emptyEvent, Measure.pi_pi_finset]
|
| 39 |
+
simp_rw [poissonMeasure_singleton, pow_zero, Nat.factorial_zero, Nat.cast_one,
|
| 40 |
+
mul_one, div_one]
|
| 41 |
+
rw [← ENNReal.ofReal_prod_of_nonneg (fun _ _ => (Real.exp_pos _).le),
|
| 42 |
+
← Real.exp_sum, Finset.sum_neg_distrib]
|
| 43 |
+
rfl
|
| 44 |
+
omit [DecidableEq ι] in
|
| 45 |
+
|
| 46 |
+
lemma integral_emptyIndicator (rate : ι → ℝ≥0) (s : Finset ι) :
|
| 47 |
+
∫ ω, emptyIndicator s ω ∂batchMeasure rate = Real.exp (-mass rate s) := by
|
| 48 |
+
simp only [emptyIndicator]
|
| 49 |
+
rw [integral_indicator_const _ (measurableSet_emptyEvent s),
|
| 50 |
+
Measure.real, measure_emptyEvent, ENNReal.toReal_ofReal (Real.exp_pos _).le]
|
| 51 |
+
simp
|
| 52 |
+
omit [DecidableEq ι] in
|
| 53 |
+
|
| 54 |
+
lemma integrable_emptyIndicator (rate : ι → ℝ≥0) (s : Finset ι) :
|
| 55 |
+
Integrable (emptyIndicator s) (batchMeasure rate) :=
|
| 56 |
+
(integrable_const (1 : ℝ)).indicator (measurableSet_emptyEvent s)
|
| 57 |
+
|
| 58 |
+
omit [Fintype ι] in
|
| 59 |
+
lemma emptyIndicator_mul (s t : Finset ι) (ω : ι → ℕ) :
|
| 60 |
+
emptyIndicator s ω * emptyIndicator t ω = emptyIndicator (s ∪ t) ω := by
|
| 61 |
+
have hu : emptyEvent (s ∪ t) = emptyEvent s ∩ emptyEvent t := by
|
| 62 |
+
ext x
|
| 63 |
+
simp [emptyEvent, Set.mem_pi, or_imp, forall_and]
|
| 64 |
+
rw [emptyIndicator, emptyIndicator, emptyIndicator, hu]
|
| 65 |
+
by_cases hs : ω ∈ emptyEvent s <;> by_cases ht : ω ∈ emptyEvent t <;>
|
| 66 |
+
simp [hs, ht]
|
| 67 |
+
|
| 68 |
+
omit [Fintype ι] in
|
| 69 |
+
lemma mass_union_inter (rate : ι → ℝ≥0) (s t : Finset ι) :
|
| 70 |
+
mass rate (s ∪ t) + mass rate (s ∩ t) = mass rate s + mass rate t := by
|
| 71 |
+
exact Finset.sum_union_inter
|
| 72 |
+
|
| 73 |
+
noncomputable def centeredFactor (s : Finset ι) (b : ℝ) (ω : ι → ℕ) : ℝ :=
|
| 74 |
+
emptyIndicator s ω - b
|
| 75 |
+
omit [DecidableEq ι] in
|
| 76 |
+
|
| 77 |
+
lemma integrable_centeredFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) :
|
| 78 |
+
Integrable (centeredFactor s b) (batchMeasure rate) :=
|
| 79 |
+
(integrable_emptyIndicator rate s).sub (integrable_const b)
|
| 80 |
+
omit [DecidableEq ι] in
|
| 81 |
+
|
| 82 |
+
lemma integral_centeredFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) :
|
| 83 |
+
∫ ω, centeredFactor s b ω ∂batchMeasure rate = Real.exp (-mass rate s) - b := by
|
| 84 |
+
simp only [centeredFactor]
|
| 85 |
+
rw [integral_sub (integrable_emptyIndicator rate s)
|
| 86 |
+
(integrable_const b), integral_emptyIndicator]
|
| 87 |
+
simp
|
| 88 |
+
|
| 89 |
+
lemma integral_centeredFactor_mul (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) :
|
| 90 |
+
(∫ ω, centeredFactor s b ω * centeredFactor t b ω ∂batchMeasure rate) =
|
| 91 |
+
(Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b) +
|
| 92 |
+
Real.exp (-(mass rate s + mass rate t)) *
|
| 93 |
+
(Real.exp (mass rate (s ∩ t)) - 1) := by
|
| 94 |
+
have he : (fun ω => centeredFactor s b ω * centeredFactor t b ω) =
|
| 95 |
+
fun ω => emptyIndicator (s ∪ t) ω - b * emptyIndicator s ω -
|
| 96 |
+
b * emptyIndicator t ω + b ^ 2 := by
|
| 97 |
+
funext ω
|
| 98 |
+
rw [centeredFactor, centeredFactor]
|
| 99 |
+
have := emptyIndicator_mul s t ω
|
| 100 |
+
nlinarith [this]
|
| 101 |
+
rw [he]
|
| 102 |
+
have hs := integrable_emptyIndicator rate s
|
| 103 |
+
have ht := integrable_emptyIndicator rate t
|
| 104 |
+
have hu := integrable_emptyIndicator rate (s ∪ t)
|
| 105 |
+
have h1 := integral_sub hu (hs.const_mul b)
|
| 106 |
+
have h2 := integral_sub (hu.sub (hs.const_mul b)) (ht.const_mul b)
|
| 107 |
+
have h3 := integral_add ((hu.sub (hs.const_mul b)).sub (ht.const_mul b))
|
| 108 |
+
(integrable_const (b ^ 2))
|
| 109 |
+
simp only [Pi.sub_apply] at h1 h2 h3
|
| 110 |
+
rw [h3, h2, h1]
|
| 111 |
+
simp only [integral_const_mul, integral_emptyIndicator, integral_const,
|
| 112 |
+
probReal_univ, one_smul]
|
| 113 |
+
have hmass := mass_union_inter rate s t
|
| 114 |
+
have hu : Real.exp (-mass rate (s ∪ t)) =
|
| 115 |
+
Real.exp (-(mass rate s + mass rate t)) * Real.exp (mass rate (s ∩ t)) := by
|
| 116 |
+
rw [← Real.exp_add]
|
| 117 |
+
congr 1
|
| 118 |
+
linarith
|
| 119 |
+
have hp : Real.exp (-mass rate s) * Real.exp (-mass rate t) =
|
| 120 |
+
Real.exp (-(mass rate s + mass rate t)) := by
|
| 121 |
+
rw [← Real.exp_add]
|
| 122 |
+
congr 1
|
| 123 |
+
ring
|
| 124 |
+
rw [hu]
|
| 125 |
+
nlinarith [hp]
|
| 126 |
+
|
| 127 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 128 |
+
lemma emptyIndicator_nonneg (s : Finset ι) (ω : ι → ℕ) : 0 ≤ emptyIndicator s ω := by
|
| 129 |
+
unfold emptyIndicator
|
| 130 |
+
apply Set.indicator_nonneg
|
| 131 |
+
intro _ _
|
| 132 |
+
norm_num
|
| 133 |
+
|
| 134 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 135 |
+
lemma abs_centeredFactor_le_one (s : Finset ι) (b : ℝ) (hb : b ∈ Set.Icc 0 1)
|
| 136 |
+
(ω : ι → ℕ) : |centeredFactor s b ω| ≤ 1 := by
|
| 137 |
+
unfold centeredFactor emptyIndicator
|
| 138 |
+
by_cases h : ω ∈ emptyEvent s <;> simp [h, abs_le] <;> constructor <;> linarith [hb.1, hb.2]
|
| 139 |
+
|
| 140 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 141 |
+
lemma centeredFactor_of_hit (s : Finset ι) (b : ℝ) (ω : ι → ℕ)
|
| 142 |
+
{i : ι} (hi : i ∈ s) (hhit : ω i ≠ 0) : centeredFactor s b ω = -b := by
|
| 143 |
+
have h : ω ∉ emptyEvent s := by
|
| 144 |
+
intro he
|
| 145 |
+
exact hhit (he i hi)
|
| 146 |
+
simp [centeredFactor, emptyIndicator, h]
|
| 147 |
+
omit [DecidableEq ι] in
|
| 148 |
+
|
| 149 |
+
lemma integral_abs_centeredFactor_le (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) :
|
| 150 |
+
(∫ ω, |centeredFactor s b ω| ∂batchMeasure rate) ≤ Real.exp (-mass rate s) + |b| := by
|
| 151 |
+
calc
|
| 152 |
+
_ ≤ ∫ ω, emptyIndicator s ω + |b| ∂batchMeasure rate := by
|
| 153 |
+
apply integral_mono (integrable_centeredFactor rate s b).abs
|
| 154 |
+
((integrable_emptyIndicator rate s).add (integrable_const |b|))
|
| 155 |
+
intro ω
|
| 156 |
+
dsimp [centeredFactor]
|
| 157 |
+
exact (abs_sub _ _).trans (by rw [abs_of_nonneg (emptyIndicator_nonneg s ω)])
|
| 158 |
+
_ = _ := by
|
| 159 |
+
rw [integral_add (integrable_emptyIndicator rate s) (integrable_const |b|),
|
| 160 |
+
integral_emptyIndicator]
|
| 161 |
+
simp
|
| 162 |
+
|
| 163 |
+
lemma abs_exp_neg_sub_exp_neg_le {a b c : ℝ} (ha : c ≤ a) (hb : c ≤ b) :
|
| 164 |
+
|Real.exp (-a) - Real.exp (-b)| ≤ Real.exp (-c) * |a - b| := by
|
| 165 |
+
have ordered : ∀ {a b : ℝ}, c ≤ a → a ≤ b →
|
| 166 |
+
Real.exp (-a) - Real.exp (-b) ≤ Real.exp (-c) * (b - a) := by
|
| 167 |
+
intro a b hca hab
|
| 168 |
+
have he := Real.add_one_le_exp (a - b)
|
| 169 |
+
have hm := mul_le_mul_of_nonneg_left he (Real.exp_pos (-a)).le
|
| 170 |
+
have hprod : Real.exp (-a) * Real.exp (a - b) = Real.exp (-b) := by
|
| 171 |
+
rw [← Real.exp_add]
|
| 172 |
+
congr 1
|
| 173 |
+
ring
|
| 174 |
+
rw [hprod] at hm
|
| 175 |
+
have hec : Real.exp (-a) ≤ Real.exp (-c) := Real.exp_le_exp.mpr (neg_le_neg hca)
|
| 176 |
+
have hd := mul_le_mul_of_nonneg_right hec (sub_nonneg.mpr hab)
|
| 177 |
+
nlinarith
|
| 178 |
+
rcases le_total a b with hab | hba
|
| 179 |
+
· rw [abs_of_nonneg (sub_nonneg.mpr (Real.exp_le_exp.mpr (neg_le_neg hab))),
|
| 180 |
+
abs_of_nonpos (sub_nonpos.mpr hab)]
|
| 181 |
+
simpa only [neg_sub] using ordered ha hab
|
| 182 |
+
· rw [abs_of_nonpos (sub_nonpos.mpr (Real.exp_le_exp.mpr (neg_le_neg hba))),
|
| 183 |
+
abs_of_nonneg (sub_nonneg.mpr hba)]
|
| 184 |
+
simpa only [neg_sub] using ordered hb hba
|
| 185 |
+
|
| 186 |
+
omit [DecidableEq ι] in
|
| 187 |
+
|
| 188 |
+
lemma abs_integral_centeredFactor_le (rate : ι → ℝ≥0) (s : Finset ι)
|
| 189 |
+
{L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam)
|
| 190 |
+
(hlam : c ≤ lam) (hbase : c ≤ base) :
|
| 191 |
+
|∫ ω, centeredFactor s (Real.exp (-L * base)) ω ∂batchMeasure rate| ≤
|
| 192 |
+
L * Real.exp (-L * c) * |lam - base| := by
|
| 193 |
+
rw [integral_centeredFactor, hmass]
|
| 194 |
+
have he := abs_exp_neg_sub_exp_neg_le
|
| 195 |
+
(mul_le_mul_of_nonneg_left hlam hL) (mul_le_mul_of_nonneg_left hbase hL)
|
| 196 |
+
simpa only [neg_mul, mul_neg, ← mul_sub, abs_mul, abs_of_nonneg hL, mul_comm,
|
| 197 |
+
mul_left_comm, mul_assoc] using he
|
| 198 |
+
|
| 199 |
+
omit [DecidableEq ι] in
|
| 200 |
+
|
| 201 |
+
lemma integral_abs_centeredFactor_exp_le (rate : ι → ℝ≥0) (s : Finset ι)
|
| 202 |
+
{L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam)
|
| 203 |
+
(hlam : c ≤ lam) (hbase : c ≤ base) :
|
| 204 |
+
(∫ ω, |centeredFactor s (Real.exp (-L * base)) ω| ∂batchMeasure rate) ≤
|
| 205 |
+
2 * Real.exp (-L * c) := by
|
| 206 |
+
have h1 := integral_abs_centeredFactor_le rate s (Real.exp (-L * base))
|
| 207 |
+
rw [hmass, abs_of_pos (Real.exp_pos _)] at h1
|
| 208 |
+
have h2 : Real.exp (-(L * lam)) ≤ Real.exp (-L * c) :=
|
| 209 |
+
Real.exp_le_exp.mpr (by nlinarith)
|
| 210 |
+
have h3 : Real.exp (-L * base) ≤ Real.exp (-L * c) :=
|
| 211 |
+
Real.exp_le_exp.mpr (by nlinarith)
|
| 212 |
+
linarith
|
| 213 |
+
|
| 214 |
+
lemma integrable_centeredFactor_mul (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) :
|
| 215 |
+
Integrable (fun ω => centeredFactor s b ω * centeredFactor t b ω) (batchMeasure rate) := by
|
| 216 |
+
have he : (fun ω => centeredFactor s b ω * centeredFactor t b ω) =
|
| 217 |
+
fun ω => emptyIndicator (s ∪ t) ω - b * emptyIndicator s ω -
|
| 218 |
+
b * emptyIndicator t ω + b ^ 2 := by
|
| 219 |
+
funext ω
|
| 220 |
+
rw [centeredFactor, centeredFactor]
|
| 221 |
+
nlinarith [emptyIndicator_mul s t ω]
|
| 222 |
+
rw [he]
|
| 223 |
+
exact (((integrable_emptyIndicator rate (s ∪ t)).sub
|
| 224 |
+
((integrable_emptyIndicator rate s).const_mul b)).sub
|
| 225 |
+
((integrable_emptyIndicator rate t).const_mul b)).add (integrable_const (b^2))
|
| 226 |
+
|
| 227 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 228 |
+
lemma mass_nonneg (rate : ι → ℝ≥0) (s : Finset ι) : 0 ≤ mass rate s := by
|
| 229 |
+
exact Finset.sum_nonneg (fun i _ => (rate i).coe_nonneg)
|
| 230 |
+
|
| 231 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 232 |
+
lemma mass_mono (rate : ι → ℝ≥0) {s t : Finset ι} (hst : s ⊆ t) :
|
| 233 |
+
mass rate s ≤ mass rate t := by
|
| 234 |
+
exact Finset.sum_le_sum_of_subset_of_nonneg hst (fun i _ _ => (rate i).coe_nonneg)
|
| 235 |
+
|
| 236 |
+
lemma one_sub_exp_neg_le (a : ℝ) : 1 - Real.exp (-a) ≤ a := by
|
| 237 |
+
have := Real.add_one_le_exp (-a)
|
| 238 |
+
linarith
|
| 239 |
+
|
| 240 |
+
omit [Fintype ι] in
|
| 241 |
+
|
| 242 |
+
lemma covariance_le (rate : ι → ℝ≥0) (s t : Finset ι) :
|
| 243 |
+
Real.exp (-(mass rate s + mass rate t)) *
|
| 244 |
+
(Real.exp (mass rate (s ∩ t)) - 1) ≤
|
| 245 |
+
mass rate (s ∩ t) * Real.exp (-mass rate (s ∪ t)) := by
|
| 246 |
+
have hu := mass_union_inter rate s t
|
| 247 |
+
have he : Real.exp (-(mass rate s + mass rate t)) =
|
| 248 |
+
Real.exp (-mass rate (s ∪ t)) * Real.exp (-mass rate (s ∩ t)) := by
|
| 249 |
+
rw [← Real.exp_add]
|
| 250 |
+
congr 1
|
| 251 |
+
linarith
|
| 252 |
+
rw [he]
|
| 253 |
+
have hh : Real.exp (-mass rate (s ∩ t)) * Real.exp (mass rate (s ∩ t)) = 1 := by
|
| 254 |
+
rw [← Real.exp_add]
|
| 255 |
+
simp
|
| 256 |
+
have hb := mul_le_mul_of_nonneg_left (one_sub_exp_neg_le (mass rate (s ∩ t)))
|
| 257 |
+
(Real.exp_pos (-mass rate (s ∪ t))).le
|
| 258 |
+
calc
|
| 259 |
+
_ = Real.exp (-mass rate (s ∪ t)) * (1 - Real.exp (-mass rate (s ∩ t))) := by
|
| 260 |
+
rw [mul_assoc, mul_sub, hh, mul_one]
|
| 261 |
+
_ ≤ _ := by simpa only [mul_comm] using hb
|
| 262 |
+
omit [Fintype ι] in
|
| 263 |
+
|
| 264 |
+
lemma covariance_nonneg (rate : ι → ℝ≥0) (s t : Finset ι) :
|
| 265 |
+
0 ≤ Real.exp (-(mass rate s + mass rate t)) *
|
| 266 |
+
(Real.exp (mass rate (s ∩ t)) - 1) := by
|
| 267 |
+
apply mul_nonneg (Real.exp_pos _).le
|
| 268 |
+
exact sub_nonneg.mpr (Real.one_le_exp_iff.mpr (mass_nonneg rate _))
|
| 269 |
+
|
| 270 |
+
lemma abs_integral_centeredFactor_mul_le_mass (rate : ι → ℝ≥0)
|
| 271 |
+
(s t : Finset ι) (b : ℝ) :
|
| 272 |
+
|∫ ω, centeredFactor s b ω * centeredFactor t b ω ∂batchMeasure rate| ≤
|
| 273 |
+
|Real.exp (-mass rate s) - b| * |Real.exp (-mass rate t) - b| +
|
| 274 |
+
mass rate (s ∩ t) * Real.exp (-mass rate (s ∪ t)) := by
|
| 275 |
+
rw [integral_centeredFactor_mul]
|
| 276 |
+
calc
|
| 277 |
+
_ ≤ |(Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b)| +
|
| 278 |
+
|Real.exp (-(mass rate s + mass rate t)) *
|
| 279 |
+
(Real.exp (mass rate (s ∩ t)) - 1)| := abs_add_le _ _
|
| 280 |
+
_ ≤ _ := by
|
| 281 |
+
rw [abs_mul, abs_of_nonneg (covariance_nonneg rate s t)]
|
| 282 |
+
exact add_le_add le_rfl (covariance_le rate s t)
|
| 283 |
+
|
| 284 |
+
lemma abs_integral_centeredFactor_mul_exp_le (rate : ι → ℝ≥0)
|
| 285 |
+
(s t : Finset ι) {L lam₁ lam₂ base c θ : ℝ}
|
| 286 |
+
(hL : 1 ≤ L) (hc : 0 ≤ c)
|
| 287 |
+
(hs : mass rate s = L * lam₁) (ht : mass rate t = L * lam₂)
|
| 288 |
+
(hi : mass rate (s ∩ t) = L * θ)
|
| 289 |
+
(h₁ : c ≤ lam₁) (h₂ : c ≤ lam₂) (hbase : c ≤ base) :
|
| 290 |
+
|∫ ω, centeredFactor s (Real.exp (-L * base)) ω *
|
| 291 |
+
centeredFactor t (Real.exp (-L * base)) ω ∂batchMeasure rate| ≤
|
| 292 |
+
L ^ 2 * Real.exp (-L * c) * (|lam₁ - base| * |lam₂ - base| + θ) := by
|
| 293 |
+
have hL0 : 0 ≤ L := le_trans (by norm_num) hL
|
| 294 |
+
have hi0 := mass_nonneg rate (s ∩ t)
|
| 295 |
+
have hθ : 0 ≤ θ := by rw [hi] at hi0; nlinarith
|
| 296 |
+
have hu : L * c ≤ mass rate (s ∪ t) := by
|
| 297 |
+
calc
|
| 298 |
+
_ ≤ L * lam₁ := mul_le_mul_of_nonneg_left h₁ hL0
|
| 299 |
+
_ = mass rate s := hs.symm
|
| 300 |
+
_ ≤ mass rate (s ∪ t) := mass_mono rate Finset.subset_union_left
|
| 301 |
+
have huse : Real.exp (-mass rate (s ∪ t)) ≤ Real.exp (-L * c) :=
|
| 302 |
+
Real.exp_le_exp.mpr (by linarith)
|
| 303 |
+
have hepos := Real.exp_pos (-L * c)
|
| 304 |
+
have hele : Real.exp (-L * c) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith)
|
| 305 |
+
have e₁ := abs_integral_centeredFactor_le rate s hL0 hs h₁ hbase
|
| 306 |
+
have e₂ := abs_integral_centeredFactor_le rate t hL0 ht h₂ hbase
|
| 307 |
+
rw [integral_centeredFactor] at e₁ e₂
|
| 308 |
+
have hmul := mul_le_mul e₁ e₂ (abs_nonneg _)
|
| 309 |
+
(mul_nonneg (mul_nonneg hL0 hepos.le) (abs_nonneg _))
|
| 310 |
+
have hab := mul_nonneg (abs_nonneg (lam₁ - base)) (abs_nonneg (lam₂ - base))
|
| 311 |
+
have hpow : Real.exp (-L * c) ^ 2 ≤ Real.exp (-L * c) := by nlinarith
|
| 312 |
+
have hbound := mul_le_mul_of_nonneg_left hpow
|
| 313 |
+
(mul_nonneg (sq_nonneg L) hab)
|
| 314 |
+
have hcov := mul_le_mul_of_nonneg_left huse hi0
|
| 315 |
+
rw [hi] at hcov
|
| 316 |
+
have hLsq : L ≤ L ^ 2 := by nlinarith
|
| 317 |
+
have hcov' := mul_le_mul_of_nonneg_right hLsq (mul_nonneg hθ hepos.le)
|
| 318 |
+
have hfinal := abs_integral_centeredFactor_mul_le_mass rate s t (Real.exp (-L * base))
|
| 319 |
+
nlinarith
|
| 320 |
+
|
| 321 |
+
noncomputable def scheduleMeasure (rate : ι → ℝ≥0) (R : ℕ) :
|
| 322 |
+
Measure (Fin R → ι → ℕ) :=
|
| 323 |
+
Measure.pi (fun _ : Fin R => batchMeasure rate)
|
| 324 |
+
|
| 325 |
+
instance flat_HighMomentRecovered_2 (rate : ι → ℝ≥0) (R : ℕ) : IsProbabilityMeasure (scheduleMeasure rate R) := by
|
| 326 |
+
unfold scheduleMeasure
|
| 327 |
+
infer_instance
|
| 328 |
+
|
| 329 |
+
noncomputable def scoreTerm {R : ℕ} (s : Finset ι) (b : ℝ) (own : Fin R → Bool)
|
| 330 |
+
(ω : Fin R → ι → ℕ) : ℝ :=
|
| 331 |
+
∏ r, if own r then centeredFactor s b (ω r) else 0
|
| 332 |
+
omit [DecidableEq ι] in
|
| 333 |
+
|
| 334 |
+
lemma integrable_scoreTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ)
|
| 335 |
+
(own : Fin R → Bool) : Integrable (scoreTerm s b own) (scheduleMeasure rate R) := by
|
| 336 |
+
apply Integrable.fintype_prod (f := fun r ω => if own r then centeredFactor s b ω else 0)
|
| 337 |
+
intro r
|
| 338 |
+
cases h : own r <;> simp only [Bool.false_eq_true, ↓reduceIte]
|
| 339 |
+
· exact integrable_const 0
|
| 340 |
+
· exact integrable_centeredFactor rate s b
|
| 341 |
+
omit [DecidableEq ι] in
|
| 342 |
+
|
| 343 |
+
lemma integral_scoreTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ)
|
| 344 |
+
(own : Fin R → Bool) :
|
| 345 |
+
(∫ ω, scoreTerm s b own ω ∂scheduleMeasure rate R) =
|
| 346 |
+
∏ r, if own r then Real.exp (-mass rate s) - b else 0 := by
|
| 347 |
+
unfold scoreTerm scheduleMeasure
|
| 348 |
+
rw [integral_fintype_prod_eq_prod (f := fun r ω => if own r then centeredFactor s b ω else 0)]
|
| 349 |
+
congr 1
|
| 350 |
+
funext r
|
| 351 |
+
cases h : own r <;> simp [integral_centeredFactor]
|
| 352 |
+
|
| 353 |
+
noncomputable def pairMean (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : ℝ :=
|
| 354 |
+
(Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b) +
|
| 355 |
+
Real.exp (-(mass rate s + mass rate t)) *
|
| 356 |
+
(Real.exp (mass rate (s ∩ t)) - 1)
|
| 357 |
+
|
| 358 |
+
lemma integrable_scoreTerm_mul (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ)
|
| 359 |
+
(ownS ownT : Fin R → Bool) :
|
| 360 |
+
Integrable (fun ω => scoreTerm s b ownS ω * scoreTerm t b ownT ω)
|
| 361 |
+
(scheduleMeasure rate R) := by
|
| 362 |
+
simp only [scoreTerm, ← Finset.prod_mul_distrib]
|
| 363 |
+
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))
|
| 364 |
+
intro r
|
| 365 |
+
cases hs : ownS r <;> cases ht : ownT r <;>
|
| 366 |
+
simp only [Bool.false_eq_true, ↓reduceIte, zero_mul, mul_zero]
|
| 367 |
+
· exact integrable_const 0
|
| 368 |
+
· exact integrable_const 0
|
| 369 |
+
· exact integrable_const 0
|
| 370 |
+
· exact integrable_centeredFactor_mul rate s t b
|
| 371 |
+
|
| 372 |
+
lemma integral_scoreTerm_mul (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ)
|
| 373 |
+
(ownS ownT : Fin R → Bool) :
|
| 374 |
+
(∫ ω, scoreTerm s b ownS ω * scoreTerm t b ownT ω ∂scheduleMeasure rate R) =
|
| 375 |
+
∏ r, if ownS r && ownT r then pairMean rate s t b else 0 := by
|
| 376 |
+
simp only [scoreTerm, ← Finset.prod_mul_distrib, scheduleMeasure]
|
| 377 |
+
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))]
|
| 378 |
+
congr 1
|
| 379 |
+
funext r
|
| 380 |
+
cases hs : ownS r <;> cases ht : ownT r <;>
|
| 381 |
+
simp [integral_centeredFactor_mul, pairMean]
|
| 382 |
+
|
| 383 |
+
lemma abs_integral_scoreTerm_mul_le (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ)
|
| 384 |
+
(ownS ownT : Fin R → Bool) :
|
| 385 |
+
|∫ ω, scoreTerm s b ownS ω * scoreTerm t b ownT ω ∂scheduleMeasure rate R| ≤
|
| 386 |
+
|pairMean rate s t b| ^ R := by
|
| 387 |
+
rw [integral_scoreTerm_mul, Finset.abs_prod]
|
| 388 |
+
calc
|
| 389 |
+
_ ≤ ∏ _ : Fin R, |pairMean rate s t b| := by
|
| 390 |
+
apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _)
|
| 391 |
+
intro r _
|
| 392 |
+
split_ifs <;> simp
|
| 393 |
+
_ = _ := by simp
|
| 394 |
+
|
| 395 |
+
variable {κ : Type*}
|
| 396 |
+
|
| 397 |
+
noncomputable def typicalScore {R : ℕ} (H : Finset κ) (directions : κ → Finset ι)
|
| 398 |
+
(b : ℝ) (own : κ → Fin R → Bool) (ω : Fin R → ι → ℕ) : ℝ :=
|
| 399 |
+
∑ h ∈ H, scoreTerm (directions h) b (own h) ω
|
| 400 |
+
|
| 401 |
+
lemma integral_typicalScore_sq (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ)
|
| 402 |
+
(directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) :
|
| 403 |
+
(∫ ω, (typicalScore H directions b own ω)^2 ∂scheduleMeasure rate R) =
|
| 404 |
+
∑ h ∈ H, ∑ k ∈ H,
|
| 405 |
+
∏ r, if own h r && own k r then pairMean rate (directions h) (directions k) b else 0 := by
|
| 406 |
+
simp only [typicalScore, pow_two]
|
| 407 |
+
simp_rw [Finset.sum_mul]
|
| 408 |
+
simp_rw [Finset.mul_sum]
|
| 409 |
+
rw [integral_finsetSum H (fun h _ =>
|
| 410 |
+
integrable_finsetSum H (fun k _ =>
|
| 411 |
+
integrable_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k)))]
|
| 412 |
+
apply Finset.sum_congr rfl
|
| 413 |
+
intro h _
|
| 414 |
+
rw [integral_finsetSum H (fun k _ =>
|
| 415 |
+
integrable_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k))]
|
| 416 |
+
apply Finset.sum_congr rfl
|
| 417 |
+
intro k _
|
| 418 |
+
exact integral_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k)
|
| 419 |
+
|
| 420 |
+
end SharpRamseyFive.PoissonScore
|
| 421 |
+
end
|
| 422 |
+
|
| 423 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/HighRankEntropy.lean
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Marking.HighRankContext
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey.ActualHighRank
|
| 8 |
+
open Finset Real Selection
|
| 9 |
+
open scoped Classical BigOperators
|
| 10 |
+
noncomputable section
|
| 11 |
+
variable {K V Ω : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V]
|
| 12 |
+
[FiniteDimensional K V] [Fintype Ω]
|
| 13 |
+
[Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))]
|
| 14 |
+
|
| 15 |
+
omit [FiniteDimensional K V]
|
| 16 |
+
[Fintype (Projectivization K (Module.Dual K V))] in
|
| 17 |
+
lemma projective_card_bound {d : ℕ} (hdim : Module.finrank K V=d+1) :
|
| 18 |
+
(Fintype.card (Projectivization K V):ℝ)≤2*(Nat.card K:ℝ)^d := by
|
| 19 |
+
rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim,Nat.cast_sum]
|
| 20 |
+
simp only [Nat.cast_pow]
|
| 21 |
+
exact HighRankExcess.geom_sum_le_twice (by exact_mod_cast (Finite.one_lt_card : 1<Nat.card K)) d
|
| 22 |
+
|
| 23 |
+
omit [FiniteDimensional K V]
|
| 24 |
+
[Fintype (Projectivization K (Module.Dual K V))] in
|
| 25 |
+
lemma projective_card_positive {d : ℕ} (hdim : Module.finrank K V=d+1) :
|
| 26 |
+
(0:ℝ)<Fintype.card (Projectivization K V) := by
|
| 27 |
+
rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim,Nat.cast_sum]
|
| 28 |
+
apply lt_of_lt_of_le (by norm_num : (0:ℝ)<(Nat.card K^0:ℕ))
|
| 29 |
+
exact single_le_sum (fun i _=>Nat.cast_nonneg _) (mem_range.mpr (by omega))
|
| 30 |
+
|
| 31 |
+
omit [FiniteDimensional K V] in
|
| 32 |
+
lemma flag_card_log {d : ℕ} (hdim : Module.finrank K V=d+1) :
|
| 33 |
+
log (Fintype.card (Projectivization K (Module.Dual K V)×Projectivization K V))≤
|
| 34 |
+
2*(log 2+(d:ℝ)*log (Nat.card K)) := by
|
| 35 |
+
have hdual : Module.finrank K (Module.Dual K V)=d+1 := by rw [Subspace.dual_finrank_eq,hdim]
|
| 36 |
+
have ha:=projective_card_bound hdual
|
| 37 |
+
have hb:=projective_card_bound hdim
|
| 38 |
+
have hap:=projective_card_positive hdual
|
| 39 |
+
have hbp:=projective_card_positive hdim
|
| 40 |
+
have hq : (0:ℝ)<Nat.card K := by exact_mod_cast Finite.card_pos
|
| 41 |
+
simp only [Fintype.card_prod,Nat.cast_mul]
|
| 42 |
+
apply (log_le_log (mul_pos hap hbp)
|
| 43 |
+
(mul_le_mul ha hb hbp.le (by positivity))).trans
|
| 44 |
+
rw [←pow_two,log_pow,log_mul (by norm_num) (pow_ne_zero _ hq.ne'),log_pow]
|
| 45 |
+
rfl
|
| 46 |
+
|
| 47 |
+
omit [FiniteDimensional K V] in
|
| 48 |
+
theorem raw_entropy {d h : ℕ} (hdim : Module.finrank K V=d+1)
|
| 49 |
+
(p : Law Ω)
|
| 50 |
+
(code : Ω→(Fin h→Projectivization K (Module.Dual K V)×Projectivization K V)×
|
| 51 |
+
(Fin h→Projectivization K (Module.Dual K V)×Projectivization K V)) :
|
| 52 |
+
entropy (p.map code)≤4*(h:ℝ)*(log 2+(d:ℝ)*log (Nat.card K)) := by
|
| 53 |
+
apply (raw_rows_entropy h p code).trans
|
| 54 |
+
have hh:=mul_le_mul_of_nonneg_left (flag_card_log hdim) (by positivity : 0≤2*(h:ℝ))
|
| 55 |
+
convert hh using 1
|
| 56 |
+
ring
|
| 57 |
+
|
| 58 |
+
end
|
| 59 |
+
end SharpLogRamsey.ActualHighRank
|
| 60 |
+
|
| 61 |
+
end
|
| 62 |
+
|
| 63 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/InformationScales.lean
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Parameters.ExposureScales
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey.SourceScales
|
| 8 |
+
open Real Filter
|
| 9 |
+
open scoped Topology
|
| 10 |
+
noncomputable section
|
| 11 |
+
|
| 12 |
+
theorem eventually_information_bad_small (η C c ε : ℝ)
|
| 13 |
+
(hη : 0<η) (hC : 0≤C) (hc : 0<c) (hε : 0<ε) :
|
| 14 |
+
∀ᶠ σ : ℝ in atTop, ∀ q D N budget k : ℝ,
|
| 15 |
+
0<q → 0<D → 0≤N → budget≤C*N*D*σ^(-beta η) →
|
| 16 |
+
c*q*D*σ^(3000*beta η)≤k →
|
| 17 |
+
let a:=σ^(-2000*beta η)/q
|
| 18 |
+
budget/(D*σ^beta η)+2*budget/(k*a)≤N*ε := by
|
| 19 |
+
filter_upwards [eventually_integer_bad_small η C c ε hη hC hc hε,
|
| 20 |
+
eventually_ge_atTop (0:ℝ)] with σ h hσ
|
| 21 |
+
intro q D N budget k hq hD hN hb hk
|
| 22 |
+
have hh:=h q D N budget 0 (c*q*σ^(1+η/2)) k hq hD hN hb
|
| 23 |
+
(mul_nonneg hC hσ) hk le_rfl
|
| 24 |
+
simpa only [mul_zero,zero_div,add_zero] using hh
|
| 25 |
+
end
|
| 26 |
+
end SharpLogRamsey.SourceScales
|
| 27 |
+
|
| 28 |
+
end
|
| 29 |
+
|
| 30 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/IntegralTypicalScoreSq.lean
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.HighMoments
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
namespace SharpRamseyFive.PoissonScore
|
| 12 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 13 |
+
variable {κ : Type*}
|
| 14 |
+
lemma integral_typicalScore_sq_le (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ)
|
| 15 |
+
(directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) :
|
| 16 |
+
(∫ ω, (typicalScore H directions b own ω)^2 ∂scheduleMeasure rate R) ≤
|
| 17 |
+
∑ h ∈ H, ∑ k ∈ H, |pairMean rate (directions h) (directions k) b|^R := by
|
| 18 |
+
rw [integral_typicalScore_sq]
|
| 19 |
+
apply Finset.sum_le_sum
|
| 20 |
+
intro h _
|
| 21 |
+
apply Finset.sum_le_sum
|
| 22 |
+
intro k _
|
| 23 |
+
rw [← integral_scoreTerm_mul]
|
| 24 |
+
exact (le_abs_self _).trans
|
| 25 |
+
(abs_integral_scoreTerm_mul_le rate (directions h) (directions k) b (own h) (own k))
|
| 26 |
+
|
| 27 |
+
section TupleCalculation
|
| 28 |
+
|
| 29 |
+
variable {ν : Type*} [DecidableEq ν]
|
| 30 |
+
omit [Fintype ι] in
|
| 31 |
+
|
| 32 |
+
lemma prod_emptyIndicator (I : Finset ν) (directions : ν → Finset ι) (ω : ι → ℕ) :
|
| 33 |
+
(∏ h ∈ I, emptyIndicator (directions h) ω) =
|
| 34 |
+
emptyIndicator (I.biUnion directions) ω := by
|
| 35 |
+
induction I using Finset.induction_on with
|
| 36 |
+
| empty => simp [emptyIndicator, emptyEvent]
|
| 37 |
+
| @insert h I hh ih =>
|
| 38 |
+
rw [Finset.prod_insert hh, Finset.biUnion_insert, ih, emptyIndicator_mul]
|
| 39 |
+
omit [Fintype ι] in
|
| 40 |
+
|
| 41 |
+
lemma prod_centeredFactor (I : Finset ν) (directions : ν → Finset ι) (b : ℝ)
|
| 42 |
+
(ω : ι → ℕ) :
|
| 43 |
+
(∏ h ∈ I, centeredFactor (directions h) b ω) =
|
| 44 |
+
∑ J ∈ I.powerset, (-b) ^ (I \ J).card * emptyIndicator (J.biUnion directions) ω := by
|
| 45 |
+
simp only [centeredFactor, sub_eq_add_neg]
|
| 46 |
+
rw [Finset.prod_add]
|
| 47 |
+
apply Finset.sum_congr rfl
|
| 48 |
+
intro J _
|
| 49 |
+
rw [prod_emptyIndicator, Finset.prod_const]
|
| 50 |
+
ring
|
| 51 |
+
|
| 52 |
+
lemma integrable_prod_centeredFactor (rate : ι → ℝ≥0) (I : Finset ν)
|
| 53 |
+
(directions : ν → Finset ι) (b : ℝ) :
|
| 54 |
+
Integrable (fun ω => ∏ h ∈ I, centeredFactor (directions h) b ω) (batchMeasure rate) := by
|
| 55 |
+
simp_rw [prod_centeredFactor]
|
| 56 |
+
exact integrable_finsetSum _ (fun J _ =>
|
| 57 |
+
(integrable_emptyIndicator rate _).const_mul _)
|
| 58 |
+
|
| 59 |
+
noncomputable def tupleMean (rate : ι → ℝ≥0) (I : Finset ν)
|
| 60 |
+
(directions : ν → Finset ι) (b : ℝ) : ℝ :=
|
| 61 |
+
∑ J ∈ I.powerset, (-b) ^ (I \ J).card * Real.exp (-mass rate (J.biUnion directions))
|
| 62 |
+
|
| 63 |
+
lemma integral_prod_centeredFactor (rate : ι → ℝ≥0) (I : Finset ν)
|
| 64 |
+
(directions : ν → Finset ι) (b : ℝ) :
|
| 65 |
+
(∫ ω, ∏ h ∈ I, centeredFactor (directions h) b ω ∂batchMeasure rate) =
|
| 66 |
+
tupleMean rate I directions b := by
|
| 67 |
+
simp_rw [prod_centeredFactor]
|
| 68 |
+
rw [integral_finsetSum _ (fun J _ =>
|
| 69 |
+
(integrable_emptyIndicator rate _).const_mul _)]
|
| 70 |
+
simp only [integral_const_mul, integral_emptyIndicator, tupleMean]
|
| 71 |
+
|
| 72 |
+
omit [Fintype ι] [DecidableEq ι] [DecidableEq ν] in
|
| 73 |
+
lemma prod_scoreTerm (I : Finset ν) (directions : ν → Finset ι) (b : ℝ)
|
| 74 |
+
{R : ℕ} (own : ν → Fin R → Bool) (ω : Fin R → ι → ℕ) :
|
| 75 |
+
(∏ h ∈ I, scoreTerm (directions h) b (own h) ω) =
|
| 76 |
+
∏ r, if ∀ h ∈ I, own h r then ∏ h ∈ I, centeredFactor (directions h) b (ω r) else 0 := by
|
| 77 |
+
simp only [scoreTerm]
|
| 78 |
+
rw [Finset.prod_comm]
|
| 79 |
+
apply Finset.prod_congr rfl
|
| 80 |
+
intro r _
|
| 81 |
+
exact Finset.prod_ite_zero
|
| 82 |
+
|
| 83 |
+
lemma integrable_prod_scoreTerm (rate : ι → ℝ≥0) (I : Finset ν)
|
| 84 |
+
(directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) :
|
| 85 |
+
Integrable (fun ω => ∏ h ∈ I, scoreTerm (directions h) b (own h) ω)
|
| 86 |
+
(scheduleMeasure rate R) := by
|
| 87 |
+
simp_rw [prod_scoreTerm]
|
| 88 |
+
apply Integrable.fintype_prod (f := fun r ω => if ∀ h ∈ I, own h r then
|
| 89 |
+
∏ h ∈ I, centeredFactor (directions h) b ω else 0)
|
| 90 |
+
intro r
|
| 91 |
+
split_ifs
|
| 92 |
+
· exact integrable_prod_centeredFactor rate I directions b
|
| 93 |
+
· exact integrable_const 0
|
| 94 |
+
|
| 95 |
+
lemma integral_prod_scoreTerm (rate : ι → ℝ≥0) (I : Finset ν)
|
| 96 |
+
(directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) :
|
| 97 |
+
(∫ ω, ∏ h ∈ I, scoreTerm (directions h) b (own h) ω ∂scheduleMeasure rate R) =
|
| 98 |
+
∏ r, if ∀ h ∈ I, own h r then tupleMean rate I directions b else 0 := by
|
| 99 |
+
simp_rw [prod_scoreTerm]
|
| 100 |
+
unfold scheduleMeasure
|
| 101 |
+
rw [integral_fintype_prod_eq_prod (f := fun r ω => if ∀ h ∈ I, own h r then
|
| 102 |
+
∏ h ∈ I, centeredFactor (directions h) b ω else 0)]
|
| 103 |
+
apply Finset.prod_congr rfl
|
| 104 |
+
intro r _
|
| 105 |
+
split_ifs <;> simp [integral_prod_centeredFactor]
|
| 106 |
+
|
| 107 |
+
lemma abs_integral_prod_scoreTerm_le (rate : ι → ℝ≥0) (I : Finset ν)
|
| 108 |
+
(directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) :
|
| 109 |
+
|∫ ω, ∏ h ∈ I, scoreTerm (directions h) b (own h) ω ∂scheduleMeasure rate R| ≤
|
| 110 |
+
|tupleMean rate I directions b| ^ R := by
|
| 111 |
+
rw [integral_prod_scoreTerm, Finset.abs_prod]
|
| 112 |
+
calc
|
| 113 |
+
_ ≤ ∏ _ : Fin R, |tupleMean rate I directions b| := by
|
| 114 |
+
apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _)
|
| 115 |
+
intro r _
|
| 116 |
+
split_ifs <;> simp
|
| 117 |
+
_ = _ := by simp
|
| 118 |
+
|
| 119 |
+
end TupleCalculation
|
| 120 |
+
|
| 121 |
+
lemma integral_typicalScore_pow (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ)
|
| 122 |
+
(directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) (p : ℕ) :
|
| 123 |
+
(∫ ω, (typicalScore H directions b own ω)^p ∂scheduleMeasure rate R) =
|
| 124 |
+
∑ hs ∈ Fintype.piFinset (fun _ : Fin p => H),
|
| 125 |
+
∏ r, if ∀ i : Fin p, own (hs i) r then
|
| 126 |
+
tupleMean rate Finset.univ (fun i => directions (hs i)) b else 0 := by
|
| 127 |
+
classical
|
| 128 |
+
simp only [typicalScore]
|
| 129 |
+
simp_rw [Finset.sum_pow']
|
| 130 |
+
rw [integral_finsetSum _ (fun hs _ =>
|
| 131 |
+
integrable_prod_scoreTerm rate Finset.univ (fun i => directions (hs i)) b (fun i => own (hs i)))]
|
| 132 |
+
apply Finset.sum_congr rfl
|
| 133 |
+
intro hs _
|
| 134 |
+
simpa using integral_prod_scoreTerm rate Finset.univ (fun i => directions (hs i)) b (fun i => own (hs i))
|
| 135 |
+
|
| 136 |
+
noncomputable def maskedFactor (s : Finset ι) (b : ℝ) (own touched : Bool)
|
| 137 |
+
(ω : ι → ℕ) : ℝ :=
|
| 138 |
+
if own then (if touched then -b else centeredFactor s b ω) else 0
|
| 139 |
+
|
| 140 |
+
noncomputable def maskedTerm {R : ℕ} (s : Finset ι) (b : ℝ)
|
| 141 |
+
(own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) : ℝ :=
|
| 142 |
+
∏ r, maskedFactor s b (own r) (touched r) (ω r)
|
| 143 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 144 |
+
|
| 145 |
+
lemma abs_maskedFactor_le_one (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1)
|
| 146 |
+
(own touched : Bool) (ω : ι → ℕ) : |maskedFactor s b own touched ω| ≤ 1 := by
|
| 147 |
+
cases own <;> cases touched <;> simp [maskedFactor, abs_centeredFactor_le_one s b hb ω,
|
| 148 |
+
abs_of_nonneg hb.1, hb.2]
|
| 149 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 150 |
+
|
| 151 |
+
lemma abs_maskedTerm_le_one {R : ℕ} (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1)
|
| 152 |
+
(own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) :
|
| 153 |
+
|maskedTerm s b own touched ω| ≤ 1 := by
|
| 154 |
+
rw [maskedTerm, Finset.abs_prod]
|
| 155 |
+
exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => abs_maskedFactor_le_one s hb _ _ _)
|
| 156 |
+
|
| 157 |
+
omit [DecidableEq ι] in
|
| 158 |
+
lemma integrable_schedule_of_abs_le (rate : ι → ℝ≥0) {R : ℕ}
|
| 159 |
+
(f : (Fin R → ι → ℕ) → ℝ) (C : ℝ) (h : ∀ ω, |f ω| ≤ C) :
|
| 160 |
+
Integrable f (scheduleMeasure rate R) := by
|
| 161 |
+
apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable C
|
| 162 |
+
exact Filter.Eventually.of_forall (fun ω => by simpa only [Real.norm_eq_abs] using h ω)
|
| 163 |
+
omit [DecidableEq ι] in
|
| 164 |
+
|
| 165 |
+
lemma integrable_maskedFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ)
|
| 166 |
+
(own touched : Bool) : Integrable (maskedFactor s b own touched) (batchMeasure rate) := by
|
| 167 |
+
cases own <;> cases touched
|
| 168 |
+
· exact integrable_const 0
|
| 169 |
+
· exact integrable_const 0
|
| 170 |
+
· exact integrable_centeredFactor rate s b
|
| 171 |
+
· exact integrable_const (-b)
|
| 172 |
+
omit [DecidableEq ι] in
|
| 173 |
+
|
| 174 |
+
lemma integral_maskedFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ)
|
| 175 |
+
(own touched : Bool) :
|
| 176 |
+
(∫ ω, maskedFactor s b own touched ω ∂batchMeasure rate) =
|
| 177 |
+
if own then (if touched then -b else Real.exp (-mass rate s) - b) else 0 := by
|
| 178 |
+
cases own <;> cases touched <;> simp [maskedFactor, integral_centeredFactor]
|
| 179 |
+
omit [DecidableEq ι] in
|
| 180 |
+
|
| 181 |
+
lemma integral_maskedTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ)
|
| 182 |
+
(own touched : Fin R → Bool) :
|
| 183 |
+
(∫ ω, maskedTerm s b own touched ω ∂scheduleMeasure rate R) =
|
| 184 |
+
∏ r, if own r then (if touched r then -b else Real.exp (-mass rate s) - b) else 0 := by
|
| 185 |
+
unfold maskedTerm scheduleMeasure
|
| 186 |
+
rw [integral_fintype_prod_eq_prod]
|
| 187 |
+
simp only [integral_maskedFactor]
|
| 188 |
+
omit [DecidableEq ι] in
|
| 189 |
+
|
| 190 |
+
lemma integral_abs_maskedFactor_exp_le (rate : ι → ℝ≥0) (s : Finset ι)
|
| 191 |
+
(own touched : Bool) {L lam base c : ℝ} (hL : 0 ≤ L)
|
| 192 |
+
(hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) :
|
| 193 |
+
(∫ ω, |maskedFactor s (Real.exp (-L * base)) own touched ω| ∂batchMeasure rate) ≤
|
| 194 |
+
2 * Real.exp (-L * c) := by
|
| 195 |
+
have he := Real.exp_pos (-L * c)
|
| 196 |
+
have hb : Real.exp (-L * base) ≤ Real.exp (-L * c) :=
|
| 197 |
+
Real.exp_le_exp.mpr (by nlinarith)
|
| 198 |
+
cases own <;> cases touched <;> simp only [maskedFactor, Bool.false_eq_true, ↓reduceIte]
|
| 199 |
+
· simp only [abs_zero, integral_zero]; positivity
|
| 200 |
+
· simp only [abs_zero, integral_zero]; positivity
|
| 201 |
+
· exact integral_abs_centeredFactor_exp_le rate s hL hmass hlam hbase
|
| 202 |
+
· simp only [abs_neg, abs_of_pos (Real.exp_pos _), integral_const, probReal_univ,
|
| 203 |
+
smul_eq_mul, one_mul]
|
| 204 |
+
linarith
|
| 205 |
+
omit [DecidableEq ι] in
|
| 206 |
+
|
| 207 |
+
lemma integral_abs_maskedTerm_exp_le (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι)
|
| 208 |
+
(own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L)
|
| 209 |
+
(hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) :
|
| 210 |
+
(∫ ω, |maskedTerm s (Real.exp (-L * base)) own touched ω| ∂scheduleMeasure rate R) ≤
|
| 211 |
+
(2 * Real.exp (-L * c)) ^ R := by
|
| 212 |
+
simp only [maskedTerm, Finset.abs_prod, scheduleMeasure]
|
| 213 |
+
rw [integral_fintype_prod_eq_prod (f := fun r ω =>
|
| 214 |
+
|maskedFactor s (Real.exp (-L * base)) (own r) (touched r) ω|)]
|
| 215 |
+
calc
|
| 216 |
+
_ ≤ ∏ _ : Fin R, 2 * Real.exp (-L * c) := by
|
| 217 |
+
apply Finset.prod_le_prod₀ (fun _ _ => integral_nonneg (fun _ => abs_nonneg _))
|
| 218 |
+
intro r _
|
| 219 |
+
exact integral_abs_maskedFactor_exp_le rate s (own r) (touched r) hL hmass hlam hbase
|
| 220 |
+
_ = _ := by simp
|
| 221 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 222 |
+
|
| 223 |
+
lemma abs_prod_maskedTerm_le {ν : Type*} [DecidableEq ν] {R : ℕ}
|
| 224 |
+
(I : Finset ν) (directions : ν → Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1)
|
| 225 |
+
(own touched : ν → Fin R → Bool) {h : ν} (hh : h ∈ I) (ω : Fin R → ι → ℕ) :
|
| 226 |
+
|∏ i ∈ I, maskedTerm (directions i) b (own i) (touched i) ω| ≤
|
| 227 |
+
|maskedTerm (directions h) b (own h) (touched h) ω| := by
|
| 228 |
+
rw [Finset.abs_prod, ← Finset.prod_erase_mul _ _ hh]
|
| 229 |
+
have hp : (∏ i ∈ I.erase h, |maskedTerm (directions i) b (own i) (touched i) ω|) ≤ 1 :=
|
| 230 |
+
Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => abs_maskedTerm_le_one _ hb _ _ _)
|
| 231 |
+
simpa using mul_le_mul_of_nonneg_right hp
|
| 232 |
+
(abs_nonneg (maskedTerm (directions h) b (own h) (touched h) ω))
|
| 233 |
+
|
| 234 |
+
omit [DecidableEq ι] in
|
| 235 |
+
|
| 236 |
+
lemma integral_abs_component_indicator_le (rate : ι → ℝ≥0)
|
| 237 |
+
{ν : Type*} [DecidableEq ν] {R : ℕ} (I : Finset ν) (directions : ν → Finset ι)
|
| 238 |
+
(own touched : ν → Fin R → Bool) (E : Set (Fin R → ι → ℕ))
|
| 239 |
+
{h : ν} (hh : h ∈ I) {L lam base c : ℝ} (hL : 0 ≤ L) (hc : 0 ≤ c)
|
| 240 |
+
(hmass : mass rate (directions h) = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) :
|
| 241 |
+
(∫ ω, |E.indicator (fun ω => ∏ i ∈ I,
|
| 242 |
+
maskedTerm (directions i) (Real.exp (-L * base)) (own i) (touched i) ω) ω|
|
| 243 |
+
∂scheduleMeasure rate R) ≤ (2 * Real.exp (-L * c)) ^ R := by
|
| 244 |
+
have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 :=
|
| 245 |
+
⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩
|
| 246 |
+
have hpoint : ∀ ω, |E.indicator (fun ω => ∏ i ∈ I,
|
| 247 |
+
maskedTerm (directions i) (Real.exp (-L * base)) (own i) (touched i) ω) ω| ≤
|
| 248 |
+
|maskedTerm (directions h) (Real.exp (-L * base)) (own h) (touched h) ω| := by
|
| 249 |
+
intro ω
|
| 250 |
+
by_cases he : ω ∈ E
|
| 251 |
+
· simpa only [Set.indicator_of_mem he] using abs_prod_maskedTerm_le I directions hb own touched hh ω
|
| 252 |
+
· simp only [Set.indicator_of_notMem he, abs_zero]; exact abs_nonneg _
|
| 253 |
+
calc
|
| 254 |
+
_ ≤ ∫ ω, |maskedTerm (directions h) (Real.exp (-L * base)) (own h) (touched h) ω|
|
| 255 |
+
∂scheduleMeasure rate R := by
|
| 256 |
+
apply integral_mono
|
| 257 |
+
· apply integrable_schedule_of_abs_le rate _ 1
|
| 258 |
+
intro ω
|
| 259 |
+
rw [abs_abs]
|
| 260 |
+
exact (hpoint ω).trans (abs_maskedTerm_le_one _ hb _ _ _)
|
| 261 |
+
· exact (integrable_schedule_of_abs_le rate _ 1 (abs_maskedTerm_le_one _ hb _ _)).abs
|
| 262 |
+
· exact hpoint
|
| 263 |
+
_ ≤ _ := integral_abs_maskedTerm_exp_le rate _ _ _ hL hmass hlam hbase
|
| 264 |
+
|
| 265 |
+
def untouchedBatches {R : ℕ} (touched : Fin R → Bool) : Finset (Fin R) :=
|
| 266 |
+
Finset.univ.filter (fun r => touched r = false)
|
| 267 |
+
|
| 268 |
+
omit [DecidableEq ι] in
|
| 269 |
+
|
| 270 |
+
lemma abs_integral_maskedTerm_le_untouched (rate : ι → ℝ≥0) {R : ℕ}
|
| 271 |
+
(s : Finset ι) (own touched : Fin R → Bool) {L base c delta alpha : ℝ}
|
| 272 |
+
(hL : 1 ≤ L) (hmass : mass rate s = L * (base + delta - alpha))
|
| 273 |
+
(hinternal : c ≤ base + delta - alpha) (hbase : c ≤ base) (ha : 0 ≤ alpha) :
|
| 274 |
+
|∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤
|
| 275 |
+
(L * Real.exp (-L * c)) ^ R * (|delta| + alpha) ^ (untouchedBatches touched).card := by
|
| 276 |
+
have hL0 : 0 ≤ L := by linarith
|
| 277 |
+
have he := (Real.exp_pos (-L * c)).le
|
| 278 |
+
have hd : 0 ≤ |delta| + alpha := add_nonneg (abs_nonneg _) ha
|
| 279 |
+
have hu := abs_integral_centeredFactor_le rate s hL0 hmass hinternal hbase
|
| 280 |
+
rw [integral_centeredFactor] at hu
|
| 281 |
+
have hdif : |base + delta - alpha - base| ≤ |delta| + alpha := by
|
| 282 |
+
calc
|
| 283 |
+
|base + delta - alpha - base| = |delta - alpha| := by congr 1; ring
|
| 284 |
+
_ ≤ |delta| + |alpha| := abs_sub _ _
|
| 285 |
+
_ = _ := by rw [abs_of_nonneg ha]
|
| 286 |
+
have hu' := hu.trans (mul_le_mul_of_nonneg_left hdif (mul_nonneg hL0 he))
|
| 287 |
+
have hb : Real.exp (-L * base) ≤ L * Real.exp (-L * c) := by
|
| 288 |
+
have h₁ : Real.exp (-L * base) ≤ Real.exp (-L * c) :=
|
| 289 |
+
Real.exp_le_exp.mpr (by nlinarith)
|
| 290 |
+
have h₂ := mul_le_mul_of_nonneg_right hL he
|
| 291 |
+
nlinarith
|
| 292 |
+
rw [integral_maskedTerm, Finset.abs_prod]
|
| 293 |
+
calc
|
| 294 |
+
_ ≤ ∏ r, (L * Real.exp (-L * c)) * (if touched r then 1 else |delta| + alpha) := by
|
| 295 |
+
apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _)
|
| 296 |
+
intro r _
|
| 297 |
+
cases ho : own r <;> cases ht : touched r <;>
|
| 298 |
+
simp only [Bool.false_eq_true, ↓reduceIte, abs_neg, abs_zero, mul_one]
|
| 299 |
+
· exact mul_nonneg (mul_nonneg hL0 he) hd
|
| 300 |
+
· exact mul_nonneg hL0 he
|
| 301 |
+
· exact hu'
|
| 302 |
+
· simpa only [abs_of_pos (Real.exp_pos _)] using hb
|
| 303 |
+
_ = _ := by
|
| 304 |
+
rw [Finset.prod_mul_distrib]
|
| 305 |
+
simp [Finset.prod_ite, untouchedBatches]
|
| 306 |
+
omit [DecidableEq ι] in
|
| 307 |
+
|
| 308 |
+
lemma abs_integral_maskedTerm_le_designations (rate : ι → ℝ≥0) {R : ℕ}
|
| 309 |
+
(s : Finset ι) (own touched : Fin R → Bool) {L base c delta alpha : ℝ}
|
| 310 |
+
(hL : 1 ≤ L) (hmass : mass rate s = L * (base + delta - alpha))
|
| 311 |
+
(hinternal : c ≤ base + delta - alpha) (hbase : c ≤ base)
|
| 312 |
+
(ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ}
|
| 313 |
+
(hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) :
|
| 314 |
+
|∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤
|
| 315 |
+
(2 * L * Real.exp (-L * c)) ^ R * (|delta| ^ N + alpha ^ K) := by
|
| 316 |
+
have hNR : N ≤ R := hN.trans (by simpa using Finset.card_le_univ (untouchedBatches touched))
|
| 317 |
+
have hKpow : alpha ^ N ≤ alpha ^ K :=
|
| 318 |
+
pow_le_pow_of_le_one ha (by linarith [abs_nonneg delta]) hK
|
| 319 |
+
have h2pow : (2 : ℝ) ^ (N - 1) ≤ 2 ^ R :=
|
| 320 |
+
pow_le_pow_right₀ (by norm_num) ((Nat.sub_le N 1).trans hNR)
|
| 321 |
+
have hsplit : (|delta| + alpha) ^ (untouchedBatches touched).card ≤
|
| 322 |
+
2 ^ R * (|delta| ^ N + alpha ^ K) := calc
|
| 323 |
+
_ ≤ (|delta| + alpha) ^ N := pow_le_pow_of_le_one (by positivity) hd hN
|
| 324 |
+
_ ≤ 2 ^ (N - 1) * (|delta| ^ N + alpha ^ N) := add_pow_le (abs_nonneg _) ha N
|
| 325 |
+
_ ≤ _ := mul_le_mul h2pow (add_le_add le_rfl hKpow) (by positivity) (by positivity)
|
| 326 |
+
calc
|
| 327 |
+
_ ≤ (L * Real.exp (-L * c)) ^ R * (|delta| + alpha) ^ (untouchedBatches touched).card :=
|
| 328 |
+
abs_integral_maskedTerm_le_untouched rate s own touched hL hmass hinternal hbase ha
|
| 329 |
+
_ ≤ (L * Real.exp (-L * c)) ^ R * (2 ^ R * (|delta| ^ N + alpha ^ K)) :=
|
| 330 |
+
mul_le_mul_of_nonneg_left hsplit (by positivity)
|
| 331 |
+
_ = _ := by rw [← mul_assoc, ← mul_pow]; congr 2; ring
|
| 332 |
+
|
| 333 |
+
lemma two_mul_le_exp_small {L : ℝ} (hL : 10000 ≤ L) :
|
| 334 |
+
2 * L ≤ Real.exp ((3 / 50 : ℝ) * L) := by
|
| 335 |
+
have hL0 : 0 ≤ L := by linarith
|
| 336 |
+
have he := Real.quadratic_le_exp_of_nonneg (show 0 ≤ (3 / 50 : ℝ) * L by positivity)
|
| 337 |
+
have hs : 10000 * L ≤ L ^ 2 := by nlinarith [mul_nonneg (sub_nonneg.mpr hL) hL0]
|
| 338 |
+
nlinarith
|
| 339 |
+
|
| 340 |
+
lemma two_mul_score_attenuation {L : ℝ} (hL : 10000 ≤ L) (R : ℕ) :
|
| 341 |
+
(2 * L * Real.exp (-(37 / 50 : ℝ) * L)) ^ R ≤
|
| 342 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) := by
|
| 343 |
+
have h := mul_le_mul_of_nonneg_right (two_mul_le_exp_small hL)
|
| 344 |
+
(Real.exp_pos (-(37 / 50 : ℝ) * L)).le
|
| 345 |
+
rw [← Real.exp_add] at h
|
| 346 |
+
have heq : (3 / 50 : ℝ) * L + -(37 / 50 : ℝ) * L = -(17 / 25 : ℝ) * L := by ring
|
| 347 |
+
rw [heq] at h
|
| 348 |
+
have hp := pow_le_pow_left₀ (show 0 ≤ 2 * L * Real.exp (-(37 / 50 : ℝ) * L) by
|
| 349 |
+
have : 0 ≤ L := by linarith
|
| 350 |
+
positivity) h R
|
| 351 |
+
rw [← Real.exp_nat_mul] at hp
|
| 352 |
+
convert hp using 1
|
| 353 |
+
congr 1
|
| 354 |
+
ring
|
| 355 |
+
|
| 356 |
+
omit [DecidableEq ι] in
|
| 357 |
+
|
| 358 |
+
lemma simple_singleton_attenuation (rate : ι → ℝ≥0) {R : ℕ}
|
| 359 |
+
(s : Finset ι) (own touched : Fin R → Bool) {L base delta alpha : ℝ}
|
| 360 |
+
(hL : 10000 ≤ L) (hmass : mass rate s = L * (base + delta - alpha))
|
| 361 |
+
(hinternal : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base)
|
| 362 |
+
(ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ}
|
| 363 |
+
(hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) :
|
| 364 |
+
|∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤
|
| 365 |
+
Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K) := by
|
| 366 |
+
have h := abs_integral_maskedTerm_le_designations rate s own touched
|
| 367 |
+
(show 1 ≤ L by linarith) hmass hinternal hbase ha hd hN hK
|
| 368 |
+
apply h.trans
|
| 369 |
+
simpa only [neg_mul, mul_comm L (37 / 50 : ℝ)] using
|
| 370 |
+
mul_le_mul_of_nonneg_right (two_mul_score_attenuation hL R)
|
| 371 |
+
(show 0 ≤ |delta| ^ N + alpha ^ K by positivity)
|
| 372 |
+
|
| 373 |
+
noncomputable def hitIndicator (i : ι) (ω : ι → ℕ) : ℝ :=
|
| 374 |
+
1 - emptyIndicator {i} ω
|
| 375 |
+
|
| 376 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 377 |
+
lemma hitIndicator_eq (i : ι) (ω : ι → ℕ) :
|
| 378 |
+
hitIndicator i ω = if ω i = 0 then 0 else 1 := by
|
| 379 |
+
simp only [hitIndicator, emptyIndicator, emptyEvent
|
| 380 |
+
]
|
| 381 |
+
by_cases h : ω i = 0 <;> simp [h]
|
| 382 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 383 |
+
|
| 384 |
+
lemma hitIndicator_nonneg (i : ι) (ω : ι → ℕ) : 0 ≤ hitIndicator i ω := by
|
| 385 |
+
rw [hitIndicator_eq]; split <;> norm_num
|
| 386 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 387 |
+
|
| 388 |
+
lemma hitIndicator_le_one (i : ι) (ω : ι → ℕ) : hitIndicator i ω ≤ 1 := by
|
| 389 |
+
rw [hitIndicator_eq]; split <;> norm_num
|
| 390 |
+
omit [DecidableEq ι] in
|
| 391 |
+
|
| 392 |
+
lemma integrable_hitIndicator (rate : ι → ℝ≥0) (i : ι) :
|
| 393 |
+
Integrable (hitIndicator i) (batchMeasure rate) :=
|
| 394 |
+
(integrable_const 1).sub (integrable_emptyIndicator rate {i})
|
| 395 |
+
omit [DecidableEq ι] in
|
| 396 |
+
|
| 397 |
+
lemma integral_hitIndicator (rate : ι → ℝ≥0) (i : ι) :
|
| 398 |
+
(∫ ω, hitIndicator i ω ∂batchMeasure rate) = 1 - Real.exp (-(rate i : ℝ)) := by
|
| 399 |
+
unfold hitIndicator
|
| 400 |
+
rw [integral_sub (integrable_const 1) (integrable_emptyIndicator rate {i}),
|
| 401 |
+
integral_emptyIndicator]
|
| 402 |
+
simp [mass]
|
| 403 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 404 |
+
|
| 405 |
+
lemma maskedFactor_mul_hit (s : Finset ι) (i : ι) (hi : i ∈ s) (b : ℝ)
|
| 406 |
+
(own touched : Bool) (ω : ι → ℕ) :
|
| 407 |
+
maskedFactor s b own touched ω * hitIndicator i ω =
|
| 408 |
+
(if own then -b else 0) * hitIndicator i ω := by
|
| 409 |
+
rw [hitIndicator_eq]
|
| 410 |
+
by_cases hz : ω i = 0
|
| 411 |
+
· simp [hz]
|
| 412 |
+
· simp only [hz, ↓reduceIte, mul_one]
|
| 413 |
+
have hh : ω ∉ emptyEvent s := by
|
| 414 |
+
intro h
|
| 415 |
+
exact hz (h i hi)
|
| 416 |
+
cases own <;> cases touched <;> simp [maskedFactor, centeredFactor_of_hit s b ω hi hz]
|
| 417 |
+
omit [DecidableEq ι] in
|
| 418 |
+
|
| 419 |
+
lemma integral_abs_maskedFactor_hit_le (rate : ι → ℝ≥0)
|
| 420 |
+
(s : Finset ι) (i : ι) (hi : i ∈ s) (own touched : Bool)
|
| 421 |
+
{L base c : ℝ} (hL : 0 ≤ L) (hbase : c ≤ base) :
|
| 422 |
+
(∫ ω, |maskedFactor s (Real.exp (-L * base)) own touched ω| * hitIndicator i ω
|
| 423 |
+
∂batchMeasure rate) ≤ Real.exp (-L * c) * (rate i : ℝ) := by
|
| 424 |
+
have heq : (fun ω => |maskedFactor s (Real.exp (-L * base)) own touched ω| * hitIndicator i ω) =
|
| 425 |
+
fun ω => (if own then Real.exp (-L * base) else 0) * hitIndicator i ω := by
|
| 426 |
+
funext ω
|
| 427 |
+
rw [← abs_of_nonneg (hitIndicator_nonneg i ω), ← abs_mul, maskedFactor_mul_hit s i hi]
|
| 428 |
+
cases own <;>
|
| 429 |
+
simp [abs_mul, abs_of_nonneg (hitIndicator_nonneg i ω), abs_of_pos (Real.exp_pos _)]
|
| 430 |
+
rw [heq, integral_const_mul, integral_hitIndicator]
|
| 431 |
+
have hnonneg : 0 ≤ 1 - Real.exp (-(rate i : ℝ)) := by
|
| 432 |
+
have : Real.exp (-(rate i : ℝ)) ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (rate i).coe_nonneg)
|
| 433 |
+
linarith
|
| 434 |
+
have hb : Real.exp (-L * base) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by nlinarith)
|
| 435 |
+
cases own
|
| 436 |
+
· simp only [Bool.false_eq_true, ↓reduceIte, zero_mul]; positivity
|
| 437 |
+
· simp only [↓reduceIte]
|
| 438 |
+
exact mul_le_mul hb (one_sub_exp_neg_le (rate i : ℝ)) hnonneg (Real.exp_pos _).le
|
| 439 |
+
|
| 440 |
+
noncomputable def forcedHits {R : ℕ} (i : ι) (T : Finset (Fin R))
|
| 441 |
+
(ω : Fin R → ι → ℕ) : ℝ := ∏ r ∈ T, hitIndicator i (ω r)
|
| 442 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 443 |
+
|
| 444 |
+
lemma forcedHits_nonneg {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) :
|
| 445 |
+
0 ≤ forcedHits i T ω := Finset.prod_nonneg (fun _ _ => hitIndicator_nonneg _ _)
|
| 446 |
+
|
| 447 |
+
end SharpRamseyFive.PoissonScore
|
| 448 |
+
end
|
| 449 |
+
|
| 450 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/LabelledFilterCard.lean
ADDED
|
@@ -0,0 +1,469 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.CompleteProgramWeight
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
open MeasureTheory ProbabilityTheory
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
open MeasureTheory ProbabilityTheory
|
| 15 |
+
open scoped BigOperators ENNReal NNReal
|
| 16 |
+
namespace SharpRamseyFive.SelectionBridge
|
| 17 |
+
open MeasureTheory ProbabilityTheory
|
| 18 |
+
open scoped BigOperators NNReal
|
| 19 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 20 |
+
open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations
|
| 21 |
+
open SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedPrograms
|
| 22 |
+
open Classical
|
| 23 |
+
variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 24 |
+
[Fintype H] [DecidableEq H]
|
| 25 |
+
omit [DecidableEq V] [DecidableEq H] in
|
| 26 |
+
lemma labelled_filter_card (P : H → Prop) [DecidablePred P] :
|
| 27 |
+
(Finset.univ.filter (fun x : H × V => P x.1)).card =
|
| 28 |
+
(Finset.univ.filter P).card * Fintype.card V := by
|
| 29 |
+
have he : Finset.univ.filter (fun x : H × V => P x.1) =
|
| 30 |
+
(Finset.univ.filter P) ×ˢ (Finset.univ : Finset V) := by
|
| 31 |
+
ext z
|
| 32 |
+
simp
|
| 33 |
+
rw [he, Finset.card_product, Finset.card_univ]
|
| 34 |
+
omit [DecidableEq V] in
|
| 35 |
+
|
| 36 |
+
lemma vertexBadMass_nonneg (weight rate : D → ℝ≥0) (s : V → Finset D)
|
| 37 |
+
(t : ℝ) (R J : ℕ) (A : Finset V) : 0 ≤ vertexBadMass weight rate s t R J A := by
|
| 38 |
+
unfold vertexBadMass
|
| 39 |
+
exact badMass_nonneg _ _ (blockTrunc_range _ R J none) _ A
|
| 40 |
+
|
| 41 |
+
theorem all_bad_residual_sum_le (weight rate : D → ℝ≥0) (lines : H → Finset D)
|
| 42 |
+
(t : ℝ) (R : ℕ) (denom b mass : ℝ)
|
| 43 |
+
(hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass)
|
| 44 |
+
(hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass)
|
| 45 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 46 |
+
(hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K))
|
| 47 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 48 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁)
|
| 49 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 50 |
+
(Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂)
|
| 51 |
+
(A : Finset V) (g : V → H) :
|
| 52 |
+
(∑ f : V → H, if (∀ v ∉ A, g v = f v) then
|
| 53 |
+
vertexBadMass weight rate (lines ∘ f) t R J A else 0) ≤
|
| 54 |
+
denom ^ A.card * ∑ n : Fin (A.card + 1),
|
| 55 |
+
branchingBound (V := V) (B := Fin R) (fun z : H × V => lines z.1)
|
| 56 |
+
rate denom b mass K (N₁ * Fintype.card V) (N₂ * Fintype.card V) low ^ n.val := by
|
| 57 |
+
let F : (V → H × V) → ℝ := fun f =>
|
| 58 |
+
if Function.Injective f ∧ (∀ v ∉ A, labelled g v = f v) then
|
| 59 |
+
vertexBadMass weight rate ((fun z : H × V => lines z.1) ∘ f) t R J A else 0
|
| 60 |
+
have hF (f : V → H × V) : 0 ≤ F f := by
|
| 61 |
+
dsimp [F]
|
| 62 |
+
split_ifs
|
| 63 |
+
· exact vertexBadMass_nonneg weight rate _ t R J A
|
| 64 |
+
· exact le_rfl
|
| 65 |
+
have he (f : V → H) : F (labelled f) =
|
| 66 |
+
if (∀ v ∉ A, g v = f v) then vertexBadMass weight rate (lines ∘ f) t R J A else 0 := by
|
| 67 |
+
have ha : (∀ v ∉ A, labelled g v = labelled f v) ↔ (∀ v ∉ A, g v = f v) := by
|
| 68 |
+
simp only [labelled, Prod.mk.injEq, and_true]
|
| 69 |
+
simp only [F, labelled_injective, true_and, ha]
|
| 70 |
+
rfl
|
| 71 |
+
calc
|
| 72 |
+
_ = ∑ f : V → H, F (labelled f) := by simp only [he]
|
| 73 |
+
_ = ∑ f ∈ Finset.univ.image (labelled : (V → H) → (V → H × V)), F f := by
|
| 74 |
+
rw [Finset.sum_image (fun _ _ _ _ h => labelled_map_injective h)]
|
| 75 |
+
_ ≤ ∑ f : V → H × V, F f :=
|
| 76 |
+
Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun f _ _ => hF f)
|
| 77 |
+
_ ≤ _ := by
|
| 78 |
+
apply bad_residual_sum_le weight rate (fun z : H × V => lines z.1) t R
|
| 79 |
+
denom b mass hd hb hm (fun u => hmass u.1) K J h
|
| 80 |
+
(N₁ * Fintype.card V) (N₂ * Fintype.card V) hK hh low hsize herr
|
| 81 |
+
· intro d
|
| 82 |
+
exact (labelled_filter_card (V := V) (H := H) (fun u => d ∈ lines u)).le.trans
|
| 83 |
+
(Nat.mul_le_mul_right _ (hN₁ d))
|
| 84 |
+
· intro d e hde
|
| 85 |
+
exact (labelled_filter_card (V := V) (H := H) (fun u => d ∈ lines u ∧ e ∈ lines u)).le.trans
|
| 86 |
+
(Nat.mul_le_mul_right _ (hN₂ d e hde))
|
| 87 |
+
|
| 88 |
+
end SharpRamseyFive.SelectionBridge
|
| 89 |
+
|
| 90 |
+
namespace SharpRamseyFive.ResidualElimination
|
| 91 |
+
open scoped BigOperators
|
| 92 |
+
open Classical
|
| 93 |
+
variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
|
| 94 |
+
|
| 95 |
+
def Agrees (E : Finset V) (g f : V → H) : Prop := ∀ v ∉ E, f v = g v
|
| 96 |
+
|
| 97 |
+
noncomputable def completionSum (E : Finset V) (g : V → H) (F : (V → H) → ℝ) : ℝ :=
|
| 98 |
+
∑ f : V → H, if Agrees E g f then F f else 0
|
| 99 |
+
|
| 100 |
+
omit [DecidableEq H] in
|
| 101 |
+
lemma completionSum_nonneg (E : Finset V) (g : V → H) (F : (V → H) → ℝ)
|
| 102 |
+
(hF : ∀ f, 0 ≤ F f) : 0 ≤ completionSum E g F := by
|
| 103 |
+
apply Finset.sum_nonneg
|
| 104 |
+
intro f _
|
| 105 |
+
split_ifs
|
| 106 |
+
· exact hF f
|
| 107 |
+
· exact le_rfl
|
| 108 |
+
|
| 109 |
+
omit [DecidableEq H] in
|
| 110 |
+
lemma completionSum_mono (E : Finset V) (g : V → H) (F G : (V → H) → ℝ)
|
| 111 |
+
(h : ∀ f, Agrees E g f → F f ≤ G f) :
|
| 112 |
+
completionSum E g F ≤ completionSum E g G := by
|
| 113 |
+
apply Finset.sum_le_sum
|
| 114 |
+
intro f _
|
| 115 |
+
split_ifs with hf
|
| 116 |
+
· exact h f hf
|
| 117 |
+
· exact le_rfl
|
| 118 |
+
omit [DecidableEq H] in
|
| 119 |
+
|
| 120 |
+
lemma completionSum_congr (E : Finset V) (g : V → H) (F G : (V → H) → ℝ)
|
| 121 |
+
(h : ∀ f, Agrees E g f → F f = G f) :
|
| 122 |
+
completionSum E g F = completionSum E g G := by
|
| 123 |
+
apply le_antisymm <;> apply completionSum_mono
|
| 124 |
+
· exact fun f hf => le_of_eq (h f hf)
|
| 125 |
+
· exact fun f hf => le_of_eq (h f hf).symm
|
| 126 |
+
|
| 127 |
+
omit [DecidableEq H] in
|
| 128 |
+
lemma completionSum_mul (E : Finset V) (g : V → H) (c : ℝ) (F : (V → H) → ℝ) :
|
| 129 |
+
completionSum E g (fun f => c * F f) = c * completionSum E g F := by
|
| 130 |
+
simp only [completionSum, Finset.mul_sum, mul_ite, mul_zero]
|
| 131 |
+
|
| 132 |
+
omit [DecidableEq H] in
|
| 133 |
+
lemma completionSum_sum {ι : Type} (T : Finset ι) (E : Finset V) (g : V → H)
|
| 134 |
+
(F : ι → (V → H) → ℝ) :
|
| 135 |
+
completionSum E g (fun f => ∑ i ∈ T, F i f) =
|
| 136 |
+
∑ i ∈ T, completionSum E g (F i) := by
|
| 137 |
+
unfold completionSum
|
| 138 |
+
rw [Finset.sum_comm]
|
| 139 |
+
apply Finset.sum_congr rfl
|
| 140 |
+
intro f _
|
| 141 |
+
by_cases h : Agrees E g f <;> simp [h]
|
| 142 |
+
|
| 143 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 144 |
+
lemma agrees_erase_iff (E : Finset V) (g f : V → H) {u : V} (hu : u ∈ E) (x : H) :
|
| 145 |
+
Agrees (E.erase u) (Function.update g u x) f ↔ Agrees E g f ∧ f u = x := by
|
| 146 |
+
constructor
|
| 147 |
+
· intro h
|
| 148 |
+
constructor
|
| 149 |
+
· intro v hv
|
| 150 |
+
have hvu : v ≠ u := by intro he; exact hv (he ▸ hu)
|
| 151 |
+
simpa only [Function.update_of_ne hvu] using h v (by simp [hv])
|
| 152 |
+
· simpa using h u (Finset.notMem_erase u E)
|
| 153 |
+
· rintro ⟨h, hx⟩ v hv
|
| 154 |
+
by_cases hvu : v = u
|
| 155 |
+
· subst v; simpa using hx
|
| 156 |
+
· rw [Function.update_of_ne hvu]
|
| 157 |
+
exact h v (by simpa [hvu] using hv)
|
| 158 |
+
|
| 159 |
+
lemma completionSum_expose (E : Finset V) (g : V → H) {u : V} (hu : u ∈ E)
|
| 160 |
+
(F : (V → H) → ℝ) :
|
| 161 |
+
completionSum E g F = ∑ x : H, completionSum (E.erase u) (Function.update g u x) F := by
|
| 162 |
+
unfold completionSum
|
| 163 |
+
rw [Finset.sum_comm]
|
| 164 |
+
apply Finset.sum_congr rfl
|
| 165 |
+
intro f _
|
| 166 |
+
simp only [agrees_erase_iff E g f hu]
|
| 167 |
+
by_cases h : Agrees E g f
|
| 168 |
+
· simp [h, eq_comm]
|
| 169 |
+
· simp [h]
|
| 170 |
+
|
| 171 |
+
lemma completionSum_empty (g : V → H) (F : (V → H) → ℝ) :
|
| 172 |
+
completionSum ∅ g F = F g := by
|
| 173 |
+
have he (f : V → H) : Agrees ∅ g f ↔ f = g := by
|
| 174 |
+
constructor
|
| 175 |
+
· intro h
|
| 176 |
+
funext v
|
| 177 |
+
exact h v (Finset.notMem_empty v)
|
| 178 |
+
· rintro rfl v _
|
| 179 |
+
rfl
|
| 180 |
+
simp [completionSum, he]
|
| 181 |
+
|
| 182 |
+
noncomputable def term (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ)
|
| 183 |
+
(E S : Finset V) (f : V → H) : ℝ := (∏ u ∈ S, a u f) * B (E \ S) f
|
| 184 |
+
|
| 185 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 186 |
+
lemma term_nonneg (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ)
|
| 187 |
+
(ha : ∀ u f, 0 ≤ a u f) (hB : ∀ A f, 0 ≤ B A f)
|
| 188 |
+
(E S : Finset V) (f : V → H) : 0 ≤ term a B E S f :=
|
| 189 |
+
mul_nonneg (Finset.prod_nonneg (fun u _ => ha u f)) (hB _ f)
|
| 190 |
+
|
| 191 |
+
omit [Fintype V] in
|
| 192 |
+
lemma prod_erase_le (a : V → ℝ) (ha : ∀ u, a u ∈ Set.Icc (0 : ℝ) 1)
|
| 193 |
+
(S : Finset V) (v : V) : (∏ u ∈ S, a u) ≤ ∏ u ∈ S.erase v, a u := by
|
| 194 |
+
by_cases hv : v ∈ S
|
| 195 |
+
· rw [← Finset.mul_prod_erase S a hv]
|
| 196 |
+
exact mul_le_of_le_one_left (Finset.prod_nonneg (fun u _ => (ha u).1)) (ha v).2
|
| 197 |
+
· rw [Finset.erase_eq_of_notMem hv]
|
| 198 |
+
|
| 199 |
+
omit [Fintype V] in
|
| 200 |
+
lemma erase_sdiff (E S : Finset V) (u _v : V) (hu : u ∈ S) :
|
| 201 |
+
E.erase u \ S.erase u = E \ S := by
|
| 202 |
+
ext w
|
| 203 |
+
by_cases hw : w = u <;> simp [hw, hu]
|
| 204 |
+
|
| 205 |
+
omit [Fintype V] in
|
| 206 |
+
lemma double_erase_sdiff (E S : Finset V) (u v : V) (hu : u ∈ S) :
|
| 207 |
+
(E.erase u).erase v \ (S.erase u).erase v = (E \ S).erase v := by
|
| 208 |
+
ext w
|
| 209 |
+
by_cases hwu : w = u <;> by_cases hwv : w = v <;> simp [hwu, hwv, hu]
|
| 210 |
+
|
| 211 |
+
omit [Fintype H] [DecidableEq H] in
|
| 212 |
+
lemma term_shift_step (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ)
|
| 213 |
+
(W : H → H → ℝ) (ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1)
|
| 214 |
+
(hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f)
|
| 215 |
+
(hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f)
|
| 216 |
+
(hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v))
|
| 217 |
+
(E S : Finset V) {u : V} (hu : u ∈ S) (f : V → H) :
|
| 218 |
+
term a B E S f ≤ ∑ v ∈ Finset.univ.erase u,
|
| 219 |
+
W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f := by
|
| 220 |
+
have hp : 0 ≤ (∏ w ∈ S.erase u, a w f) * B (E \ S) f :=
|
| 221 |
+
mul_nonneg (Finset.prod_nonneg (fun w _ => (ha w f).1)) (hB _ f)
|
| 222 |
+
calc
|
| 223 |
+
term a B E S f = a u f * ((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := by
|
| 224 |
+
rw [term, ← Finset.mul_prod_erase S (fun w => a w f) hu, mul_assoc]
|
| 225 |
+
_ ≤ (∑ v ∈ Finset.univ.erase u, W (f u) (f v)) *
|
| 226 |
+
((∏ w ∈ S.erase u, a w f) * B (E \ S) f) :=
|
| 227 |
+
mul_le_mul_of_nonneg_right (hshift u f) hp
|
| 228 |
+
_ = ∑ v ∈ Finset.univ.erase u, W (f u) (f v) *
|
| 229 |
+
((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := by rw [Finset.sum_mul]
|
| 230 |
+
_ ≤ _ := by
|
| 231 |
+
apply Finset.sum_le_sum
|
| 232 |
+
intro v hv
|
| 233 |
+
apply mul_le_mul_of_nonneg_left _ (hW _ _)
|
| 234 |
+
unfold term
|
| 235 |
+
rw [double_erase_sdiff E S u v hu]
|
| 236 |
+
apply mul_le_mul (prod_erase_le (fun w => a w f) (fun w => ha w f) _ v)
|
| 237 |
+
(hmono _ _ (Finset.erase_subset v _) f) (hB _ f)
|
| 238 |
+
exact Finset.prod_nonneg (fun w _ => (ha w f).1)
|
| 239 |
+
|
| 240 |
+
lemma sum_known_partner (E : Finset V) (g : V → H) {u v : V} (hu : u ∈ E) (hv : v ∉ E)
|
| 241 |
+
(W : H → H → ℝ) (F : (V → H) → ℝ) (X C : ℝ)
|
| 242 |
+
(hW : ∀ x y, 0 ≤ W x y) (hX : 0 ≤ X)
|
| 243 |
+
(hrow : ∑ x : H, W x (g v) ≤ C)
|
| 244 |
+
(hF : ∀ x : H, completionSum (E.erase u) (Function.update g u x) F ≤ X) :
|
| 245 |
+
completionSum E g (fun f => W (f u) (f v) * F f) ≤ C * X := by
|
| 246 |
+
rw [completionSum_expose E g hu]
|
| 247 |
+
calc
|
| 248 |
+
_ ≤ ∑ x : H, W x (g v) * X := by
|
| 249 |
+
apply Finset.sum_le_sum
|
| 250 |
+
intro x _
|
| 251 |
+
have he : completionSum (E.erase u) (Function.update g u x)
|
| 252 |
+
(fun f => W (f u) (f v) * F f) = W x (g v) *
|
| 253 |
+
completionSum (E.erase u) (Function.update g u x) F := by
|
| 254 |
+
rw [← completionSum_mul]
|
| 255 |
+
apply completionSum_congr
|
| 256 |
+
intro f hf
|
| 257 |
+
have hfu : f u = x := by simpa using hf u (Finset.notMem_erase u E)
|
| 258 |
+
have hvu : v ≠ u := by intro he; exact hv (he ▸ hu)
|
| 259 |
+
have hfv : f v = g v := by
|
| 260 |
+
simpa only [Function.update_of_ne hvu] using hf v (by simp [hv])
|
| 261 |
+
rw [hfu, hfv]
|
| 262 |
+
rw [he]
|
| 263 |
+
exact mul_le_mul_of_nonneg_left (hF x) (hW _ _)
|
| 264 |
+
_ = (∑ x : H, W x (g v)) * X := by rw [Finset.sum_mul]
|
| 265 |
+
_ ≤ _ := mul_le_mul_of_nonneg_right hrow hX
|
| 266 |
+
|
| 267 |
+
lemma sum_new_partner (E : Finset V) (g : V → H) {u v : V}
|
| 268 |
+
(hu : u ∈ E) (hv : v ∈ E) (hne : v ≠ u)
|
| 269 |
+
(W : H → H → ℝ) (F : (V → H) → ℝ) (X C : ℝ)
|
| 270 |
+
(hW : ∀ x y, 0 ≤ W x y) (hX : 0 ≤ X)
|
| 271 |
+
(hpair : (∑ x : H, ∑ y : H, W x y) ≤ C)
|
| 272 |
+
(hF : ∀ x y : H, completionSum ((E.erase u).erase v)
|
| 273 |
+
(Function.update (Function.update g u x) v y) F ≤ X) :
|
| 274 |
+
completionSum E g (fun f => W (f u) (f v) * F f) ≤ C * X := by
|
| 275 |
+
rw [completionSum_expose E g hu]
|
| 276 |
+
have hv' : v ∈ E.erase u := Finset.mem_erase.mpr ⟨hne,hv⟩
|
| 277 |
+
calc
|
| 278 |
+
_ ≤ ∑ x : H, ∑ y : H, W x y * X := by
|
| 279 |
+
apply Finset.sum_le_sum
|
| 280 |
+
intro x _
|
| 281 |
+
rw [completionSum_expose _ _ hv']
|
| 282 |
+
apply Finset.sum_le_sum
|
| 283 |
+
intro y _
|
| 284 |
+
have he : completionSum ((E.erase u).erase v)
|
| 285 |
+
(Function.update (Function.update g u x) v y)
|
| 286 |
+
(fun f => W (f u) (f v) * F f) = W x y *
|
| 287 |
+
completionSum ((E.erase u).erase v)
|
| 288 |
+
(Function.update (Function.update g u x) v y) F := by
|
| 289 |
+
rw [← completionSum_mul]
|
| 290 |
+
apply completionSum_congr
|
| 291 |
+
intro f hf
|
| 292 |
+
have hfu : f u = x := by
|
| 293 |
+
simpa only [Function.update_of_ne hne.symm, Function.update_self] using
|
| 294 |
+
hf u (by simp)
|
| 295 |
+
have hfv : f v = y := by simpa using hf v (by simp)
|
| 296 |
+
rw [hfu, hfv]
|
| 297 |
+
rw [he]
|
| 298 |
+
exact mul_le_mul_of_nonneg_left (hF x y) (hW _ _)
|
| 299 |
+
_ = (∑ x : H, ∑ y : H, W x y) * X := by simp only [Finset.sum_mul]
|
| 300 |
+
_ ≤ _ := mul_le_mul_of_nonneg_right hpair hX
|
| 301 |
+
|
| 302 |
+
theorem shift_bad_enumeration (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ)
|
| 303 |
+
(W : H → H → ℝ) (C : ℝ) (hC : 0 ≤ C)
|
| 304 |
+
(ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1)
|
| 305 |
+
(hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f)
|
| 306 |
+
(hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f)
|
| 307 |
+
(hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v))
|
| 308 |
+
(hrow : ∀ y, (∑ x : H, W x y) ≤ C)
|
| 309 |
+
(hpair : (∑ x : H, ∑ y : H, W x y) ≤ C ^ 2)
|
| 310 |
+
(hbad : ∀ A g, completionSum A g (B A) ≤ C ^ A.card)
|
| 311 |
+
(E S : Finset V) (hS : S ⊆ E) (g : V → H) :
|
| 312 |
+
completionSum E g (term a B E S) ≤ ((Fintype.card V + 1 : ℝ) * C) ^ E.card := by
|
| 313 |
+
let M : ℝ := (Fintype.card V + 1) * C
|
| 314 |
+
have hCM : C ≤ M := by dsimp [M]; nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card V)]
|
| 315 |
+
have hM : 0 ≤ M := hC.trans hCM
|
| 316 |
+
suffices hall : ∀ E : Finset V, ∀ S, S ⊆ E → ∀ g : V → H,
|
| 317 |
+
completionSum E g (term a B E S) ≤ M ^ E.card from hall E S hS g
|
| 318 |
+
intro E
|
| 319 |
+
refine Finset.strongInductionOn E ?_
|
| 320 |
+
intro E ih S hS g
|
| 321 |
+
by_cases hs : S = ∅
|
| 322 |
+
· subst S
|
| 323 |
+
have he : term a B E ∅ = B E := by
|
| 324 |
+
funext f
|
| 325 |
+
simp [term]
|
| 326 |
+
rw [he]
|
| 327 |
+
exact (hbad E g).trans (pow_le_pow_left₀ hC hCM _)
|
| 328 |
+
obtain ⟨u,hu⟩ := Finset.nonempty_iff_ne_empty.mpr hs
|
| 329 |
+
have huE := hS hu
|
| 330 |
+
have hsub := Finset.erase_ssubset huE
|
| 331 |
+
have hS' : S.erase u ⊆ E.erase u := Finset.erase_subset_erase u hS
|
| 332 |
+
have hcard : E.card = (E.erase u).card + 1 := (Finset.card_erase_add_one huE).symm
|
| 333 |
+
calc
|
| 334 |
+
_ ≤ completionSum E g (fun f => ∑ v ∈ Finset.univ.erase u,
|
| 335 |
+
W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f) := by
|
| 336 |
+
apply completionSum_mono
|
| 337 |
+
intro f _
|
| 338 |
+
exact term_shift_step a B W ha hW hB hmono hshift E S hu f
|
| 339 |
+
_ = ∑ v ∈ Finset.univ.erase u, completionSum E g
|
| 340 |
+
(fun f => W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f) :=
|
| 341 |
+
completionSum_sum _ E g _
|
| 342 |
+
_ ≤ ∑ _v ∈ Finset.univ.erase u, C * M ^ (E.erase u).card := by
|
| 343 |
+
apply Finset.sum_le_sum
|
| 344 |
+
intro v hv
|
| 345 |
+
have hne : v ≠ u := (Finset.mem_erase.mp hv).1
|
| 346 |
+
by_cases hvE : v ∈ E
|
| 347 |
+
· have hv' : v ∈ E.erase u := Finset.mem_erase.mpr ⟨hne,hvE⟩
|
| 348 |
+
have hsmall : (E.erase u).erase v ⊂ E :=
|
| 349 |
+
Finset.ssubset_of_subset_of_ssubset (Finset.erase_subset _ _) hsub
|
| 350 |
+
have hSt : (S.erase u).erase v ⊆ (E.erase u).erase v :=
|
| 351 |
+
Finset.erase_subset_erase v hS'
|
| 352 |
+
have hbnd := sum_new_partner E g huE hvE hne W
|
| 353 |
+
(term a B ((E.erase u).erase v) ((S.erase u).erase v))
|
| 354 |
+
(M ^ ((E.erase u).erase v).card) (C ^ 2) hW (pow_nonneg hM _) hpair
|
| 355 |
+
(fun x y => ih _ hsmall _ hSt _)
|
| 356 |
+
apply hbnd.trans
|
| 357 |
+
rw [show (E.erase u).card = ((E.erase u).erase v).card + 1 from
|
| 358 |
+
(Finset.card_erase_add_one hv').symm, pow_succ M]
|
| 359 |
+
calc
|
| 360 |
+
_ = (C * C) * M ^ ((E.erase u).erase v).card := by ring
|
| 361 |
+
_ ≤ (C * M) * M ^ ((E.erase u).erase v).card :=
|
| 362 |
+
mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hCM hC) (pow_nonneg hM _)
|
| 363 |
+
_ = _ := by ring
|
| 364 |
+
· have hvS : v ∉ S := fun h => hvE (hS h)
|
| 365 |
+
rw [Finset.erase_eq_of_notMem (fun h => hvE (Finset.erase_subset u E h)),
|
| 366 |
+
Finset.erase_eq_of_notMem (fun h => hvS (Finset.erase_subset u S h))]
|
| 367 |
+
exact sum_known_partner E g huE hvE W (term a B (E.erase u) (S.erase u))
|
| 368 |
+
(M ^ (E.erase u).card) C hW (pow_nonneg hM _) (hrow (g v))
|
| 369 |
+
(fun x => ih _ hsub _ hS' _)
|
| 370 |
+
_ ≤ M * M ^ (E.erase u).card := by
|
| 371 |
+
simp only [Finset.sum_const, nsmul_eq_mul]
|
| 372 |
+
rw [← mul_assoc]
|
| 373 |
+
apply mul_le_mul_of_nonneg_right _ (pow_nonneg hM _)
|
| 374 |
+
change ((Finset.univ.erase u).card : ℝ) * C ≤ M
|
| 375 |
+
have hc : ((Finset.univ.erase u).card : ℝ) ≤ (Fintype.card V : ℝ) := by
|
| 376 |
+
exact_mod_cast Finset.card_le_card (Finset.erase_subset u (Finset.univ : Finset V))
|
| 377 |
+
dsimp [M]
|
| 378 |
+
nlinarith
|
| 379 |
+
_ = _ := by rw [hcard, pow_succ]; ring
|
| 380 |
+
|
| 381 |
+
end SharpRamseyFive.ResidualElimination
|
| 382 |
+
|
| 383 |
+
namespace SharpRamseyFive.SingletonEnumeration
|
| 384 |
+
open MeasureTheory ProbabilityTheory
|
| 385 |
+
open scoped BigOperators NNReal
|
| 386 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 387 |
+
open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations
|
| 388 |
+
open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms
|
| 389 |
+
open SharpRamseyFive.ResidualElimination
|
| 390 |
+
open Classical
|
| 391 |
+
variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 392 |
+
[Fintype H] [DecidableEq H]
|
| 393 |
+
omit [DecidableEq V] in
|
| 394 |
+
|
| 395 |
+
lemma vertexBadMass_antitone (weight rate : D → ℝ≥0) (s : V → Finset D)
|
| 396 |
+
(t : ℝ) (R J : ℕ) {A A' : Finset V} (hA : A' ⊆ A) :
|
| 397 |
+
vertexBadMass weight rate s t R J A ≤ vertexBadMass weight rate s t R J A' := by
|
| 398 |
+
unfold vertexBadMass badMass
|
| 399 |
+
apply integral_mono
|
| 400 |
+
(badTerm_integrable _ _ (blockTrunc_range _ R J none) _ A)
|
| 401 |
+
(badTerm_integrable _ _ (blockTrunc_range _ R J none) _ A')
|
| 402 |
+
intro z
|
| 403 |
+
apply mul_le_mul_of_nonneg_left _ (blockTrunc_range _ R J none z).1
|
| 404 |
+
exact Finset.prod_le_prod_of_subset_of_le_one₀ hA
|
| 405 |
+
(fun v _ => (badIndicator_range _ v z).1)
|
| 406 |
+
(fun v _ _ => (badIndicator_range _ v z).2)
|
| 407 |
+
|
| 408 |
+
lemma sum_powers_le (x : ℝ) (hx : 0 ≤ x) (n : ℕ) :
|
| 409 |
+
(∑ i ∈ Finset.range (n + 1), x ^ i) ≤ (1 + x) ^ n := by
|
| 410 |
+
induction n with
|
| 411 |
+
| zero => simp
|
| 412 |
+
| succ n ih =>
|
| 413 |
+
rw [Finset.sum_range_succ]
|
| 414 |
+
calc
|
| 415 |
+
_ ≤ (1 + x) ^ n + x ^ (n + 1) := add_le_add ih le_rfl
|
| 416 |
+
_ ≤ (1 + x) ^ n + x * (1 + x) ^ n := by
|
| 417 |
+
rw [pow_succ']
|
| 418 |
+
exact add_le_add le_rfl (mul_le_mul_of_nonneg_left
|
| 419 |
+
(pow_le_pow_left₀ hx (by linarith : x ≤ 1 + x) n) hx)
|
| 420 |
+
_ = _ := by rw [pow_succ]; ring
|
| 421 |
+
|
| 422 |
+
lemma actual_bad_completion (weight rate : D → ℝ≥0) (lines : H → Finset D)
|
| 423 |
+
(t : ℝ) (R : ℕ) (denom b mass : ℝ)
|
| 424 |
+
(hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass)
|
| 425 |
+
(hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass)
|
| 426 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 427 |
+
(hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K))
|
| 428 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 429 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁)
|
| 430 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 431 |
+
(Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂)
|
| 432 |
+
(A : Finset V) (g : V → H) :
|
| 433 |
+
completionSum A g (fun f => vertexBadMass weight rate (lines ∘ f) t R J A) ≤
|
| 434 |
+
(denom * (1 + branchingBound (V := V) (B := Fin R)
|
| 435 |
+
(fun z : H × V => lines z.1) rate denom b mass K
|
| 436 |
+
(N₁ * Fintype.card V) (N₂ * Fintype.card V) low)) ^ A.card := by
|
| 437 |
+
have he : completionSum A g (fun f => vertexBadMass weight rate (lines ∘ f) t R J A) =
|
| 438 |
+
∑ f : V → H, if (∀ v ∉ A, g v = f v) then
|
| 439 |
+
vertexBadMass weight rate (lines ∘ f) t R J A else 0 := by
|
| 440 |
+
unfold completionSum
|
| 441 |
+
apply Finset.sum_congr rfl
|
| 442 |
+
intro f _
|
| 443 |
+
have : Agrees A g f ↔ (∀ v ∉ A, g v = f v) := by
|
| 444 |
+
simp only [Agrees, eq_comm]
|
| 445 |
+
simp only [this]
|
| 446 |
+
rw [he]
|
| 447 |
+
apply (all_bad_residual_sum_le weight rate lines t R denom b mass hd hb hm hmass
|
| 448 |
+
K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ A g).trans
|
| 449 |
+
rw [mul_pow]
|
| 450 |
+
apply mul_le_mul_of_nonneg_left _ (pow_nonneg hd.le _)
|
| 451 |
+
rw [Fin.sum_univ_eq_sum_range]
|
| 452 |
+
apply sum_powers_le
|
| 453 |
+
exact branchingBound_nonneg _ _ _ _ _ hd.le (by linarith) hm _ _ _ _
|
| 454 |
+
|
| 455 |
+
noncomputable def shiftKernel (weight : D → ℝ≥0) (lines : H → Finset D) (p K : ℕ)
|
| 456 |
+
(x y : H) : ℝ := min 1 (((p : ℝ) * mass weight (lines x ∩ lines y)) ^ K)
|
| 457 |
+
|
| 458 |
+
omit [Fintype H] [DecidableEq H] in
|
| 459 |
+
omit [Fintype D] in
|
| 460 |
+
lemma shiftKernel_range (weight : D → ℝ≥0) (lines : H → Finset D) (p K : ℕ)
|
| 461 |
+
(x y : H) : shiftKernel weight lines p K x y ∈ Set.Icc (0 : ℝ) 1 := by
|
| 462 |
+
unfold shiftKernel
|
| 463 |
+
exact ⟨le_min zero_le_one (pow_nonneg (mul_nonneg (Nat.cast_nonneg _) (mass_nonneg _ _)) _),
|
| 464 |
+
min_le_left _ _⟩
|
| 465 |
+
|
| 466 |
+
end SharpRamseyFive.SingletonEnumeration
|
| 467 |
+
end
|
| 468 |
+
|
| 469 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/LargeCard.lean
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.SinglesUnique
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
open MeasureTheory ProbabilityTheory
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
open MeasureTheory ProbabilityTheory
|
| 15 |
+
open scoped BigOperators ENNReal NNReal
|
| 16 |
+
namespace SharpRamseyFive.AmbientEnumeration
|
| 17 |
+
open scoped BigOperators NNReal
|
| 18 |
+
open Classical
|
| 19 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 20 |
+
open SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartition
|
| 21 |
+
open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination
|
| 22 |
+
open SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridge
|
| 23 |
+
variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 24 |
+
[Fintype H] [DecidableEq H]
|
| 25 |
+
omit [Fintype D] in
|
| 26 |
+
lemma large_card (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) :
|
| 27 |
+
Fintype.card (Components weight s t) - (simpleSet weight s t).card =
|
| 28 |
+
(largeLabels (componentMap (strongGraph weight s t))).card := by
|
| 29 |
+
rw [← large_image, Finset.card_image_of_injective _ (vertex_injective weight s t),
|
| 30 |
+
Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ]
|
| 31 |
+
|
| 32 |
+
end SharpRamseyFive.AmbientEnumeration
|
| 33 |
+
|
| 34 |
+
namespace SharpRamseyFive.AmbientEnumeration
|
| 35 |
+
open MeasureTheory ProbabilityTheory
|
| 36 |
+
open scoped BigOperators NNReal
|
| 37 |
+
open Classical
|
| 38 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 39 |
+
open SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartition
|
| 40 |
+
open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination
|
| 41 |
+
open SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridge
|
| 42 |
+
open SharpRamseyFive.WeightedPrograms
|
| 43 |
+
variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 44 |
+
[Fintype H] [DecidableEq H]
|
| 45 |
+
|
| 46 |
+
noncomputable def vertexExpansion (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 47 |
+
(t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (E : Finset V) (f : V → H) : ℝ :=
|
| 48 |
+
badExpansion
|
| 49 |
+
(fun u f => independentWeight weight (fun d => L * weight d) lines R J base (f u) +
|
| 50 |
+
alpha weight (lines ∘ f) t u ^ K)
|
| 51 |
+
(fun A f => vertexBadMass weight (fun d => L * weight d) (lines ∘ f) t R J A) E f
|
| 52 |
+
omit [Fintype H] [DecidableEq H] in
|
| 53 |
+
|
| 54 |
+
lemma vertexExpansion_nonneg (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 55 |
+
(t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (E : Finset V) (f : V → H) :
|
| 56 |
+
0 ≤ vertexExpansion weight lines t R J K L base E f := by
|
| 57 |
+
apply Finset.sum_nonneg
|
| 58 |
+
intro U _
|
| 59 |
+
apply mul_nonneg
|
| 60 |
+
· apply Finset.prod_nonneg
|
| 61 |
+
intro u _
|
| 62 |
+
exact add_nonneg (independentWeight_nonneg _ _ _ _ _ _ _) (pow_nonneg (alpha_nonneg _ _ _ _) _)
|
| 63 |
+
· exact vertexBadMass_nonneg _ _ _ _ _ _ _
|
| 64 |
+
omit [Fintype H] [DecidableEq H] in
|
| 65 |
+
|
| 66 |
+
lemma designated_le_partition (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 67 |
+
(t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (f : V → H) :
|
| 68 |
+
designatedBound weight (lines ∘ f) t R J K L base ≤
|
| 69 |
+
Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) ^
|
| 70 |
+
(largeLabels (componentMap (strongGraph weight (lines ∘ f) t))).card *
|
| 71 |
+
(Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) ^
|
| 72 |
+
(singles (componentMap (strongGraph weight (lines ∘ f) t))).card *
|
| 73 |
+
vertexExpansion weight lines t R J K L base
|
| 74 |
+
(singles (componentMap (strongGraph weight (lines ∘ f) t))) f) := by
|
| 75 |
+
have ht := mul_le_mul_of_nonneg_left
|
| 76 |
+
(designation_sum_le_vertex weight lines f t R J K L base)
|
| 77 |
+
(show 0 ≤ Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) ^ (simpleSet weight (lines ∘ f) t).card *
|
| 78 |
+
Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) ^
|
| 79 |
+
(Fintype.card (Components weight (lines ∘ f) t) - (simpleSet weight (lines ∘ f) t).card) by positivity)
|
| 80 |
+
change designatedBound weight (lines ∘ f) t R J K L base ≤ _ at ht
|
| 81 |
+
rw [large_card, simple_card, simple_image] at ht
|
| 82 |
+
exact ht.trans_eq (by unfold vertexExpansion; ring)
|
| 83 |
+
|
| 84 |
+
theorem designation_sum_enumerated (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 85 |
+
{p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p)
|
| 86 |
+
(R : ℕ) (L : ℝ≥0) (denom rootB mass C D₀ base A : ℝ)
|
| 87 |
+
(hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C)
|
| 88 |
+
(hD : 0 ≤ D₀) (hA : 0 ≤ A)
|
| 89 |
+
(hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass)
|
| 90 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 91 |
+
(hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K))
|
| 92 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 93 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁)
|
| 94 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 95 |
+
(Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂)
|
| 96 |
+
(hBC : denom * (1 + branchingBound (V := V) (B := Fin R)
|
| 97 |
+
(fun z : H × V => lines z.1) (fun d => L * weight d) denom rootB mass K
|
| 98 |
+
(N₁ * Fintype.card V) (N₂ * Fintype.card V) low) ≤ C)
|
| 99 |
+
(hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C)
|
| 100 |
+
(hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2)
|
| 101 |
+
(hDsum : (∑ x : H, independentWeight weight (fun d => L * weight d) lines R J base x) ≤ D₀)
|
| 102 |
+
(hsingle : Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) *
|
| 103 |
+
(D₀ + 2 * ((Fintype.card V + 1 : ℝ) * C)) ≤ A)
|
| 104 |
+
(Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ)
|
| 105 |
+
(hnum : ∀ m : ℕ, 2 ≤ m → m ≤ Fintype.card V →
|
| 106 |
+
Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) *
|
| 107 |
+
((m : ℝ) ^ 2 * Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) *
|
| 108 |
+
((m : ℝ) ^ 2 * Δ) ^ (m - 2)) ≤ A ^ m) :
|
| 109 |
+
(∑ f : V → H, designatedBound weight (lines ∘ f) (1 / (100 * p)) R J K L base) ≤
|
| 110 |
+
(Fintype.card V : ℝ) ^ Fintype.card V * A ^ Fintype.card V := by
|
| 111 |
+
let t : ℝ := 1 / (100 * p)
|
| 112 |
+
let a := Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R))
|
| 113 |
+
let b := Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R))
|
| 114 |
+
let F (E : Finset V) (f : V → H) := a ^ E.card * vertexExpansion weight lines t R J K L base E f
|
| 115 |
+
have hres (r : V → V) (g : V → H) :
|
| 116 |
+
completionSum (singles r) g (F (singles r)) ≤ A ^ (singles r).card := by
|
| 117 |
+
change completionSum (singles r) g (fun f => a ^ (singles r).card *
|
| 118 |
+
vertexExpansion weight lines t R J K L base (singles r) f) ≤ _
|
| 119 |
+
rw [completionSum_mul]
|
| 120 |
+
apply (mul_le_mul_of_nonneg_left (actual_all_singleton_enumeration weight
|
| 121 |
+
(fun d => L * weight d) lines hp hc R denom rootB mass C D₀ base hd hb hm hC hD
|
| 122 |
+
hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ hBC hrow hpair hDsum (singles r) g)
|
| 123 |
+
(show 0 ≤ a ^ (singles r).card by dsimp [a]; positivity)).trans
|
| 124 |
+
rw [← mul_pow]
|
| 125 |
+
exact pow_le_pow_left₀ (by positivity) hsingle _
|
| 126 |
+
apply (Finset.sum_le_sum (fun f _ => designated_le_partition weight lines t R J K L base f)).trans
|
| 127 |
+
have ht := graph_partition_sum (V := V) (overlapRelation weight lines t)
|
| 128 |
+
(overlapRelation_symm weight lines t) b A (Real.exp_pos _).le hA Δ hΔ hnum F
|
| 129 |
+
(fun E f => mul_nonneg (pow_nonneg (Real.exp_pos _).le _) (vertexExpansion_nonneg _ _ _ _ _ _ _ _ _ _)) hres
|
| 130 |
+
simpa only [relation_graph_eq] using ht
|
| 131 |
+
|
| 132 |
+
end SharpRamseyFive.AmbientEnumeration
|
| 133 |
+
|
| 134 |
+
namespace SharpRamseyFive.MomentBudgets
|
| 135 |
+
open scoped BigOperators
|
| 136 |
+
|
| 137 |
+
lemma block_cost (P B E Δ : ℝ) (p m : ℕ) (hP : 0 ≤ P) (hB : 0 ≤ B)
|
| 138 |
+
(hE : 0 ≤ E) (hΔ : 0 ≤ Δ) (hm : 2 ≤ m) (hmp : m ≤ p)
|
| 139 |
+
(hp : (p : ℝ) ^ 2 ≤ Real.exp (P / 10))
|
| 140 |
+
(hpair : E ≤ B ^ 2 * Real.exp (P / 10))
|
| 141 |
+
(hdeg : Δ ≤ B * Real.exp (-P)) :
|
| 142 |
+
Real.exp (-(7 / 10 : ℝ) * P) *
|
| 143 |
+
((m : ℝ) ^ 2 * E * ((m : ℝ) ^ 2 * Δ) ^ (m - 2)) ≤
|
| 144 |
+
(B * Real.exp (-(1 / 5 : ℝ) * P)) ^ m := by
|
| 145 |
+
let A := B * Real.exp (-(1 / 5 : ℝ) * P)
|
| 146 |
+
have hA : 0 ≤ A := mul_nonneg hB (Real.exp_pos _).le
|
| 147 |
+
have hm2 : (m : ℝ) ^ 2 ≤ Real.exp (P / 10) := by
|
| 148 |
+
apply (pow_le_pow_left₀ (by positivity) (show (m : ℝ) ≤ p by exact_mod_cast hmp) 2).trans hp
|
| 149 |
+
have hfirst : Real.exp (-(7 / 10 : ℝ) * P) * ((m : ℝ) ^ 2 * E) ≤ A ^ 2 := by
|
| 150 |
+
calc
|
| 151 |
+
_ ≤ Real.exp (-(7 / 10 : ℝ) * P) * (Real.exp (P / 10) * (B ^ 2 * Real.exp (P / 10))) := by
|
| 152 |
+
exact mul_le_mul_of_nonneg_left (mul_le_mul hm2 hpair hE (Real.exp_pos _).le) (Real.exp_pos _).le
|
| 153 |
+
_ = B ^ 2 * Real.exp (-(1 / 2 : ℝ) * P) := by
|
| 154 |
+
rw [show Real.exp (-(7 / 10 : ℝ) * P) * (Real.exp (P / 10) * (B ^ 2 * Real.exp (P / 10))) =
|
| 155 |
+
B ^ 2 * (Real.exp (-(7 / 10 : ℝ) * P) * Real.exp (P / 10) * Real.exp (P / 10)) by ring]
|
| 156 |
+
rw [← Real.exp_add, ← Real.exp_add]
|
| 157 |
+
congr 2
|
| 158 |
+
ring
|
| 159 |
+
_ ≤ B ^ 2 * Real.exp (-(2 / 5 : ℝ) * P) := by
|
| 160 |
+
exact mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) (sq_nonneg B)
|
| 161 |
+
_ = A ^ 2 := by
|
| 162 |
+
dsimp [A]
|
| 163 |
+
rw [mul_pow, ← Real.exp_nat_mul]
|
| 164 |
+
congr 2
|
| 165 |
+
ring
|
| 166 |
+
have hstep : (m : ℝ) ^ 2 * Δ ≤ A := by
|
| 167 |
+
calc
|
| 168 |
+
_ ≤ Real.exp (P / 10) * (B * Real.exp (-P)) :=
|
| 169 |
+
mul_le_mul hm2 hdeg hΔ (Real.exp_pos _).le
|
| 170 |
+
_ = B * Real.exp (-(9 / 10 : ℝ) * P) := by
|
| 171 |
+
rw [show Real.exp (P / 10) * (B * Real.exp (-P)) = B * (Real.exp (P / 10) * Real.exp (-P)) by ring,
|
| 172 |
+
← Real.exp_add]
|
| 173 |
+
congr 2
|
| 174 |
+
ring
|
| 175 |
+
_ ≤ A := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) hB
|
| 176 |
+
calc
|
| 177 |
+
_ = (Real.exp (-(7 / 10 : ℝ) * P) * ((m : ℝ) ^ 2 * E)) *
|
| 178 |
+
((m : ℝ) ^ 2 * Δ) ^ (m - 2) := by ring
|
| 179 |
+
_ ≤ A ^ 2 * A ^ (m - 2) := mul_le_mul hfirst
|
| 180 |
+
(pow_le_pow_left₀ (mul_nonneg (sq_nonneg _) hΔ) hstep _) (by positivity) (pow_nonneg hA _)
|
| 181 |
+
_ = A ^ m := by rw [← pow_add, Nat.add_sub_of_le hm]
|
| 182 |
+
|
| 183 |
+
lemma singleton_cost (P B M : ℝ) (hP : 0 ≤ P) (hB : 0 ≤ B)
|
| 184 |
+
(hM : M ≤ B * Real.exp (P / 5)) :
|
| 185 |
+
Real.exp (-(17 / 25 : ℝ) * P) * M ≤ B * Real.exp (-(1 / 5 : ℝ) * P) := by
|
| 186 |
+
calc
|
| 187 |
+
_ ≤ Real.exp (-(17 / 25 : ℝ) * P) * (B * Real.exp (P / 5)) :=
|
| 188 |
+
mul_le_mul_of_nonneg_left hM (Real.exp_pos _).le
|
| 189 |
+
_ = B * Real.exp (-(12 / 25 : ℝ) * P) := by
|
| 190 |
+
rw [show Real.exp (-(17 / 25 : ℝ) * P) * (B * Real.exp (P / 5)) =
|
| 191 |
+
B * (Real.exp (-(17 / 25 : ℝ) * P) * Real.exp (P / 5)) by ring, ← Real.exp_add]
|
| 192 |
+
congr 2
|
| 193 |
+
ring
|
| 194 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) hB
|
| 195 |
+
|
| 196 |
+
lemma partition_cost (P B : ℝ) (p : ℕ) (hB : 0 ≤ B)
|
| 197 |
+
(hp : (p : ℝ) ≤ Real.exp (P / 10)) :
|
| 198 |
+
(p : ℝ) ^ p * (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ p ≤
|
| 199 |
+
B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * P)) := by
|
| 200 |
+
calc
|
| 201 |
+
_ ≤ Real.exp (P / 10) ^ p * (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ p :=
|
| 202 |
+
mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by positivity) hp _) (by positivity)
|
| 203 |
+
_ = _ := by
|
| 204 |
+
rw [← mul_pow, show Real.exp (P / 10) * (B * Real.exp (-(1 / 5 : ℝ) * P)) =
|
| 205 |
+
B * (Real.exp (P / 10) * Real.exp (-(1 / 5 : ℝ) * P)) by ring, ← Real.exp_add,
|
| 206 |
+
mul_pow, ← Real.exp_nat_mul]
|
| 207 |
+
congr 2
|
| 208 |
+
ring
|
| 209 |
+
|
| 210 |
+
end SharpRamseyFive.MomentBudgets
|
| 211 |
+
|
| 212 |
+
namespace SharpRamseyFive.AmbientEnumeration
|
| 213 |
+
open MeasureTheory ProbabilityTheory
|
| 214 |
+
open scoped BigOperators NNReal
|
| 215 |
+
open Classical
|
| 216 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 217 |
+
open SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartition
|
| 218 |
+
open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination
|
| 219 |
+
open SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridge
|
| 220 |
+
open SharpRamseyFive.WeightedPrograms
|
| 221 |
+
variable {D H : Type} [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H]
|
| 222 |
+
|
| 223 |
+
theorem ambient_refined_truncated_moment (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 224 |
+
{p : ℕ} (hp : 0 < p) (R : ℕ) (own : H → Fin R → Bool)
|
| 225 |
+
(L : ℝ≥0) (denom rootB mass C D₀ base B : ℝ)
|
| 226 |
+
(hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base)
|
| 227 |
+
(hlower : ∀ k, (3 / 4 : ℝ) ≤ PoissonScore.mass weight (lines k))
|
| 228 |
+
(hdelta : ∀ k, |PoissonScore.mass weight (lines k) - base| ≤ (17 / 100 : ℝ))
|
| 229 |
+
(hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C)
|
| 230 |
+
(hD : 0 ≤ D₀) (hB : 0 ≤ B)
|
| 231 |
+
(hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass)
|
| 232 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hKR : K ≤ R / 2) (hh : 0 < h) (low : Bool)
|
| 233 |
+
(hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K))
|
| 234 |
+
(herr : (p : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 235 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁)
|
| 236 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 237 |
+
(Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂)
|
| 238 |
+
(hBC : denom * (1 + branchingBound (V := Fin p) (B := Fin R)
|
| 239 |
+
(fun z : H × Fin p => lines z.1) (fun d => L * weight d) denom rootB mass K
|
| 240 |
+
(N₁ * p) (N₂ * p) low) ≤ C)
|
| 241 |
+
(hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C)
|
| 242 |
+
(hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2)
|
| 243 |
+
(hDsum : (∑ x : H, independentWeight weight (fun d => L * weight d) lines R J base x) ≤ D₀)
|
| 244 |
+
(hcost : D₀ + 2 * ((p + 1 : ℝ) * C) ≤ B * Real.exp (((L : ℝ) * R) / 5))
|
| 245 |
+
(hp2 : (p : ℝ) ^ 2 ≤ Real.exp (((L : ℝ) * R) / 10))
|
| 246 |
+
(Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ)
|
| 247 |
+
(hdeg : (Δ : ℝ) ≤ B * Real.exp (-((L : ℝ) * R)))
|
| 248 |
+
(hRelPairs : (Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) : ℝ) ≤
|
| 249 |
+
B ^ 2 * Real.exp (((L : ℝ) * R) / 10)) :
|
| 250 |
+
(∫ ω, HighMoment.allTrunc R J ω *
|
| 251 |
+
(∑ k : H, scoreTerm (lines k) (Real.exp (-(L : ℝ) * base)) (own k)
|
| 252 |
+
(fun r d => ω (r,d))) ^ p
|
| 253 |
+
∂batchMeasure (fun i : Fin R × D => L * weight i.2)) ≤
|
| 254 |
+
B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * ((L : ℝ) * R))) := by
|
| 255 |
+
have hP : 0 ≤ (L : ℝ) * R := by positivity
|
| 256 |
+
apply (truncated_power_designated weight R J K L base lines own hp hL hbase hlower hdelta hKR).trans
|
| 257 |
+
have hs := designation_sum_enumerated (V := Fin p) weight lines hp (by simp)
|
| 258 |
+
R L denom rootB mass C D₀ base (B * Real.exp (-(1 / 5 : ℝ) * ((L : ℝ) * R))) hd hb hm hC hD
|
| 259 |
+
(by positivity) hmass K J h N₁ N₂ hK hh low hsize
|
| 260 |
+
(by simpa only [Fintype.card_fin] using herr) hN₁ hN₂
|
| 261 |
+
(by simpa only [Fintype.card_fin] using hBC) hrow hpair hDsum
|
| 262 |
+
(by simpa only [Fintype.card_fin] using MomentBudgets.singleton_cost _ B _ hP hB hcost)
|
| 263 |
+
Δ hΔ (fun m hm hmp => MomentBudgets.block_cost _ B _ _ p m hP hB
|
| 264 |
+
(by positivity) (by positivity) hm (by simpa only [Fintype.card_fin] using hmp) hp2 hRelPairs hdeg)
|
| 265 |
+
apply hs.trans
|
| 266 |
+
simp only [Fintype.card_fin]
|
| 267 |
+
apply MomentBudgets.partition_cost _ B p hB
|
| 268 |
+
have hpr : (1 : ℝ) ≤ p := by exact_mod_cast hp
|
| 269 |
+
exact (show (p : ℝ) ≤ (p : ℝ) ^ 2 by nlinarith).trans hp2
|
| 270 |
+
|
| 271 |
+
omit [DecidableEq D] in
|
| 272 |
+
|
| 273 |
+
lemma allTrunc_eq_one {R J : ℕ} (h : R < J) (ω : Fin R × D → ℕ) :
|
| 274 |
+
HighMoment.allTrunc R J ω = 1 := by
|
| 275 |
+
apply Finset.prod_eq_one
|
| 276 |
+
intro d _
|
| 277 |
+
unfold lineTrunc
|
| 278 |
+
apply ite_eq_left
|
| 279 |
+
exact (show (Finset.univ.filter (fun r => ω (r,d) ≠ 0)).card ≤ R by
|
| 280 |
+
simpa only [Finset.card_univ, Fintype.card_fin] using
|
| 281 |
+
Finset.card_le_card (Finset.filter_subset (fun r : Fin R => ω (r,d) ≠ 0) Finset.univ)).trans_lt h
|
| 282 |
+
|
| 283 |
+
theorem ambient_untruncated_moment (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 284 |
+
{p : ℕ} (hp : 0 < p) (R : ℕ) (own : H → Fin R → Bool)
|
| 285 |
+
(L : ℝ≥0) (denom rootB mass C D₀ base B : ℝ)
|
| 286 |
+
(hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base)
|
| 287 |
+
(hlower : ∀ k, (3 / 4 : ℝ) ≤ PoissonScore.mass weight (lines k))
|
| 288 |
+
(hdelta : ∀ k, |PoissonScore.mass weight (lines k) - base| ≤ (17 / 100 : ℝ))
|
| 289 |
+
(hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C)
|
| 290 |
+
(hD : 0 ≤ D₀) (hB : 0 ≤ B)
|
| 291 |
+
(hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass)
|
| 292 |
+
(K h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hKR : K ≤ R / 2) (hh : 0 < h)
|
| 293 |
+
(hsize : h ≤ (R / 2) / (2 * K))
|
| 294 |
+
(herr : (p : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 295 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁)
|
| 296 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 297 |
+
(Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂)
|
| 298 |
+
(hBC : denom * (1 + branchingBound (V := Fin p) (B := Fin R)
|
| 299 |
+
(fun z : H × Fin p => lines z.1) (fun d => L * weight d) denom rootB mass K
|
| 300 |
+
(N₁ * p) (N₂ * p) true) ≤ C)
|
| 301 |
+
(hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C)
|
| 302 |
+
(hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2)
|
| 303 |
+
(hDsum : (∑ x : H, |PoissonScore.mass weight (lines x) - base| ^ (R / 2)) ≤ D₀)
|
| 304 |
+
(hcost : D₀ + 2 * ((p + 1 : ℝ) * C) ≤ B * Real.exp (((L : ℝ) * R) / 5))
|
| 305 |
+
(hp2 : (p : ℝ) ^ 2 ≤ Real.exp (((L : ℝ) * R) / 10))
|
| 306 |
+
(Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ)
|
| 307 |
+
(hdeg : (Δ : ℝ) ≤ B * Real.exp (-((L : ℝ) * R)))
|
| 308 |
+
(hRelPairs : (Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) : ℝ) ≤
|
| 309 |
+
B ^ 2 * Real.exp (((L : ℝ) * R) / 10)) :
|
| 310 |
+
(∫ ω, (∑ k : H, scoreTerm (lines k) (Real.exp (-(L : ℝ) * base)) (own k)
|
| 311 |
+
(fun r d => ω (r,d))) ^ p
|
| 312 |
+
∂batchMeasure (fun i : Fin R × D => L * weight i.2)) ≤
|
| 313 |
+
B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * ((L : ℝ) * R))) := by
|
| 314 |
+
have hs := ambient_refined_truncated_moment weight lines hp R own L denom rootB mass C D₀ base B
|
| 315 |
+
hL hbase hlower hdelta hd hb hm hC hD hB hmass K (R+1) h N₁ N₂ hK hKR hh true
|
| 316 |
+
(by simpa using hsize) herr hN₁ hN₂ hBC hrow hpair
|
| 317 |
+
(by simpa only [independentWeight, Nat.lt_succ_self, ite_true, add_zero] using hDsum)
|
| 318 |
+
hcost hp2 Δ hΔ hdeg hRelPairs
|
| 319 |
+
simpa only [allTrunc_eq_one (Nat.lt_succ_self R), one_mul] using hs
|
| 320 |
+
|
| 321 |
+
end SharpRamseyFive.AmbientEnumeration
|
| 322 |
+
|
| 323 |
+
namespace SharpLogRamsey.MomentBudgetBridge
|
| 324 |
+
|
| 325 |
+
def anchorBudget (p : ℕ) (P : ℝ) : ℝ := 200 * (p : ℝ) + 2 * P
|
| 326 |
+
|
| 327 |
+
def certificateOverhead (p D : ℕ) (P : ℝ) : ℝ :=
|
| 328 |
+
1 + 4 * (p : ℝ)^2 + 4 * (p : ℝ)^3 * anchorBudget p P +
|
| 329 |
+
(p : ℝ)^4 * (anchorBudget p P)^2 +
|
| 330 |
+
(p : ℝ)^4 * ((D : ℝ)+4) * (2*P)^200
|
| 331 |
+
|
| 332 |
+
lemma anchorBudget_nonneg (p : ℕ) {P : ℝ} (hP : 0 ≤ P) :
|
| 333 |
+
0 ≤ anchorBudget p P := by
|
| 334 |
+
unfold anchorBudget
|
| 335 |
+
positivity
|
| 336 |
+
|
| 337 |
+
lemma certificateOverhead_nonneg (p D : ℕ) {P : ℝ} (hP : 0 ≤ P) :
|
| 338 |
+
0 ≤ certificateOverhead p D P := by
|
| 339 |
+
have hA := anchorBudget_nonneg p hP
|
| 340 |
+
unfold certificateOverhead
|
| 341 |
+
positivity
|
| 342 |
+
|
| 343 |
+
theorem labelled_branching_bound (p D : ℕ) (P B H N M : ℝ)
|
| 344 |
+
(hP : 0 ≤ P) (hB : 1 ≤ B) (hH : H ≤ 4*B^2) (hN : N ≤ 4*B)
|
| 345 |
+
(hM : M ≤ (p : ℝ)^2 * (B^2 * Real.exp (P/50) * ((D : ℝ)+4) * (2*P)^200)) :
|
| 346 |
+
1 + (((p : ℝ)*(H*p)/B)/B^8 +
|
| 347 |
+
(p : ℝ)^2*(N*p)*anchorBudget p P/B +
|
| 348 |
+
((p : ℝ)^3*p*(anchorBudget p P)^2/B)*B +
|
| 349 |
+
(p : ℝ)^2*M/B^2) ≤ Real.exp (P/50)*certificateOverhead p D P := by
|
| 350 |
+
have hB0 : 0 < B := lt_of_lt_of_le zero_lt_one hB
|
| 351 |
+
have hp : (0 : ℝ) ≤ p := Nat.cast_nonneg p
|
| 352 |
+
have hA := anchorBudget_nonneg p hP
|
| 353 |
+
have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity)
|
| 354 |
+
have hroot : ((p : ℝ)*(H*p)/B)/B^8 ≤ 4*(p : ℝ)^2 := by
|
| 355 |
+
apply (div_le_iff₀ (pow_pos hB0 8)).mpr
|
| 356 |
+
apply (div_le_iff₀ hB0).mpr
|
| 357 |
+
have hpow : B^2 ≤ B^9 := pow_le_pow_right₀ hB (by decide)
|
| 358 |
+
calc
|
| 359 |
+
(p : ℝ)*(H*p) ≤ (p : ℝ)*(4*B^2*p) :=
|
| 360 |
+
mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hH hp) hp
|
| 361 |
+
_ = 4*(p : ℝ)^2*B^2 := by ring
|
| 362 |
+
_ ≤ 4*(p : ℝ)^2*B^9 := mul_le_mul_of_nonneg_left hpow (by positivity)
|
| 363 |
+
_ = 4*(p : ℝ)^2*B^8*B := by ring
|
| 364 |
+
have hanchor : (p : ℝ)^2*(N*p)*anchorBudget p P/B ≤
|
| 365 |
+
4*(p : ℝ)^3*anchorBudget p P := by
|
| 366 |
+
apply (div_le_iff₀ hB0).mpr
|
| 367 |
+
calc
|
| 368 |
+
_ ≤ (p : ℝ)^2*(4*B*p)*anchorBudget p P := by
|
| 369 |
+
exact mul_le_mul_of_nonneg_right
|
| 370 |
+
(mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hN hp) (by positivity)) hA
|
| 371 |
+
_ = _ := by ring
|
| 372 |
+
have htwo : ((p : ℝ)^3*p*(anchorBudget p P)^2/B)*B =
|
| 373 |
+
(p : ℝ)^4*(anchorBudget p P)^2 := by
|
| 374 |
+
rw [div_mul_cancel₀ _ hB0.ne']
|
| 375 |
+
ring
|
| 376 |
+
have hpair : (p : ℝ)^2*M/B^2 ≤
|
| 377 |
+
Real.exp (P/50)*((p : ℝ)^4*((D : ℝ)+4)*(2*P)^200) := by
|
| 378 |
+
apply (div_le_iff₀ (pow_pos hB0 2)).mpr
|
| 379 |
+
calc
|
| 380 |
+
_ ≤ (p : ℝ)^2*((p : ℝ)^2*(B^2*Real.exp (P/50)*((D : ℝ)+4)*(2*P)^200)) :=
|
| 381 |
+
mul_le_mul_of_nonneg_left hM (by positivity)
|
| 382 |
+
_ = _ := by ring
|
| 383 |
+
have hplain : 1 + 4*(p : ℝ)^2 + 4*(p : ℝ)^3*anchorBudget p P +
|
| 384 |
+
(p : ℝ)^4*(anchorBudget p P)^2 ≤
|
| 385 |
+
Real.exp (P/50)*(1 + 4*(p : ℝ)^2 + 4*(p : ℝ)^3*anchorBudget p P +
|
| 386 |
+
(p : ℝ)^4*(anchorBudget p P)^2) := by
|
| 387 |
+
exact le_mul_of_one_le_left (by positivity) he
|
| 388 |
+
unfold certificateOverhead
|
| 389 |
+
rw [htwo]
|
| 390 |
+
nlinarith only [hroot, hanchor, hpair, hplain]
|
| 391 |
+
|
| 392 |
+
theorem absorb_certificate (p D : ℕ) (P : ℝ)
|
| 393 |
+
(h : certificateOverhead p D P ≤ Real.exp (2*P/25)) :
|
| 394 |
+
Real.exp (P/50)*certificateOverhead p D P ≤ Real.exp (P/10) := by
|
| 395 |
+
calc
|
| 396 |
+
_ ≤ Real.exp (P/50)*Real.exp (2*P/25) :=
|
| 397 |
+
mul_le_mul_of_nonneg_left h (Real.exp_pos _).le
|
| 398 |
+
_ = _ := by rw [← Real.exp_add]; congr 1; ring
|
| 399 |
+
|
| 400 |
+
theorem singleton_budget (p : ℕ) (B P : ℝ) (hB : 0 ≤ B) (hP : 0 ≤ P)
|
| 401 |
+
(hp : 2*(p : ℝ)+3 ≤ Real.exp (P/10)) :
|
| 402 |
+
B*Real.exp (P/100) + 2*((p+1 : ℝ)*(B*Real.exp (P/10))) ≤
|
| 403 |
+
B*Real.exp (P/5) := by
|
| 404 |
+
have he : Real.exp (P/100) ≤ Real.exp (P/10) := Real.exp_le_exp.mpr (by linarith)
|
| 405 |
+
calc
|
| 406 |
+
_ ≤ B*Real.exp (P/10)+2*((p+1 : ℝ)*(B*Real.exp (P/10))) := by
|
| 407 |
+
linarith only [mul_le_mul_of_nonneg_left he hB]
|
| 408 |
+
_ = (B*Real.exp (P/10))*(2*(p : ℝ)+3) := by ring
|
| 409 |
+
_ ≤ (B*Real.exp (P/10))*Real.exp (P/10) :=
|
| 410 |
+
mul_le_mul_of_nonneg_left hp (mul_nonneg hB (Real.exp_pos _).le)
|
| 411 |
+
_ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring
|
| 412 |
+
|
| 413 |
+
def shiftOverhead (p D : ℕ) : ℝ := 4+(D : ℝ)*(200*(p : ℝ))^200
|
| 414 |
+
|
| 415 |
+
lemma shifted_dyadic_budget (p D : ℕ) (P C : ℝ) (hP : 0 ≤ P) (hC : 0 ≤ C)
|
| 416 |
+
(hpoly : shiftOverhead p D ≤ Real.exp (2*P/25)) :
|
| 417 |
+
4*C+(D : ℝ)*C*Real.exp (P/50)*(2*(p : ℝ))^200 ≤ C*Real.exp (P/10) := by
|
| 418 |
+
have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity)
|
| 419 |
+
have hp : (2*(p : ℝ))^200 ≤ (200*(p : ℝ))^200 :=
|
| 420 |
+
pow_le_pow_left₀ (by positivity) (by have := (Nat.cast_nonneg p : (0 : ℝ) ≤ p); linarith) _
|
| 421 |
+
have heC : 4*C ≤ 4*C*Real.exp (P/50) := le_mul_of_one_le_right (by positivity) he
|
| 422 |
+
have hpow := mul_le_mul_of_nonneg_left hp
|
| 423 |
+
(show 0 ≤ (D : ℝ)*C*Real.exp (P/50) by positivity)
|
| 424 |
+
calc
|
| 425 |
+
_ ≤ C*Real.exp (P/50)*shiftOverhead p D := by
|
| 426 |
+
unfold shiftOverhead
|
| 427 |
+
nlinarith only [heC, hpow]
|
| 428 |
+
_ ≤ C*Real.exp (P/50)*Real.exp (2*P/25) :=
|
| 429 |
+
mul_le_mul_of_nonneg_left hpoly (by positivity)
|
| 430 |
+
_ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring
|
| 431 |
+
|
| 432 |
+
lemma strong_dyadic_budget (p D : ℕ) (P C : ℝ) (hP : 0 ≤ P) (hC : 0 ≤ C)
|
| 433 |
+
(hpoly : shiftOverhead p D ≤ Real.exp (2*P/25)) :
|
| 434 |
+
4*C+(D : ℝ)*C*Real.exp (P/50)*(200*(p : ℝ))^200 ≤ C*Real.exp (P/10) := by
|
| 435 |
+
have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity)
|
| 436 |
+
have heC : 4*C ≤ 4*C*Real.exp (P/50) := le_mul_of_one_le_right (by positivity) he
|
| 437 |
+
calc
|
| 438 |
+
_ ≤ C*Real.exp (P/50)*shiftOverhead p D := by
|
| 439 |
+
unfold shiftOverhead
|
| 440 |
+
nlinarith only [heC]
|
| 441 |
+
_ ≤ C*Real.exp (P/50)*Real.exp (2*P/25) :=
|
| 442 |
+
mul_le_mul_of_nonneg_left hpoly (by positivity)
|
| 443 |
+
_ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring
|
| 444 |
+
|
| 445 |
+
end SharpLogRamsey.MomentBudgetBridge
|
| 446 |
+
end
|
| 447 |
+
|
| 448 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/MakePair.lean
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.AnchorEventsRealized
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
open MeasureTheory ProbabilityTheory
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
open MeasureTheory ProbabilityTheory
|
| 15 |
+
open scoped BigOperators ENNReal NNReal
|
| 16 |
+
namespace SharpRamseyFive.CertificateCover
|
| 17 |
+
open SharpRamseyFive.StaticCertificates
|
| 18 |
+
open SharpRamseyFive.CertificateEnumeration
|
| 19 |
+
open SharpRamseyFive.WeightedPrograms
|
| 20 |
+
open SharpRamseyFive.ResidualCertificate
|
| 21 |
+
open scoped BigOperators
|
| 22 |
+
variable {V H D B : Type*} [Fintype V] [DecidableEq V]
|
| 23 |
+
[Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D]
|
| 24 |
+
[Fintype B] [DecidableEq B]
|
| 25 |
+
variable (lines : H → Finset D)
|
| 26 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in
|
| 27 |
+
lemma make_pair (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop)
|
| 28 |
+
(K : ℕ) (hK : 2 ≤ K) (low : Bool) (E : Finset V) (s : State V H D B)
|
| 29 |
+
(hs : Coherent lines f hit K E s) (v u : V) (hv : v ∉ E) (hu : u ∉ E) (hne : v ≠ u)
|
| 30 |
+
(hp : K ≤ (sharedBatches (outsideDirections (fun v => lines (f v)) E) hit v u).card) :
|
| 31 |
+
∃ a : Action lines K s,
|
| 32 |
+
Coherent lines f hit K (insert v (insert u E)) (advance lines K s a) ∧
|
| 33 |
+
(insert v (insert u E)).card = E.card + degree lines K s a ∧
|
| 34 |
+
Enabled lines K low s a ∧ actionCharge lines K s a = 0 := by
|
| 35 |
+
classical
|
| 36 |
+
obtain ⟨T, d, hT, hd, _, _, _, _⟩ :=
|
| 37 |
+
pair_step_witnesses (fun v => lines (f v)) hit E s.2 v u K hs.2.1 hs.2.2.1 hp
|
| 38 |
+
have hmem (r : T) : d r ∈ PairDirections lines s (f v) (f u) := by
|
| 39 |
+
apply Finset.mem_sdiff.mpr
|
| 40 |
+
refine ⟨(hd r).1, ?_⟩
|
| 41 |
+
intro hc
|
| 42 |
+
exact (hd r).2.1 (hs.2.1 hc)
|
| 43 |
+
let c : PairChoice lines K s := ⟨v, u, f v, ⟨f u, fun he => hne (hf he.symm)⟩,
|
| 44 |
+
⟨T, Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, hT⟩⟩, fun r => ⟨d r, hmem r⟩⟩
|
| 45 |
+
let a : Action lines K s := .inr (.inr (.inr c))
|
| 46 |
+
have hv' : v ∉ insert u E := by simp [hne, hv]
|
| 47 |
+
have hc : (insert v (insert u E)).card = E.card + degree lines K s a := by
|
| 48 |
+
simp [a, degree, Finset.card_insert_of_notMem hv', Finset.card_insert_of_notMem hu,
|
| 49 |
+
Nat.add_assoc]
|
| 50 |
+
refine ⟨a, ?_, hc, ?_, rfl⟩
|
| 51 |
+
· apply coherent_step lines f hit K hK E (insert v (insert u E)) s hs a
|
| 52 |
+
((Finset.subset_insert _ _).trans (Finset.subset_insert _ _)) _ _ _ hc
|
| 53 |
+
· have hu' := agrees_update f (insert v E)
|
| 54 |
+
(Function.update s.1 v (f v), s.2) (agrees_update f E s hs.1 v s.2) u
|
| 55 |
+
(advance lines K s a).2
|
| 56 |
+
simpa only [a, c, advance, newValues, Finset.insert_comm] using hu'
|
| 57 |
+
· intro z hz
|
| 58 |
+
obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz
|
| 59 |
+
obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp
|
| 60 |
+
exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, (Finset.mem_inter.mp (hd r).1).1⟩
|
| 61 |
+
· intro p hp
|
| 62 |
+
obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp
|
| 63 |
+
exact (hd r).2.2
|
| 64 |
+
· intro c' he
|
| 65 |
+
simp [a] at he
|
| 66 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 67 |
+
omit [Fintype D] in
|
| 68 |
+
|
| 69 |
+
lemma make_root (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K)
|
| 70 |
+
(low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s)
|
| 71 |
+
(v : V) (hv : v ∉ E) :
|
| 72 |
+
∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧
|
| 73 |
+
(insert v E).card = E.card + degree lines K s a ∧
|
| 74 |
+
Enabled lines K low s a ∧ actionCharge lines K s a = -8 := by
|
| 75 |
+
let a : Action lines K s := .inl (v, f v)
|
| 76 |
+
have hc : (insert v E).card = E.card + degree lines K s a := by
|
| 77 |
+
simp [a, degree, Finset.card_insert_of_notMem hv]
|
| 78 |
+
refine ⟨a, ?_, hc, ?_, rfl⟩
|
| 79 |
+
· apply coherent_step lines f hit K hK E (insert v E) s hs a
|
| 80 |
+
(Finset.subset_insert _ _) (agrees_update f E s hs.1 v _) _ _ hc
|
| 81 |
+
· simp [a, newEvents, paidDirections]
|
| 82 |
+
· simp [a, newEvents, Realized]
|
| 83 |
+
· intro c' he
|
| 84 |
+
simp [a] at he
|
| 85 |
+
|
| 86 |
+
abbrev Word (K : ℕ) := DWord (Action (V := V) (B := B) lines K) (advance lines K)
|
| 87 |
+
abbrev finish (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) :=
|
| 88 |
+
dFinish (Action lines K) (advance lines K) s w
|
| 89 |
+
abbrev charge (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) :=
|
| 90 |
+
dCharge (Action lines K) (advance lines K) (actionCharge lines K) s w
|
| 91 |
+
|
| 92 |
+
def degreeSum (K : ℕ) : {n : ℕ} → (s : State V H D B) → Word lines K n s → ℕ
|
| 93 |
+
| 0, _, _ => 0
|
| 94 |
+
| _ + 1, s, w => degree lines K s w.1 + degreeSum K (advance lines K s w.1) w.2
|
| 95 |
+
|
| 96 |
+
def TraceOK (K : ℕ) (low : Bool) :
|
| 97 |
+
{n : ℕ} → (s : State V H D B) → Word lines K n s → Prop
|
| 98 |
+
| 0, _, _ => True
|
| 99 |
+
| _ + 1, s, w => s.2.card ≤ K * Fintype.card V ∧
|
| 100 |
+
Enabled lines K low s w.1 ∧ TraceOK K low (advance lines K s w.1) w.2
|
| 101 |
+
|
| 102 |
+
def append (K : ℕ) {m : ℕ} : {n : ℕ} → (s : State V H D B) →
|
| 103 |
+
(w : Word lines K n s) → Word lines K m (finish lines K s w) → Word lines K (m + n) s
|
| 104 |
+
| 0, _, _, w' => w'
|
| 105 |
+
| _ + 1, s, w, w' => ⟨w.1, append K (advance lines K s w.1) w.2 w'⟩
|
| 106 |
+
|
| 107 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in
|
| 108 |
+
lemma finish_append (K : ℕ) {m n : ℕ} (s : State V H D B)
|
| 109 |
+
(w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) :
|
| 110 |
+
finish lines K s (append lines K s w w') = finish lines K (finish lines K s w) w' := by
|
| 111 |
+
induction n generalizing s with
|
| 112 |
+
| zero => rfl
|
| 113 |
+
| succ n ih => exact ih _ w.2 w'
|
| 114 |
+
|
| 115 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in
|
| 116 |
+
lemma degreeSum_append (K : ℕ) {m n : ℕ} (s : State V H D B)
|
| 117 |
+
(w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) :
|
| 118 |
+
degreeSum lines K s (append lines K s w w') =
|
| 119 |
+
degreeSum lines K s w + degreeSum lines K (finish lines K s w) w' := by
|
| 120 |
+
induction n generalizing s with
|
| 121 |
+
| zero => simp only [append, degreeSum, finish, dFinish, Nat.zero_add]
|
| 122 |
+
| succ n ih =>
|
| 123 |
+
simpa only [append, degreeSum, finish, dFinish, Nat.add_assoc] using
|
| 124 |
+
congrArg (fun t => degree lines K s w.1 + t) (ih (advance lines K s w.1) w.2 w')
|
| 125 |
+
|
| 126 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in
|
| 127 |
+
lemma charge_append (K : ℕ) {m n : ℕ} (s : State V H D B)
|
| 128 |
+
(w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) :
|
| 129 |
+
charge lines K s (append lines K s w w') =
|
| 130 |
+
charge lines K s w + charge lines K (finish lines K s w) w' := by
|
| 131 |
+
induction n generalizing s with
|
| 132 |
+
| zero => simp only [append, charge, dCharge, finish, dFinish, zero_add]
|
| 133 |
+
| succ n ih =>
|
| 134 |
+
simpa only [append, charge, dCharge, finish, dFinish, add_assoc] using
|
| 135 |
+
congrArg (fun t => actionCharge lines K s w.1 + t) (ih (advance lines K s w.1) w.2 w')
|
| 136 |
+
|
| 137 |
+
omit [Fintype H] [DecidableEq H] [Fintype D] in
|
| 138 |
+
lemma traceOK_append (K : ℕ) (low : Bool) {m n : ℕ} (s : State V H D B)
|
| 139 |
+
(w : Word lines K n s) (w' : Word lines K m (finish lines K s w))
|
| 140 |
+
(h : TraceOK lines K low s w) (h' : TraceOK lines K low (finish lines K s w) w') :
|
| 141 |
+
TraceOK lines K low s (append lines K s w w') := by
|
| 142 |
+
induction n generalizing s with
|
| 143 |
+
| zero => exact h'
|
| 144 |
+
| succ n ih => exact ⟨h.1, h.2.1, ih _ w.2 w' h.2.2 h'⟩
|
| 145 |
+
|
| 146 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq B] in
|
| 147 |
+
lemma one_le_degree (K : ℕ) (s : State V H D B) (a : Action lines K s) :
|
| 148 |
+
1 ≤ degree lines K s a := by
|
| 149 |
+
rcases a with a | a
|
| 150 |
+
· exact le_rfl
|
| 151 |
+
rcases a with a | a
|
| 152 |
+
· exact le_rfl
|
| 153 |
+
rcases a with a | a
|
| 154 |
+
· exact le_rfl
|
| 155 |
+
· norm_num [degree]
|
| 156 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in
|
| 157 |
+
|
| 158 |
+
lemma length_le_degreeSum (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) :
|
| 159 |
+
n ≤ degreeSum lines K s w := by
|
| 160 |
+
induction n generalizing s with
|
| 161 |
+
| zero => exact le_rfl
|
| 162 |
+
| succ n ih =>
|
| 163 |
+
have h1 := one_le_degree lines K s w.1
|
| 164 |
+
have h2 := ih _ w.2
|
| 165 |
+
change n + 1 ≤ _ + _
|
| 166 |
+
omega
|
| 167 |
+
omit [Fintype H] [DecidableEq H] in
|
| 168 |
+
omit [Fintype D] in
|
| 169 |
+
|
| 170 |
+
lemma trace_weight (rate : D → ℝ≥0) (denom : ℝ) (hd : denom ≠ 0)
|
| 171 |
+
(K : ℕ) (low : Bool) {n : ℕ} (s : State V H D B) (w : Word lines K n s)
|
| 172 |
+
(hw : TraceOK lines K low s w) :
|
| 173 |
+
weight (fun p : B × D => rate p.2) (finish lines K s w).2 =
|
| 174 |
+
weight (fun p : B × D => rate p.2) s.2 *
|
| 175 |
+
dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s w *
|
| 176 |
+
denom ^ degreeSum lines K s w := by
|
| 177 |
+
induction n generalizing s with
|
| 178 |
+
| zero => simp [finish, dFinish, dWeight, degreeSum]
|
| 179 |
+
| succ n ih =>
|
| 180 |
+
change weight _ (finish lines K (advance lines K s w.1) w.2).2 = _
|
| 181 |
+
rw [ih _ w.2 hw.2.2, step_weight lines rate denom hd K low s w.1 hw.2.1 hw.1]
|
| 182 |
+
simp only [dWeight, degreeSum, pow_add]
|
| 183 |
+
ring
|
| 184 |
+
|
| 185 |
+
def Segment (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool)
|
| 186 |
+
(E F : Finset V) (s : State V H D B) {n : ℕ} (w : Word lines K n s) : Prop :=
|
| 187 |
+
Coherent lines f hit K F (finish lines K s w) ∧
|
| 188 |
+
F.card = E.card + degreeSum lines K s w ∧ TraceOK lines K low s w
|
| 189 |
+
|
| 190 |
+
omit [Fintype H] [DecidableEq H] [Fintype D] in
|
| 191 |
+
lemma segment_empty (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool)
|
| 192 |
+
(E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) :
|
| 193 |
+
Segment lines f hit K low E E s (n := 0) (PUnit.unit : Word lines K 0 s) := by
|
| 194 |
+
exact ⟨hs, by simp [degreeSum], trivial⟩
|
| 195 |
+
|
| 196 |
+
omit [Fintype H] [DecidableEq H] [Fintype D] in
|
| 197 |
+
lemma segment_single (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool)
|
| 198 |
+
(E F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s)
|
| 199 |
+
(a : Action lines K s) (hf : Coherent lines f hit K F (advance lines K s a))
|
| 200 |
+
(hc : F.card = E.card + degree lines K s a) (he : Enabled lines K low s a) :
|
| 201 |
+
Segment lines f hit K low E F s (n := 1) (⟨a, PUnit.unit⟩ : Word lines K 1 s) := by
|
| 202 |
+
refine ⟨hf, ?_, ?_⟩
|
| 203 |
+
· simpa [degreeSum] using hc
|
| 204 |
+
· exact ⟨hs.2.2.2.trans (Nat.mul_le_mul_left K (Finset.card_le_univ E)), he, trivial⟩
|
| 205 |
+
omit [Fintype H] [DecidableEq H] [Fintype D] in
|
| 206 |
+
|
| 207 |
+
lemma segment_append (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool)
|
| 208 |
+
(E F G : Finset V) {m n : ℕ} (s : State V H D B)
|
| 209 |
+
(w : Word lines K n s) (w' : Word lines K m (finish lines K s w))
|
| 210 |
+
(h : Segment lines f hit K low E F s w)
|
| 211 |
+
(h' : Segment lines f hit K low F G (finish lines K s w) w') :
|
| 212 |
+
Segment lines f hit K low E G s (append lines K s w w') := by
|
| 213 |
+
refine ⟨?_, ?_, traceOK_append lines K low s w w' h.2.2 h'.2.2⟩
|
| 214 |
+
· rw [finish_append]; exact h'.1
|
| 215 |
+
· rw [degreeSum_append, ← Nat.add_assoc, ← h.2.1]
|
| 216 |
+
exact h'.2.1
|
| 217 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 218 |
+
omit [Fintype D] in
|
| 219 |
+
|
| 220 |
+
lemma make_encoding (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop)
|
| 221 |
+
(K : ℕ) (hK : 2 ≤ K) (low : Bool) {E F : Finset V}
|
| 222 |
+
(h : EncodingStep (fun v => lines (f v)) hit (if low then 1 else 2) K E F)
|
| 223 |
+
(s : State V H D B) (hs : Coherent lines f hit K E s) :
|
| 224 |
+
∃ a : Action lines K s, Coherent lines f hit K F (advance lines K s a) ∧
|
| 225 |
+
F.card = E.card + degree lines K s a ∧ Enabled lines K low s a ∧
|
| 226 |
+
0 ≤ actionCharge lines K s a := by
|
| 227 |
+
cases h with
|
| 228 |
+
| anchor v hv ha =>
|
| 229 |
+
cases low with
|
| 230 |
+
| false =>
|
| 231 |
+
obtain ⟨a, hh, hc, he, hq⟩ := make_two lines f hit K hK false E s hs v hv ha
|
| 232 |
+
exact ⟨a, hh, hc, he, by omega⟩
|
| 233 |
+
| true =>
|
| 234 |
+
obtain ⟨a, hh, hc, he, hq⟩ := make_one lines f hit K hK E s hs v hv ha
|
| 235 |
+
exact ⟨a, hh, hc, he, by omega⟩
|
| 236 |
+
| pair v u hv hu hne hp =>
|
| 237 |
+
obtain ⟨a, hh, hc, he, hq⟩ := make_pair lines f hf hit K hK low E s hs v u hv hu hne hp
|
| 238 |
+
exact ⟨a, hh, hc, he, by omega⟩
|
| 239 |
+
|
| 240 |
+
omit [Fintype H] [DecidableEq H] in
|
| 241 |
+
omit [Fintype D] in
|
| 242 |
+
|
| 243 |
+
theorem encoding_path_program (f : V → H) (hf : Function.Injective f)
|
| 244 |
+
(hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) {E F : Finset V}
|
| 245 |
+
(h : Relation.ReflTransGen (EncodingStep (fun v => lines (f v)) hit
|
| 246 |
+
(if low then 1 else 2) K) E F)
|
| 247 |
+
(s : State V H D B) (hs : Coherent lines f hit K E s) :
|
| 248 |
+
∃ n, ∃ w : Word lines K n s, Segment lines f hit K low E F s w ∧
|
| 249 |
+
0 ≤ charge lines K s w := by
|
| 250 |
+
induction h with
|
| 251 |
+
| refl => exact ⟨0, PUnit.unit, segment_empty lines f hit K low E s hs, le_rfl⟩
|
| 252 |
+
| @tail F G h hFG ih =>
|
| 253 |
+
obtain ⟨n, w, hw, hq⟩ := ih
|
| 254 |
+
obtain ⟨a, ha, hc, he, hqa⟩ := make_encoding lines f hf hit K hK low hFG
|
| 255 |
+
(finish lines K s w) hw.1
|
| 256 |
+
let w' : Word lines K 1 (finish lines K s w) := ⟨a, PUnit.unit⟩
|
| 257 |
+
refine ⟨1 + n, append lines K s w w', ?_, ?_⟩
|
| 258 |
+
· exact segment_append lines f hit K low E F G s w w' hw
|
| 259 |
+
(segment_single lines f hit K low F G _ hw.1 a ha hc he)
|
| 260 |
+
· rw [charge_append]
|
| 261 |
+
exact add_nonneg hq (by simpa [w', charge, dCharge] using hqa)
|
| 262 |
+
|
| 263 |
+
omit [Fintype H] [DecidableEq H] [Fintype D] in
|
| 264 |
+
|
| 265 |
+
lemma encode_set (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool)
|
| 266 |
+
(E R : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (c : ℤ)
|
| 267 |
+
(hdis : Disjoint E R)
|
| 268 |
+
(hmake : ∀ F : Finset V, E ⊆ F → ∀ s' : State V H D B,
|
| 269 |
+
Coherent lines f hit K F s' → ∀ v ∈ R, v ∉ F →
|
| 270 |
+
∃ a : Action lines K s', Coherent lines f hit K (insert v F) (advance lines K s' a) ∧
|
| 271 |
+
(insert v F).card = F.card + degree lines K s' a ∧
|
| 272 |
+
Enabled lines K low s' a ∧ actionCharge lines K s' a = c) :
|
| 273 |
+
∃ n, ∃ w : Word lines K n s, Segment lines f hit K low E (E ∪ R) s w ∧
|
| 274 |
+
charge lines K s w = c * R.card := by
|
| 275 |
+
classical
|
| 276 |
+
induction R using Finset.induction with
|
| 277 |
+
| empty =>
|
| 278 |
+
refine ⟨0, PUnit.unit, ?_, ?_⟩
|
| 279 |
+
· simpa using segment_empty lines f hit K low E s hs
|
| 280 |
+
· simp [charge, dCharge]
|
| 281 |
+
| @insert v R hvR ih =>
|
| 282 |
+
have hdis' : Disjoint E R := hdis.mono_right (Finset.subset_insert _ _)
|
| 283 |
+
obtain ⟨n, w, hw, hq⟩ := ih hdis' (by
|
| 284 |
+
intro F hEF s' hs' u hu hfu
|
| 285 |
+
exact hmake F hEF s' hs' u (Finset.mem_insert_of_mem hu) hfu)
|
| 286 |
+
have hvE : v ∉ E := fun hvE => Finset.disjoint_left.mp hdis hvE (Finset.mem_insert_self _ _)
|
| 287 |
+
have hvF : v ∉ E ∪ R := by simp [hvE, hvR]
|
| 288 |
+
obtain ⟨a, ha, hc, he, hqa⟩ := hmake (E ∪ R) Finset.subset_union_left
|
| 289 |
+
(finish lines K s w) hw.1 v (Finset.mem_insert_self _ _) hvF
|
| 290 |
+
let w' : Word lines K 1 (finish lines K s w) := ⟨a, PUnit.unit⟩
|
| 291 |
+
refine ⟨1 + n, append lines K s w w', ?_, ?_⟩
|
| 292 |
+
· have hh := segment_append lines f hit K low E (E ∪ R) (insert v (E ∪ R)) s w w' hw
|
| 293 |
+
(segment_single lines f hit K low (E ∪ R) _ _ hw.1 a ha hc he)
|
| 294 |
+
simpa only [Finset.union_insert] using hh
|
| 295 |
+
· rw [charge_append, hq]
|
| 296 |
+
change c * (R.card : ℤ) + (actionCharge lines K _ a + 0) = _
|
| 297 |
+
rw [hqa, Finset.card_insert_of_notMem hvR, Nat.cast_add, Nat.cast_one]
|
| 298 |
+
ring
|
| 299 |
+
omit [Fintype H] [DecidableEq H] in
|
| 300 |
+
omit [Fintype D] in
|
| 301 |
+
|
| 302 |
+
lemma residual_program (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K)
|
| 303 |
+
(low : Bool) (F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K F s)
|
| 304 |
+
(roots : Finset {v // v ∉ F})
|
| 305 |
+
(hsize : 10 * roots.card ≤ Fintype.card {v // v ∉ F})
|
| 306 |
+
(hroot : ∀ v, ∃ u ∈ roots, ∃ w ∈ roots, u ≠ w ∧ u ≠ v ∧ w ≠ v ∧
|
| 307 |
+
∃ d ∈ survivingDirections (fun v => lines (f v)) F v ∩
|
| 308 |
+
survivingDirections (fun v => lines (f v)) F u,
|
| 309 |
+
∃ e ∈ survivingDirections (fun v => lines (f v)) F v ∩
|
| 310 |
+
survivingDirections (fun v => lines (f v)) F w,
|
| 311 |
+
d ≠ e ∧ (∃ r, hit r d) ∧ (∃ r, hit r e)) :
|
| 312 |
+
∃ n, ∃ w : Word lines K n s, Segment lines f hit K low F Finset.univ s w ∧
|
| 313 |
+
0 ≤ charge lines K s w := by
|
| 314 |
+
classical
|
| 315 |
+
let R : Finset V := roots.image Subtype.val
|
| 316 |
+
have hRc : R.card = roots.card := by
|
| 317 |
+
dsimp [R]
|
| 318 |
+
apply Finset.card_image_of_injective
|
| 319 |
+
exact Subtype.val_injective
|
| 320 |
+
have hdis : Disjoint F R := by
|
| 321 |
+
apply Finset.disjoint_left.mpr
|
| 322 |
+
intro v hv hR
|
| 323 |
+
obtain ⟨u, _, rfl⟩ := Finset.mem_image.mp hR
|
| 324 |
+
exact u.property hv
|
| 325 |
+
obtain ⟨n, w, hw, hq⟩ := encode_set lines f hit K low F R s hs (-8) hdis (by
|
| 326 |
+
intro G hFG s' hs' v hv hvg
|
| 327 |
+
exact make_root lines f hit K hK low G s' hs' v hvg)
|
| 328 |
+
let NR : Finset V := Finset.univ \ (F ∪ R)
|
| 329 |
+
have hdisNR : Disjoint (F ∪ R) NR := Finset.disjoint_sdiff
|
| 330 |
+
have hmake : ∀ G : Finset V, F ∪ R ⊆ G → ∀ s' : State V H D B,
|
| 331 |
+
Coherent lines f hit K G s' → ∀ v ∈ NR, v ∉ G →
|
| 332 |
+
∃ a : Action lines K s', Coherent lines f hit K (insert v G) (advance lines K s' a) ∧
|
| 333 |
+
(insert v G).card = G.card + degree lines K s' a ∧
|
| 334 |
+
Enabled lines K low s' a ∧ actionCharge lines K s' a = 1 := by
|
| 335 |
+
intro G hFG s' hs' v hv hvg
|
| 336 |
+
have hvF : v ∉ F := fun hvF => (Finset.mem_sdiff.mp hv).2 (Finset.mem_union_left R hvF)
|
| 337 |
+
obtain ⟨u, hu, u', hu', _, _, _, d, hd, e, he, hde, hdp, hep⟩ := hroot ⟨v, hvF⟩
|
| 338 |
+
have hdv : d ∈ lines (f v) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp hd).1).1
|
| 339 |
+
have hdu : d ∈ lines (f u.val) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp hd).2).1
|
| 340 |
+
have hev : e ∈ lines (f v) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp he).1).1
|
| 341 |
+
have heu : e ∈ lines (f u'.val) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp he).2).1
|
| 342 |
+
have hdE : d ∈ encodedDirections (fun v => lines (f v)) G :=
|
| 343 |
+
Finset.mem_biUnion.mpr ⟨u.val, hFG (Finset.mem_union_right F
|
| 344 |
+
(Finset.mem_image_of_mem Subtype.val hu)), hdu⟩
|
| 345 |
+
have heE : e ∈ encodedDirections (fun v => lines (f v)) G :=
|
| 346 |
+
Finset.mem_biUnion.mpr ⟨u'.val, hFG (Finset.mem_union_right F
|
| 347 |
+
(Finset.mem_image_of_mem Subtype.val hu')), heu⟩
|
| 348 |
+
apply make_two lines f hit K hK low G s' hs' v hvg
|
| 349 |
+
apply Finset.one_lt_card.mpr
|
| 350 |
+
exact ⟨d, Finset.mem_filter.mpr ⟨Finset.mem_inter.mpr ⟨hdv, hdE⟩, hdp⟩,
|
| 351 |
+
e, Finset.mem_filter.mpr ⟨Finset.mem_inter.mpr ⟨hev, heE⟩, hep⟩, hde⟩
|
| 352 |
+
obtain ⟨m, w', hw', hq'⟩ := encode_set lines f hit K low (F ∪ R) NR
|
| 353 |
+
(finish lines K s w) hw.1 1 hdisNR hmake
|
| 354 |
+
have hfull : (F ∪ R) ∪ NR = Finset.univ := by
|
| 355 |
+
ext v
|
| 356 |
+
simp only [NR, Finset.mem_union, Finset.mem_sdiff, Finset.mem_univ, true_and]
|
| 357 |
+
tauto
|
| 358 |
+
refine ⟨m + n, append lines K s w w', ?_, ?_⟩
|
| 359 |
+
· simpa only [hfull] using segment_append lines f hit K low F (F ∪ R) _ s w w' hw hw'
|
| 360 |
+
· rw [charge_append, hq, hq', one_mul]
|
| 361 |
+
have hr : Fintype.card {v // v ∉ F} = Fintype.card V - F.card := by
|
| 362 |
+
rw [Fintype.card_subtype_compl]
|
| 363 |
+
simp
|
| 364 |
+
have hc : NR.card + (F.card + R.card) = Fintype.card V := by
|
| 365 |
+
have hh := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ (F ∪ R))
|
| 366 |
+
simpa only [NR, Finset.card_univ, Finset.card_union_of_disjoint hdis] using hh
|
| 367 |
+
rw [← hRc, hr] at hsize
|
| 368 |
+
omega
|
| 369 |
+
|
| 370 |
+
omit [Fintype H] [DecidableEq H] in
|
| 371 |
+
omit [Fintype D] in
|
| 372 |
+
|
| 373 |
+
theorem bad_program_high (f : V → H) (hf : Function.Injective f)
|
| 374 |
+
(hit : B → D → Prop) [∀ r d, Decidable (hit r d)] (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h)
|
| 375 |
+
(hsize : h ≤ (Fintype.card B / 2 - J) / (2 * K))
|
| 376 |
+
(E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s)
|
| 377 |
+
(hbad : ∀ v ∉ E, Fintype.card B / 2 ≤
|
| 378 |
+
(touchedBatches (fun v => lines (f v)) hit v).card)
|
| 379 |
+
(htrunc : ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J)
|
| 380 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) :
|
| 381 |
+
∃ n, ∃ w : Word lines K n s, Segment lines f hit K false E Finset.univ s w ∧
|
| 382 |
+
0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by
|
| 383 |
+
classical
|
| 384 |
+
obtain ⟨F, hpath, roots, hr, hroot⟩ := high_case_certificate_geometry
|
| 385 |
+
(fun v => lines (f v)) hit E K J h hh hsize hbad
|
| 386 |
+
(by
|
| 387 |
+
intro d
|
| 388 |
+
apply le_trans _ (htrunc d)
|
| 389 |
+
apply Finset.card_le_card
|
| 390 |
+
intro r hr
|
| 391 |
+
simpa only [Finset.mem_filter, Finset.mem_univ, true_and] using hr) herr
|
| 392 |
+
obtain ⟨n, w, hw, hq⟩ := encoding_path_program lines f hf hit K hK false hpath s hs
|
| 393 |
+
obtain ⟨m, w', hw', hq'⟩ := residual_program lines f hit K hK false F
|
| 394 |
+
(finish lines K s w) hw.1 roots hr hroot
|
| 395 |
+
refine ⟨m + n, append lines K s w w', segment_append lines f hit K false E F _ s w w' hw hw', ?_, ?_⟩
|
| 396 |
+
· rw [charge_append]; exact add_nonneg hq hq'
|
| 397 |
+
· have hl := length_le_degreeSum lines K s (append lines K s w w')
|
| 398 |
+
have hc := (segment_append lines f hit K false E F _ s w w' hw hw').2.1
|
| 399 |
+
simp only [Finset.card_univ] at hc
|
| 400 |
+
omega
|
| 401 |
+
omit [Fintype H] [DecidableEq H] in
|
| 402 |
+
omit [Fintype D] in
|
| 403 |
+
|
| 404 |
+
theorem bad_program_low (f : V → H) (hf : Function.Injective f)
|
| 405 |
+
(hit : B → D → Prop) (K h : ℕ) (hK : 2 ≤ K) (hh : 0 < h)
|
| 406 |
+
(hsize : h ≤ (Fintype.card B / 2) / (2 * K))
|
| 407 |
+
(E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s)
|
| 408 |
+
(hbad : ∀ v ∉ E, Fintype.card B / 2 ≤
|
| 409 |
+
(touchedBatches (fun v => lines (f v)) hit v).card)
|
| 410 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) :
|
| 411 |
+
∃ n, ∃ w : Word lines K n s, Segment lines f hit K true E Finset.univ s w ∧
|
| 412 |
+
0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by
|
| 413 |
+
obtain ⟨F, hpath, roots, hr, hroot⟩ := low_case_certificate_geometry
|
| 414 |
+
(fun v => lines (f v)) hit E K h hh hsize hbad herr
|
| 415 |
+
obtain ⟨n, w, hw, hq⟩ := encoding_path_program lines f hf hit K hK true hpath s hs
|
| 416 |
+
obtain ⟨m, w', hw', hq'⟩ := residual_program lines f hit K hK true F
|
| 417 |
+
(finish lines K s w) hw.1 roots hr hroot
|
| 418 |
+
refine ⟨m + n, append lines K s w w', segment_append lines f hit K true E F _ s w w' hw hw', ?_, ?_⟩
|
| 419 |
+
· rw [charge_append]; exact add_nonneg hq hq'
|
| 420 |
+
· have hl := length_le_degreeSum lines K s (append lines K s w w')
|
| 421 |
+
have hc := (segment_append lines f hit K true E F _ s w w' hw hw').2.1
|
| 422 |
+
simp only [Finset.card_univ] at hc
|
| 423 |
+
omega
|
| 424 |
+
|
| 425 |
+
omit [DecidableEq D] [DecidableEq B] in
|
| 426 |
+
lemma decoded_static_union_bound {F C : Type*} [Fintype F] [DecidableEq F]
|
| 427 |
+
[Fintype C] [DecidableEq C]
|
| 428 |
+
(rate : D → ℝ≥0) (requirements : C → Finset (B × D)) (decode : C → F)
|
| 429 |
+
(events : F → Set ((B × D) → ℕ))
|
| 430 |
+
(hm : ∀ f, MeasurableSet (events f))
|
| 431 |
+
(hc : ∀ f ω, ω ∈ events f → ∃ c, decode c = f ∧ ω ∈ positiveEvent (requirements c)) :
|
| 432 |
+
(∑ f, (poissonLaw (fun p : B × D => rate p.2)).real (events f)) ≤
|
| 433 |
+
∑ c, weight (fun p : B × D => rate p.2) (requirements c) := by
|
| 434 |
+
classical
|
| 435 |
+
calc
|
| 436 |
+
_ ≤ ∑ f, ∑ c ∈ Finset.univ.filter (fun c => decode c = f),
|
| 437 |
+
weight (fun p : B × D => rate p.2) (requirements c) := by
|
| 438 |
+
apply Finset.sum_le_sum
|
| 439 |
+
intro f _
|
| 440 |
+
apply static_union_bound _ requirements _ (events f) (hm f)
|
| 441 |
+
intro ω hω
|
| 442 |
+
obtain ⟨c, hd, he⟩ := hc f ω hω
|
| 443 |
+
exact ⟨c, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hd⟩, he⟩
|
| 444 |
+
_ = _ := by
|
| 445 |
+
simp only [Finset.sum_filter]
|
| 446 |
+
rw [Finset.sum_comm]
|
| 447 |
+
apply Finset.sum_congr rfl
|
| 448 |
+
intro c _
|
| 449 |
+
simp
|
| 450 |
+
|
| 451 |
+
abbrev AllPrograms (K : ℕ) (E : Finset V) (s : State V H D B) :=
|
| 452 |
+
(n : Fin (Fintype.card V - E.card + 1)) × Word lines K n.val s
|
| 453 |
+
|
| 454 |
+
def CompleteProgram (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B)
|
| 455 |
+
(c : AllPrograms lines K E s) : Prop :=
|
| 456 |
+
TraceOK lines K low s c.2 ∧ 0 ≤ charge lines K s c.2 ∧
|
| 457 |
+
degreeSum lines K s c.2 = Fintype.card V - E.card
|
| 458 |
+
|
| 459 |
+
noncomputable def completePrograms (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) :=
|
| 460 |
+
{c : AllPrograms lines K E s // CompleteProgram lines K low E s c}
|
| 461 |
+
|
| 462 |
+
noncomputable instance completePrograms_fintype (K : ℕ) (low : Bool) (E : Finset V)
|
| 463 |
+
(s : State V H D B) : Fintype (completePrograms lines K low E s) := by
|
| 464 |
+
classical
|
| 465 |
+
unfold completePrograms
|
| 466 |
+
infer_instance
|
| 467 |
+
end SharpRamseyFive.CertificateCover
|
| 468 |
+
end
|
| 469 |
+
|
| 470 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/MarkingTwoEntropy.lean
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Marking.MarkingTwoScans
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey.Selection
|
| 8 |
+
open scoped BigOperators Classical
|
| 9 |
+
noncomputable section
|
| 10 |
+
variable {Ω Γ α ι : Type*} [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype ι]
|
| 11 |
+
|
| 12 |
+
def selectedDeficit (p : Law Ω) (θ : Ω → Γ) (F : Ω → ι → α)
|
| 13 |
+
(S : Γ → Finset ι) (J : ℝ) : ℝ :=
|
| 14 |
+
∑ z, (p.map θ).mass z*((S z).card*J-entropy (((p.cond θ z).map F).restrict (S z)))
|
| 15 |
+
end
|
| 16 |
+
end SharpLogRamsey.Selection
|
| 17 |
+
|
| 18 |
+
namespace SharpLogRamsey.Marking
|
| 19 |
+
open scoped BigOperators Classical
|
| 20 |
+
noncomputable section
|
| 21 |
+
variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V]
|
| 22 |
+
[FiniteDimensional K V] [Fintype (Projectivization K V)]
|
| 23 |
+
[Fintype (Projectivization K (Module.Dual K V))]
|
| 24 |
+
[Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] [Finite K]
|
| 25 |
+
|
| 26 |
+
abbrev jointJ (K : Type*) (d : ℕ) : ℝ := Real.log (64*(Nat.card K:ℝ)^d)
|
| 27 |
+
|
| 28 |
+
def sourceMessage {Ω Γ : Type*} {N : ℕ} (C : Ω → Γ)
|
| 29 |
+
(F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) :
|
| 30 |
+
Ω → TwoMessage (K:=K) (V:=V) Γ N :=
|
| 31 |
+
Selection.markingMessage C (fun x => twoMask (Nat.card K) (F x)) bothExpensive F
|
| 32 |
+
|
| 33 |
+
variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ]
|
| 34 |
+
|
| 35 |
+
def excessCost {N : ℕ} (p : Selection.Law Ω) (C : Ω → Γ)
|
| 36 |
+
(F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) (Jprev J₀ : ℝ) : ℝ :=
|
| 37 |
+
Selection.entropy (p.map C)+Real.log (Fintype.card (TwoMask (K:=K) (V:=V) N))+
|
| 38 |
+
N*J₀-Selection.entropy (p.map F)+
|
| 39 |
+
(∑ x, p.mass x*((bothExpensive (twoMask (Nat.card K) (F x))).card:ℝ))*(Jprev-J₀)
|
| 40 |
+
|
| 41 |
+
theorem twoScan_subset_deficit {N n : ℕ} (hdim : Module.finrank K V=n+3)
|
| 42 |
+
(p : Selection.Law Ω) (C : Ω → Γ) (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V))
|
| 43 |
+
(D : Γ → Fin N → Finset (ProjectivePair (K:=K) (V:=V))) (Jprev : ℝ)
|
| 44 |
+
(hcons : ∀ x, p.mass x≠0 → ScanConsistent ((List.ofFn (F x)).map toScan))
|
| 45 |
+
(hinc : ∀ x, p.mass x≠0 → ∀ i, Incidence.Incident (F x i).1 (F x i).2)
|
| 46 |
+
(hD : ∀ x, p.mass x≠0 → ∀ i, F x i∈D (C x) i)
|
| 47 |
+
(hprev : ∀ c i, Real.log (D c i).card≤Jprev)
|
| 48 |
+
(S : TwoMessage (K:=K) (V:=V) Γ N → Finset (Fin N))
|
| 49 |
+
(hS : ∀ z, Disjoint (S z) (bothExpensive z.2.2)) :
|
| 50 |
+
0 ≤ Selection.selectedDeficit p (sourceMessage C F) F S (jointJ K (n+2)) ∧
|
| 51 |
+
Selection.selectedDeficit p (sourceMessage C F) F S (jointJ K (n+2)) ≤
|
| 52 |
+
excessCost p C F Jprev (jointJ K (n+2)) := by
|
| 53 |
+
have hh := Selection.marking_subset_deficit p C (fun x => twoMask (Nat.card K) (F x))
|
| 54 |
+
bothExpensive F D cheapBoth Jprev (jointJ K (n+2)) hD hprev
|
| 55 |
+
(fun x hx i hi => cheapBoth_mem C F x (hcons x hx) (hinc x hx) i hi)
|
| 56 |
+
(fun z i _ => cheapBoth_log_card hdim z i) S hS
|
| 57 |
+
change 0≤_ ∧ _≤_ at hh
|
| 58 |
+
convert hh using 1 <;> simp only [Selection.selectedDeficit,sourceMessage,excessCost,Fintype.card_fin]
|
| 59 |
+
all_goals congr!
|
| 60 |
+
|
| 61 |
+
end
|
| 62 |
+
end SharpLogRamsey.Marking
|
| 63 |
+
|
| 64 |
+
end
|
| 65 |
+
|
| 66 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/NewEvents.lean
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.TwoAnchorCrossCost
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
open MeasureTheory ProbabilityTheory
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
namespace SharpRamseyFive.WeightedPrograms
|
| 15 |
+
open SharpRamseyFive.StaticCertificates
|
| 16 |
+
open SharpRamseyFive.CertificateEnumeration
|
| 17 |
+
open scoped BigOperators NNReal
|
| 18 |
+
variable {V H D B : Type*} [Fintype V] [DecidableEq V]
|
| 19 |
+
[Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D]
|
| 20 |
+
[Fintype B] [DecidableEq B]
|
| 21 |
+
variable (lines : H → Finset D)
|
| 22 |
+
def newEvents (K : ℕ) (s : State V H D B) : Action lines K s → Finset (B × D)
|
| 23 |
+
| .inl _ => ∅
|
| 24 |
+
| .inr (.inl c) => c.2.2.1.requirements
|
| 25 |
+
| .inr (.inr (.inl c)) => c.2.2.2.1.requirements ∪ c.2.2.2.2.1.requirements
|
| 26 |
+
| .inr (.inr (.inr c)) => witnessRequirements c.2.2.2.2.1.val
|
| 27 |
+
(PairDirections lines s c.2.2.1 c.2.2.2.1.val) c.2.2.2.2.2
|
| 28 |
+
|
| 29 |
+
def newValues (K : ℕ) (s : State V H D B) : Action lines K s → V → H
|
| 30 |
+
| .inl c => Function.update s.1 c.1 c.2
|
| 31 |
+
| .inr (.inl c) => Function.update s.1 c.1 c.2.2.2.val
|
| 32 |
+
| .inr (.inr (.inl c)) => Function.update s.1 c.1 c.2.2.2.2.2.val
|
| 33 |
+
| .inr (.inr (.inr c)) =>
|
| 34 |
+
Function.update (Function.update s.1 c.1 c.2.2.1) c.2.1 c.2.2.2.1.val
|
| 35 |
+
|
| 36 |
+
def advance (K : ℕ) (s : State V H D B) (a : Action lines K s) : State V H D B :=
|
| 37 |
+
(newValues lines K s a, s.2 ∪ newEvents lines K s a)
|
| 38 |
+
|
| 39 |
+
def degree (K : ℕ) (s : State V H D B) : Action lines K s → ℕ
|
| 40 |
+
| .inr (.inr (.inr _)) => 2
|
| 41 |
+
| _ => 1
|
| 42 |
+
|
| 43 |
+
def actionCharge (K : ℕ) (s : State V H D B) : Action lines K s → ℤ
|
| 44 |
+
| .inl _ => -8
|
| 45 |
+
| .inr (.inr (.inl _)) => 1
|
| 46 |
+
| _ => 0
|
| 47 |
+
|
| 48 |
+
noncomputable def rawCost (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool)
|
| 49 |
+
(s : State V H D B) : Action lines K s → ℝ
|
| 50 |
+
| .inl _ => 1 / denom
|
| 51 |
+
| .inr (.inl c) => if low then oneCost lines rate denom s c else 0
|
| 52 |
+
| .inr (.inr (.inl c)) => twoCost lines rate denom s c
|
| 53 |
+
| .inr (.inr (.inr c)) => pairCost lines rate denom K s c
|
| 54 |
+
|
| 55 |
+
noncomputable def programCost (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool)
|
| 56 |
+
(s : State V H D B) (a : Action lines K s) : ℝ :=
|
| 57 |
+
if s.2.card ≤ K * Fintype.card V then rawCost lines rate denom K low s a else 0
|
| 58 |
+
|
| 59 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 60 |
+
omit [Fintype D] in
|
| 61 |
+
lemma newEvents_fresh (K : ℕ) (s : State V H D B) (a : Action lines K s) :
|
| 62 |
+
Disjoint s.2 (newEvents lines K s a) := by
|
| 63 |
+
rcases a with a | a
|
| 64 |
+
· exact Finset.disjoint_empty_right _
|
| 65 |
+
rcases a with a | a
|
| 66 |
+
· exact a.2.2.1.fresh
|
| 67 |
+
rcases a with a | a
|
| 68 |
+
· exact Finset.disjoint_union_right.mpr ⟨a.2.2.2.1.fresh, a.2.2.2.2.1.fresh⟩
|
| 69 |
+
· apply witnessRequirements_disjoint
|
| 70 |
+
apply Finset.disjoint_left.mpr
|
| 71 |
+
intro d hd hdC
|
| 72 |
+
exact (Finset.mem_sdiff.mp hd).2 hdC
|
| 73 |
+
|
| 74 |
+
omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 75 |
+
omit [Fintype D] in
|
| 76 |
+
lemma rawCost_nonneg (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom)
|
| 77 |
+
(K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) :
|
| 78 |
+
0 ≤ rawCost lines rate denom K low s a := by
|
| 79 |
+
rcases a with a | a
|
| 80 |
+
· exact div_nonneg zero_le_one hd
|
| 81 |
+
rcases a with a | a
|
| 82 |
+
· change 0 ≤ if low then _ else 0
|
| 83 |
+
split_ifs
|
| 84 |
+
· exact div_nonneg (a.2.2.1.cost_nonneg rate) hd
|
| 85 |
+
· exact le_rfl
|
| 86 |
+
rcases a with a | a
|
| 87 |
+
· exact div_nonneg (mul_nonneg (a.2.2.2.1.cost_nonneg rate)
|
| 88 |
+
(a.2.2.2.2.1.cost_nonneg rate)) hd
|
| 89 |
+
· exact div_nonneg (weight_nonneg _ _) (sq_nonneg _)
|
| 90 |
+
omit [DecidableEq V] [Fintype H] [DecidableEq H] in
|
| 91 |
+
omit [Fintype D] in
|
| 92 |
+
|
| 93 |
+
lemma programCost_nonneg (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom)
|
| 94 |
+
(K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) :
|
| 95 |
+
0 ≤ programCost lines rate denom K low s a := by
|
| 96 |
+
unfold programCost
|
| 97 |
+
split_ifs
|
| 98 |
+
· exact rawCost_nonneg lines rate denom hd K low s a
|
| 99 |
+
· exact le_rfl
|
| 100 |
+
|
| 101 |
+
noncomputable def uniformAnchorBudget (K : ℕ) (mass : ℝ) : ℝ :=
|
| 102 |
+
K * Fintype.card V + Fintype.card B * mass
|
| 103 |
+
|
| 104 |
+
noncomputable def branchingBound (rate : D → ℝ≥0) (denom b mass : ℝ)
|
| 105 |
+
(K N₁ N₂ : ℕ) (low : Bool) : ℝ :=
|
| 106 |
+
((Fintype.card V : ℝ) * Fintype.card H / denom) / b ^ 8 +
|
| 107 |
+
(if low then Fintype.card V ^ 2 * (N₁ : ℝ) *
|
| 108 |
+
uniformAnchorBudget (V := V) (B := B) K mass / denom else 0) +
|
| 109 |
+
(Fintype.card V ^ 3 * (N₂ : ℝ) *
|
| 110 |
+
uniformAnchorBudget (V := V) (B := B) K mass ^ 2 / denom) * b +
|
| 111 |
+
Fintype.card V ^ 2 * pairMoment (B := B) lines rate K / denom ^ 2
|
| 112 |
+
|
| 113 |
+
omit [DecidableEq V] in
|
| 114 |
+
omit [Fintype D] [DecidableEq B] in
|
| 115 |
+
lemma branchingBound_nonneg (rate : D → ℝ≥0) (denom b mass : ℝ)
|
| 116 |
+
(hd : 0 ≤ denom) (hb : 0 ≤ b) (hm : 0 ≤ mass)
|
| 117 |
+
(K N₁ N₂ : ℕ) (low : Bool) :
|
| 118 |
+
0 ≤ branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low := by
|
| 119 |
+
unfold branchingBound uniformAnchorBudget
|
| 120 |
+
have hp := pairMoment_nonneg (B := B) lines rate K
|
| 121 |
+
split_ifs <;> positivity
|
| 122 |
+
|
| 123 |
+
omit [DecidableEq V] [Fintype D] in
|
| 124 |
+
lemma discounted_raw_sum (rate : D → ℝ≥0) (denom b : ℝ)
|
| 125 |
+
(K : ℕ) (low : Bool) (s : State V H D B) :
|
| 126 |
+
(∑ a : Action lines K s, rawCost lines rate denom K low s a * b ^ actionCharge lines K s a) =
|
| 127 |
+
((Fintype.card V : ℝ) * Fintype.card H / denom) / b ^ 8 +
|
| 128 |
+
(if low then ∑ c : OneChoice lines s, oneCost lines rate denom s c else 0) +
|
| 129 |
+
(∑ c : TwoChoice lines s, twoCost lines rate denom s c) * b +
|
| 130 |
+
∑ c : PairChoice lines K s, pairCost lines rate denom K s c := by
|
| 131 |
+
classical
|
| 132 |
+
change (∑ a : RootChoice (V := V) (H := H) ⊕
|
| 133 |
+
OneChoice lines s ⊕ TwoChoice lines s ⊕ PairChoice lines K s, _) = _
|
| 134 |
+
simp only [Fintype.sum_sum_type, rawCost, actionCharge]
|
| 135 |
+
cases low <;>
|
| 136 |
+
simp only [Bool.false_eq_true, ↓reduceIte,
|
| 137 |
+
zpow_neg, zpow_ofNat, ← Finset.sum_mul, Finset.sum_const,
|
| 138 |
+
Finset.card_univ, Fintype.card_prod, nsmul_eq_mul, RootChoice, Nat.cast_mul] <;> ring
|
| 139 |
+
|
| 140 |
+
omit [DecidableEq V] in
|
| 141 |
+
omit [Fintype D] in
|
| 142 |
+
|
| 143 |
+
theorem discounted_row_bound (rate : D → ℝ≥0) (denom b mass : ℝ)
|
| 144 |
+
(hd : 0 ≤ denom) (hb : 0 ≤ b) (hm : 0 ≤ mass)
|
| 145 |
+
(hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass)
|
| 146 |
+
(K N₁ N₂ : ℕ) (low : Bool)
|
| 147 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁)
|
| 148 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 149 |
+
(Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂)
|
| 150 |
+
(s : State V H D B) :
|
| 151 |
+
(∑ a : Action lines K s,
|
| 152 |
+
programCost lines rate denom K low s a * b ^ actionCharge lines K s a) ≤
|
| 153 |
+
branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low := by
|
| 154 |
+
classical
|
| 155 |
+
by_cases hs : s.2.card ≤ K * Fintype.card V
|
| 156 |
+
· simp only [programCost, ite_eq_left hs]
|
| 157 |
+
rw [discounted_raw_sum]
|
| 158 |
+
have hA : anchorBudget rate s mass ≤ uniformAnchorBudget (V := V) (B := B) K mass := by
|
| 159 |
+
unfold anchorBudget uniformAnchorBudget
|
| 160 |
+
apply add_le_add _ le_rfl
|
| 161 |
+
exact_mod_cast hs
|
| 162 |
+
have h1 := sum_oneCost_le lines rate denom hd s mass hmass N₁ hN₁
|
| 163 |
+
have h2 := sum_twoCost_le lines rate denom hd s mass hm hmass N₂ hN₂
|
| 164 |
+
have h3 := sum_pairCost_le lines rate denom K s
|
| 165 |
+
unfold branchingBound
|
| 166 |
+
apply add_le_add
|
| 167 |
+
· apply add_le_add
|
| 168 |
+
· apply add_le_add le_rfl
|
| 169 |
+
split_ifs with hl
|
| 170 |
+
· apply h1.trans
|
| 171 |
+
apply div_le_div_of_nonneg_right _ hd
|
| 172 |
+
exact mul_le_mul_of_nonneg_left hA (by positivity)
|
| 173 |
+
· exact le_rfl
|
| 174 |
+
· apply mul_le_mul_of_nonneg_right _ hb
|
| 175 |
+
apply h2.trans
|
| 176 |
+
apply div_le_div_of_nonneg_right _ hd
|
| 177 |
+
apply mul_le_mul_of_nonneg_left _ (by positivity)
|
| 178 |
+
exact pow_le_pow_left₀ (anchorBudget_nonneg rate s mass hm) hA 2
|
| 179 |
+
· exact h3
|
| 180 |
+
· simp only [programCost, ite_eq_right hs, zero_mul, Finset.sum_const_zero]
|
| 181 |
+
exact branchingBound_nonneg (V := V) lines rate denom b mass hd hb hm K N₁ N₂ low
|
| 182 |
+
|
| 183 |
+
omit [Fintype D] in
|
| 184 |
+
|
| 185 |
+
theorem program_enumeration (rate : D → ℝ≥0) (denom b mass : ℝ)
|
| 186 |
+
(hd : 0 ≤ denom) (hb : 1 ≤ b) (hm : 0 ≤ mass)
|
| 187 |
+
(hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass)
|
| 188 |
+
(K N₁ N₂ : ℕ) (low : Bool)
|
| 189 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁)
|
| 190 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 191 |
+
(Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂)
|
| 192 |
+
(n : ℕ) (s : State V H D B) :
|
| 193 |
+
(∑ w : DWord (Action lines K) (advance lines K) n s,
|
| 194 |
+
if 0 ≤ dCharge (Action lines K) (advance lines K) (actionCharge lines K) s w
|
| 195 |
+
then dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s w
|
| 196 |
+
else 0) ≤
|
| 197 |
+
branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n := by
|
| 198 |
+
classical
|
| 199 |
+
exact constrained_dSum_le (Action lines K) (advance lines K)
|
| 200 |
+
(programCost lines rate denom K low) (programCost_nonneg lines rate denom hd K low)
|
| 201 |
+
(actionCharge lines K) b _ hb
|
| 202 |
+
(branchingBound_nonneg (V := V) lines rate denom b mass hd (by linarith) hm K N₁ N₂ low)
|
| 203 |
+
(discounted_row_bound lines rate denom b mass hd (by linarith) hm hmass K N₁ N₂ low hN₁ hN₂)
|
| 204 |
+
n s _ (fun _ h => h)
|
| 205 |
+
|
| 206 |
+
end SharpRamseyFive.WeightedPrograms
|
| 207 |
+
|
| 208 |
+
open MeasureTheory ProbabilityTheory
|
| 209 |
+
open scoped BigOperators ENNReal NNReal
|
| 210 |
+
|
| 211 |
+
namespace SharpRamseyFive.ResidualCertificate
|
| 212 |
+
|
| 213 |
+
variable {V : Type*} [Fintype V] [DecidableEq V]
|
| 214 |
+
|
| 215 |
+
noncomputable def rootProbability : unitInterval := ⟨1 / 20, by norm_num⟩
|
| 216 |
+
|
| 217 |
+
noncomputable def rootMeasure : Measure (V → Bool) :=
|
| 218 |
+
Measure.pi (fun _ => bernoulliMeasure true false rootProbability)
|
| 219 |
+
|
| 220 |
+
instance flat_HighMomentRecovered_6 : IsProbabilityMeasure (rootMeasure (V := V)) := by
|
| 221 |
+
unfold rootMeasure
|
| 222 |
+
infer_instance
|
| 223 |
+
|
| 224 |
+
noncomputable def selected (ω : V → Bool) : Finset V :=
|
| 225 |
+
Finset.univ.filter (fun v => ω v = true)
|
| 226 |
+
|
| 227 |
+
def voidEvent (W : Finset V) : Set (V → Bool) :=
|
| 228 |
+
(W : Set V).pi (fun _ => {false})
|
| 229 |
+
|
| 230 |
+
noncomputable def voidIndicator (W : Finset V) (ω : V → Bool) : ℝ :=
|
| 231 |
+
(voidEvent W).indicator (fun _ => 1) ω
|
| 232 |
+
|
| 233 |
+
noncomputable def badIndicator (W : Finset V) (ω : V → Bool) : ℝ :=
|
| 234 |
+
if (W ∩ selected ω).card < 2 then 1 else 0
|
| 235 |
+
|
| 236 |
+
omit [DecidableEq V] in
|
| 237 |
+
lemma integrable_bounded (f : (V → Bool) → ℝ) (C : ℝ) (hf : ∀ ω, |f ω| ≤ C) :
|
| 238 |
+
Integrable f rootMeasure := by
|
| 239 |
+
apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable C
|
| 240 |
+
exact Filter.Eventually.of_forall (by intro ω; simpa only [Real.norm_eq_abs] using hf ω)
|
| 241 |
+
omit [DecidableEq V] in
|
| 242 |
+
|
| 243 |
+
lemma integrable_voidIndicator (W : Finset V) : Integrable (voidIndicator W) rootMeasure := by
|
| 244 |
+
apply integrable_bounded _ 1
|
| 245 |
+
intro ω
|
| 246 |
+
by_cases h : ω ∈ voidEvent W <;> simp [voidIndicator, h]
|
| 247 |
+
|
| 248 |
+
lemma integrable_badIndicator (W : Finset V) : Integrable (badIndicator W) rootMeasure := by
|
| 249 |
+
apply integrable_bounded _ 1
|
| 250 |
+
intro ω
|
| 251 |
+
simp only [badIndicator]
|
| 252 |
+
split_ifs <;> norm_num
|
| 253 |
+
|
| 254 |
+
omit [Fintype V] [DecidableEq V] in
|
| 255 |
+
lemma voidIndicator_nonneg (W : Finset V) (ω : V → Bool) : 0 ≤ voidIndicator W ω := by
|
| 256 |
+
by_cases h : ω ∈ voidEvent W <;> simp [voidIndicator, h]
|
| 257 |
+
|
| 258 |
+
lemma badIndicator_nonneg (W : Finset V) (ω : V → Bool) : 0 ≤ badIndicator W ω := by
|
| 259 |
+
simp only [badIndicator]
|
| 260 |
+
split_ifs <;> norm_num
|
| 261 |
+
|
| 262 |
+
omit [DecidableEq V] in
|
| 263 |
+
lemma integral_voidIndicator (W : Finset V) :
|
| 264 |
+
∫ ω, voidIndicator W ω ∂rootMeasure = (19 / 20 : ℝ) ^ W.card := by
|
| 265 |
+
have hm : MeasurableSet (voidEvent W) := MeasurableSet.pi W.finite_toSet.countable
|
| 266 |
+
(fun _ _ => measurableSet_singleton false)
|
| 267 |
+
have hprob : rootMeasure (voidEvent W) = ENNReal.ofReal ((19 / 20 : ℝ) ^ W.card) := by
|
| 268 |
+
rw [rootMeasure, voidEvent, Measure.pi_pi_finset]
|
| 269 |
+
simp only [bernoulliMeasure_apply rootProbability (measurableSet_singleton false)]
|
| 270 |
+
norm_num [rootProbability, unitInterval.toNNReal, unitInterval.symm]
|
| 271 |
+
congr 1
|
| 272 |
+
exact ENNReal.ofReal_coe_nnreal.symm
|
| 273 |
+
simp only [voidIndicator]
|
| 274 |
+
rw [ integral_indicator_const _ hm, Measure.real, hprob,
|
| 275 |
+
ENNReal.toReal_ofReal (by positivity)]
|
| 276 |
+
simp
|
| 277 |
+
|
| 278 |
+
lemma erase_void_witness (W : Finset V) (hW : W.Nonempty) (ω : V → Bool)
|
| 279 |
+
(hbad : (W ∩ selected ω).card < 2) :
|
| 280 |
+
∃ j ∈ W, ω ∈ voidEvent (W.erase j) := by
|
| 281 |
+
have hsmall : (W ∩ selected ω).card ≤ 1 := by omega
|
| 282 |
+
have hc := Finset.card_le_one.mp hsmall
|
| 283 |
+
by_cases he : (W ∩ selected ω).Nonempty
|
| 284 |
+
· obtain ⟨j, hj⟩ := he
|
| 285 |
+
refine ⟨j, (Finset.mem_inter.mp hj).1, ?_⟩
|
| 286 |
+
intro k hk
|
| 287 |
+
apply Set.mem_singleton_iff.mpr
|
| 288 |
+
apply Bool.eq_false_of_not_eq_true
|
| 289 |
+
intro hkt
|
| 290 |
+
have hkm : k ∈ W ∩ selected ω := by
|
| 291 |
+
simp only [Finset.mem_inter, selected, Finset.mem_filter, Finset.mem_univ, true_and]
|
| 292 |
+
exact ⟨(Finset.mem_erase.mp hk).2, hkt⟩
|
| 293 |
+
exact (Finset.mem_erase.mp hk).1 (hc k hkm j hj)
|
| 294 |
+
· obtain ⟨j, hj⟩ := hW
|
| 295 |
+
refine ⟨j, hj, ?_⟩
|
| 296 |
+
intro k hk
|
| 297 |
+
apply Set.mem_singleton_iff.mpr
|
| 298 |
+
apply Bool.eq_false_of_not_eq_true
|
| 299 |
+
intro hkt
|
| 300 |
+
apply he
|
| 301 |
+
refine ⟨k, ?_⟩
|
| 302 |
+
simp only [Finset.mem_inter, selected, Finset.mem_filter, Finset.mem_univ, true_and]
|
| 303 |
+
exact ⟨(Finset.mem_erase.mp hk).2, hkt⟩
|
| 304 |
+
|
| 305 |
+
lemma badIndicator_le_erase_void (W : Finset V) (hW : W.Nonempty) (ω : V → Bool) :
|
| 306 |
+
badIndicator W ω ≤ ∑ j ∈ W, voidIndicator (W.erase j) ω := by
|
| 307 |
+
unfold badIndicator
|
| 308 |
+
split_ifs with hb
|
| 309 |
+
· obtain ⟨j, hj, hv⟩ := erase_void_witness W hW ω hb
|
| 310 |
+
have hle := Finset.single_le_sum (f := fun j => voidIndicator (W.erase j) ω)
|
| 311 |
+
(fun j _ => voidIndicator_nonneg _ _) hj
|
| 312 |
+
simpa only [voidIndicator, Set.indicator_of_mem hv] using hle
|
| 313 |
+
· exact Finset.sum_nonneg (fun j _ => voidIndicator_nonneg _ _)
|
| 314 |
+
|
| 315 |
+
lemma integral_badIndicator_le (W : Finset V) (hW : W.Nonempty) :
|
| 316 |
+
∫ ω, badIndicator W ω ∂rootMeasure ≤
|
| 317 |
+
W.card * (19 / 20 : ℝ) ^ (W.card - 1) := by
|
| 318 |
+
calc
|
| 319 |
+
_ ≤ ∫ ω, ∑ j ∈ W, voidIndicator (W.erase j) ω ∂rootMeasure :=
|
| 320 |
+
integral_mono (integrable_badIndicator W)
|
| 321 |
+
(integrable_finsetSum _ (fun j _ => integrable_voidIndicator _))
|
| 322 |
+
(badIndicator_le_erase_void W hW)
|
| 323 |
+
_ = ∑ j ∈ W, (19 / 20 : ℝ) ^ (W.card - 1) := by
|
| 324 |
+
rw [integral_finsetSum _ (fun j _ => integrable_voidIndicator _)]
|
| 325 |
+
apply Finset.sum_congr rfl
|
| 326 |
+
intro j hj
|
| 327 |
+
rw [integral_voidIndicator, Finset.card_erase_of_mem hj]
|
| 328 |
+
_ = _ := by simp
|
| 329 |
+
|
| 330 |
+
omit [DecidableEq V] in
|
| 331 |
+
lemma indicator_selected (ω : V → Bool) :
|
| 332 |
+
((selected ω).card : ℝ) = ∑ v : V, if ω v = true then (1 : ℝ) else 0 := by
|
| 333 |
+
symm
|
| 334 |
+
exact Finset.sum_boole _ _
|
| 335 |
+
omit [DecidableEq V] in
|
| 336 |
+
|
| 337 |
+
lemma integrable_selected_card :
|
| 338 |
+
Integrable (fun ω : V → Bool => ((selected ω).card : ℝ)) rootMeasure := by
|
| 339 |
+
simp_rw [indicator_selected]
|
| 340 |
+
apply integrable_finsetSum
|
| 341 |
+
intro v hv
|
| 342 |
+
apply integrable_bounded _ 1
|
| 343 |
+
intro ω
|
| 344 |
+
split_ifs <;> norm_num
|
| 345 |
+
omit [DecidableEq V] in
|
| 346 |
+
|
| 347 |
+
lemma integral_selected_card :
|
| 348 |
+
∫ ω : V → Bool, ((selected ω).card : ℝ) ∂rootMeasure = (Fintype.card V : ℝ) / 20 := by
|
| 349 |
+
simp_rw [indicator_selected]
|
| 350 |
+
rw [integral_finsetSum]
|
| 351 |
+
· have hv (v : V) :
|
| 352 |
+
(∫ ω : V → Bool, if ω v = true then (1 : ℝ) else 0 ∂rootMeasure) = 1 / 20 := by
|
| 353 |
+
rw [rootMeasure, integral_comp_eval (μ := fun _ : V => bernoulliMeasure true false rootProbability) (i := v) (f := fun a : Bool => if a = true then (1 : ℝ) else 0)
|
| 354 |
+
(measurable_of_countable _).aestronglyMeasurable,
|
| 355 |
+
integral_bernoulliMeasure]
|
| 356 |
+
norm_num [rootProbability]
|
| 357 |
+
simp_rw [hv]
|
| 358 |
+
simp [div_eq_mul_inv]
|
| 359 |
+
· intro v hv
|
| 360 |
+
apply integrable_bounded _ 1
|
| 361 |
+
intro ω
|
| 362 |
+
split_ifs <;> norm_num
|
| 363 |
+
|
| 364 |
+
theorem exists_small_root_set (W : V → Finset V) {k : ℕ} (hk : 0 < k)
|
| 365 |
+
(hW : ∀ v, (W v).card = k)
|
| 366 |
+
(herr : (Fintype.card V : ℝ) * k * (19 / 20 : ℝ) ^ (k - 1) < 1 / 2) :
|
| 367 |
+
∃ roots : Finset V, 10 * roots.card ≤ Fintype.card V ∧
|
| 368 |
+
∀ v, 2 ≤ (W v ∩ roots).card := by
|
| 369 |
+
classical
|
| 370 |
+
by_cases hn : Fintype.card V = 0
|
| 371 |
+
· have : IsEmpty V := Fintype.card_eq_zero_iff.mp hn
|
| 372 |
+
exact ⟨∅, by simp [], fun v => isEmptyElim v⟩
|
| 373 |
+
have hnpos : (0 : ℝ) < Fintype.card V := by exact_mod_cast (Nat.pos_of_ne_zero hn)
|
| 374 |
+
let F : (V → Bool) → ℝ := fun ω =>
|
| 375 |
+
(10 / Fintype.card V : ℝ) * (selected ω).card + ∑ v, badIndicator (W v) ω
|
| 376 |
+
have hFi : Integrable F rootMeasure :=
|
| 377 |
+
(integrable_selected_card.const_mul _).add
|
| 378 |
+
(integrable_finsetSum _ (fun v _ => integrable_badIndicator (W v)))
|
| 379 |
+
have hFint : ∫ ω, F ω ∂rootMeasure < 1 := by
|
| 380 |
+
have he (v : V) : ∫ ω, badIndicator (W v) ω ∂rootMeasure ≤
|
| 381 |
+
k * (19 / 20 : ℝ) ^ (k - 1) := by
|
| 382 |
+
simpa only [hW] using integral_badIndicator_le (W v) (Finset.card_pos.mp (by rw [hW v]; exact hk))
|
| 383 |
+
have sumle : ∑ v : V, (∫ ω, badIndicator (W v) ω ∂rootMeasure) ≤
|
| 384 |
+
(Fintype.card V : ℝ) * k * (19 / 20 : ℝ) ^ (k - 1) := by
|
| 385 |
+
calc
|
| 386 |
+
_ ≤ ∑ _v : V, (k : ℝ) * (19 / 20 : ℝ) ^ (k - 1) := Finset.sum_le_sum (fun v _ => he v)
|
| 387 |
+
_ = _ := by simp; ring
|
| 388 |
+
have hc : (10 / Fintype.card V : ℝ) * ((Fintype.card V : ℝ) / 20) = 1 / 2 := by
|
| 389 |
+
field_simp
|
| 390 |
+
; ring
|
| 391 |
+
dsimp [F]
|
| 392 |
+
rw [integral_add (integrable_selected_card.const_mul _)
|
| 393 |
+
(integrable_finsetSum _ (fun v _ => integrable_badIndicator (W v))),
|
| 394 |
+
integral_const_mul, integral_selected_card, integral_finsetSum _
|
| 395 |
+
(fun v _ => integrable_badIndicator (W v)), hc]
|
| 396 |
+
linarith
|
| 397 |
+
have hex : ∃ ω, F ω < 1 := by
|
| 398 |
+
by_contra h
|
| 399 |
+
push Not at h
|
| 400 |
+
have hle := integral_mono (integrable_const (1 : ℝ)) hFi h
|
| 401 |
+
simp only [integral_const] at hle
|
| 402 |
+
simp at hle
|
| 403 |
+
linarith
|
| 404 |
+
obtain ⟨ω, hω⟩ := hex
|
| 405 |
+
have hsum : 0 ≤ ∑ v : V, badIndicator (W v) ω :=
|
| 406 |
+
Finset.sum_nonneg (fun v _ => badIndicator_nonneg _ _)
|
| 407 |
+
have hcost : 0 ≤ (10 / Fintype.card V : ℝ) * (selected ω).card := by positivity
|
| 408 |
+
refine ⟨selected ω, ?_, ?_⟩
|
| 409 |
+
· have ht : (10 / Fintype.card V : ℝ) * (selected ω).card < 1 := by dsimp [F] at hω; linarith
|
| 410 |
+
have hcard : (10 : ℝ) * (selected ω).card ≤ Fintype.card V := by
|
| 411 |
+
have := (mul_lt_mul_iff_right₀ hnpos).mpr ht
|
| 412 |
+
field_simp at this
|
| 413 |
+
nlinarith
|
| 414 |
+
exact_mod_cast hcard
|
| 415 |
+
· intro v
|
| 416 |
+
by_contra hv
|
| 417 |
+
have hbad : badIndicator (W v) ω = 1 := by simp [badIndicator, show (W v ∩ selected ω).card < 2 by omega]
|
| 418 |
+
have hle := Finset.single_le_sum (f := fun v => badIndicator (W v) ω)
|
| 419 |
+
(fun v _ => badIndicator_nonneg _ _) (Finset.mem_univ v)
|
| 420 |
+
rw [hbad] at hle
|
| 421 |
+
dsimp [F] at hω
|
| 422 |
+
linarith
|
| 423 |
+
|
| 424 |
+
section WitnessMatching
|
| 425 |
+
|
| 426 |
+
variable {E N D : Type*} [DecidableEq E] [DecidableEq N] [DecidableEq D]
|
| 427 |
+
|
| 428 |
+
theorem exists_distinct_witnesses (s : Finset E) (neighbor : E → N) (direction : E → D)
|
| 429 |
+
(K : ℕ) (hn : ∀ n, (s.filter (fun e => neighbor e = n)).card ≤ K)
|
| 430 |
+
(hd : ∀ d, (s.filter (fun e => direction e = d)).card ≤ K) :
|
| 431 |
+
∃ t ⊆ s, Set.InjOn neighbor (t : Set E) ∧ Set.InjOn direction (t : Set E) ∧
|
| 432 |
+
s.card ≤ 2 * K * t.card := by
|
| 433 |
+
classical
|
| 434 |
+
let family : Finset (Finset E) := s.powerset.filter (fun t =>
|
| 435 |
+
Set.InjOn neighbor (t : Set E) ∧ Set.InjOn direction (t : Set E))
|
| 436 |
+
have hempty : ∅ ∈ family := by simp [family, Set.injOn_empty]
|
| 437 |
+
obtain ⟨t, htf, hmax⟩ := Finset.exists_max_image family Finset.card ⟨∅, hempty⟩
|
| 438 |
+
have ht : t ⊆ s := Finset.mem_powerset.mp (Finset.mem_filter.mp htf).1
|
| 439 |
+
have hinj := (Finset.mem_filter.mp htf).2
|
| 440 |
+
have hcover (e : E) (he : e ∈ s) :
|
| 441 |
+
∃ a ∈ t, neighbor e = neighbor a ∨ direction e = direction a := by
|
| 442 |
+
by_contra h
|
| 443 |
+
push Not at h
|
| 444 |
+
have hen : e ∉ t := by
|
| 445 |
+
intro het
|
| 446 |
+
exact (h e het).1 rfl
|
| 447 |
+
have hnnew : Set.InjOn neighbor (↑(insert e t) : Set E) := by
|
| 448 |
+
rw [Finset.coe_insert, Set.injOn_insert hen]
|
| 449 |
+
refine ⟨hinj.1, ?_⟩
|
| 450 |
+
rintro ⟨a, ha, hea⟩
|
| 451 |
+
exact (h a ha).1 hea.symm
|
| 452 |
+
have hdnew : Set.InjOn direction (↑(insert e t) : Set E) := by
|
| 453 |
+
rw [Finset.coe_insert, Set.injOn_insert hen]
|
| 454 |
+
refine ⟨hinj.2, ?_⟩
|
| 455 |
+
rintro ⟨a, ha, hea⟩
|
| 456 |
+
exact (h a ha).2 hea.symm
|
| 457 |
+
have hnew : insert e t �� family := by
|
| 458 |
+
simp only [family, Finset.mem_filter, Finset.mem_powerset]
|
| 459 |
+
exact ⟨Finset.insert_subset he ht, hnnew, hdnew⟩
|
| 460 |
+
have := hmax _ hnew
|
| 461 |
+
rw [Finset.card_insert_of_notMem hen] at this
|
| 462 |
+
omega
|
| 463 |
+
refine ⟨t, ht, hinj.1, hinj.2, ?_⟩
|
| 464 |
+
have hsub : s ⊆ t.biUnion (fun a =>
|
| 465 |
+
(s.filter (fun e => neighbor e = neighbor a)) ∪
|
| 466 |
+
(s.filter (fun e => direction e = direction a))) := by
|
| 467 |
+
intro e he
|
| 468 |
+
obtain ⟨a, ha, hor⟩ := hcover e he
|
| 469 |
+
apply Finset.mem_biUnion.mpr
|
| 470 |
+
refine ⟨a, ha, ?_⟩
|
| 471 |
+
simpa only [Finset.mem_union, Finset.mem_filter, and_or_left] using
|
| 472 |
+
And.intro he hor
|
| 473 |
+
calc
|
| 474 |
+
s.card ≤ _ := Finset.card_le_card hsub
|
| 475 |
+
_ ≤ ∑ a ∈ t, ((s.filter (fun e => neighbor e = neighbor a)) ∪
|
| 476 |
+
(s.filter (fun e => direction e = direction a))).card := Finset.card_biUnion_le
|
| 477 |
+
_ ≤ ∑ _a ∈ t, 2 * K := by
|
| 478 |
+
apply Finset.sum_le_sum
|
| 479 |
+
intro a ha
|
| 480 |
+
exact (Finset.card_union_le _ _).trans (by have := hn (neighbor a); have := hd (direction a); omega)
|
| 481 |
+
_ = 2 * K * t.card := by simp [Nat.mul_comm]
|
| 482 |
+
|
| 483 |
+
end WitnessMatching
|
| 484 |
+
end SharpRamseyFive.ResidualCertificate
|
| 485 |
+
end
|
| 486 |
+
|
| 487 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/PatchNotMem.lean
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Entropy.ShiftKernelSum
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators NNReal
|
| 11 |
+
open MeasureTheory ProbabilityTheory
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
open MeasureTheory ProbabilityTheory
|
| 15 |
+
open scoped BigOperators ENNReal NNReal
|
| 16 |
+
namespace SharpRamseyFive.ResidualElimination
|
| 17 |
+
open scoped BigOperators
|
| 18 |
+
open Classical
|
| 19 |
+
variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
|
| 20 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 21 |
+
lemma patch_notMem (g : V → H) (T : Finset V) (x : T → H) (u : V) (hu : u ∉ T) :
|
| 22 |
+
patch g T x u = g u := by simp [patch, hu]
|
| 23 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 24 |
+
|
| 25 |
+
lemma agrees_sdiff_patch (E T : Finset V) (hT : T ⊆ E) (g f : V → H) (x : T → H) :
|
| 26 |
+
Agrees (E \ T) (patch g T x) f ↔ Agrees E g f ∧ x = fun u : T => f u := by
|
| 27 |
+
constructor
|
| 28 |
+
· intro h
|
| 29 |
+
constructor
|
| 30 |
+
· intro u hu
|
| 31 |
+
have hnu : u ∉ T := fun hh => hu (hT hh)
|
| 32 |
+
simpa only [patch_notMem g T x u hnu] using h u (by simp [hu])
|
| 33 |
+
· funext u
|
| 34 |
+
have hu := h u (by simp)
|
| 35 |
+
simpa only [patch_mem] using hu.symm
|
| 36 |
+
· rintro ⟨h,rfl⟩ u hu
|
| 37 |
+
by_cases hnu : u ∈ T
|
| 38 |
+
· simp [patch, hnu]
|
| 39 |
+
· rw [patch_notMem g T _ u hnu]
|
| 40 |
+
exact h u (by simpa [hnu] using hu)
|
| 41 |
+
|
| 42 |
+
lemma completionSum_split (E T : Finset V) (hT : T ⊆ E) (g : V → H)
|
| 43 |
+
(F : (V → H) → ℝ) :
|
| 44 |
+
completionSum E g F = ∑ x : T → H, completionSum (E \ T) (patch g T x) F := by
|
| 45 |
+
unfold completionSum
|
| 46 |
+
rw [Finset.sum_comm]
|
| 47 |
+
apply Finset.sum_congr rfl
|
| 48 |
+
intro f _
|
| 49 |
+
simp only [agrees_sdiff_patch E T hT]
|
| 50 |
+
by_cases hf : Agrees E g f <;> simp [hf]
|
| 51 |
+
|
| 52 |
+
theorem weighted_block_exposure (E T : Finset V) (hT : T ⊆ E) (g : V → H)
|
| 53 |
+
(w : (T → H) → ℝ) (hw : ∀ x, 0 ≤ w x) (F : (V → H) → ℝ)
|
| 54 |
+
(C : ℝ) (hF : ∀ g, completionSum (E \ T) g F ≤ C) :
|
| 55 |
+
completionSum E g (fun f => w (fun u : T => f u) * F f) ≤
|
| 56 |
+
(∑ x : T → H, w x) * C := by
|
| 57 |
+
rw [completionSum_split E T hT, Finset.sum_mul]
|
| 58 |
+
apply Finset.sum_le_sum
|
| 59 |
+
intro x _
|
| 60 |
+
calc
|
| 61 |
+
_ = completionSum (E \ T) (patch g T x) (fun f => w x * F f) := by
|
| 62 |
+
apply completionSum_congr
|
| 63 |
+
intro f hf
|
| 64 |
+
have hx := (agrees_sdiff_patch E T hT g f x).mp hf
|
| 65 |
+
rw [← hx.2]
|
| 66 |
+
_ = w x * completionSum (E \ T) (patch g T x) F := completionSum_mul ..
|
| 67 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left (hF _) (hw x)
|
| 68 |
+
|
| 69 |
+
theorem independent_positions_exposure (E T : Finset V) (hT : T ⊆ E) (g : V → H)
|
| 70 |
+
(w : V → H → ℝ) (hw : ∀ u h, 0 ≤ w u h) (F : (V → H) → ℝ)
|
| 71 |
+
(C : ℝ) (hF : ∀ g, completionSum (E \ T) g F ≤ C) :
|
| 72 |
+
completionSum E g (fun f => (∏ u ∈ T, w u (f u)) * F f) ≤
|
| 73 |
+
(∏ u ∈ T, ∑ h : H, w u h) * C := by
|
| 74 |
+
let W : (T → H) → ℝ := fun x => ∏ u : T, w u (x u)
|
| 75 |
+
have hW : ∀ x, 0 ≤ W x := by
|
| 76 |
+
intro x
|
| 77 |
+
exact Finset.prod_nonneg (fun u _ => hw _ _)
|
| 78 |
+
have he (f : V → H) : (∏ u ∈ T, w u (f u)) = W (fun u : T => f u) := by
|
| 79 |
+
exact (Finset.prod_coe_sort T (fun u => w u (f u))).symm
|
| 80 |
+
simp_rw [he]
|
| 81 |
+
apply (weighted_block_exposure E T hT g W hW F C hF).trans_eq
|
| 82 |
+
have hs : (∑ x : T → H, W x) = ∏ u ∈ T, ∑ h : H, w u h := by
|
| 83 |
+
rw [show (∑ x : T → H, W x) = ∏ u : T, ∑ h : H, w u h from
|
| 84 |
+
(Fintype.prod_sum (fun u : T => w u)).symm]
|
| 85 |
+
exact Finset.prod_coe_sort T (fun u => ∑ h : H, w u h)
|
| 86 |
+
rw [hs]
|
| 87 |
+
|
| 88 |
+
end SharpRamseyFive.ResidualElimination
|
| 89 |
+
|
| 90 |
+
namespace SharpRamseyFive.ResidualElimination
|
| 91 |
+
open scoped BigOperators
|
| 92 |
+
open Classical
|
| 93 |
+
variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
|
| 94 |
+
|
| 95 |
+
omit [Fintype V] in
|
| 96 |
+
lemma powerset_sdiff (E U : Finset V) :
|
| 97 |
+
(E \ U).powerset = E.powerset.filter (fun S => Disjoint S U) := by
|
| 98 |
+
ext S
|
| 99 |
+
simp only [Finset.mem_powerset, Finset.mem_filter]
|
| 100 |
+
constructor
|
| 101 |
+
· intro h
|
| 102 |
+
refine ⟨h.trans Finset.sdiff_subset, Finset.disjoint_left.mpr ?_⟩
|
| 103 |
+
intro u hu hU
|
| 104 |
+
exact (Finset.mem_sdiff.mp (h hu)).2 hU
|
| 105 |
+
· rintro ⟨h,hD⟩ u hu
|
| 106 |
+
exact Finset.mem_sdiff.mpr ⟨h hu, fun hU => Finset.disjoint_left.mp hD hu hU⟩
|
| 107 |
+
omit [Fintype V] in
|
| 108 |
+
|
| 109 |
+
lemma sum_disjoint_swap (E : Finset V) (F : Finset V → Finset V → ℝ) :
|
| 110 |
+
(∑ U ∈ E.powerset, ∑ S ∈ (E \ U).powerset, F U S) =
|
| 111 |
+
∑ S ∈ E.powerset, ∑ U ∈ (E \ S).powerset, F U S := by
|
| 112 |
+
simp_rw [powerset_sdiff, Finset.sum_filter]
|
| 113 |
+
rw [Finset.sum_comm]
|
| 114 |
+
apply Finset.sum_congr rfl
|
| 115 |
+
intro S hS
|
| 116 |
+
apply Finset.sum_congr rfl
|
| 117 |
+
intro U hU
|
| 118 |
+
simp only [disjoint_comm]
|
| 119 |
+
|
| 120 |
+
noncomputable def badExpansion (a : V → (V → H) → ℝ)
|
| 121 |
+
(B : Finset V → (V → H) → ℝ) (E : Finset V) (f : V → H) : ℝ :=
|
| 122 |
+
∑ U ∈ E.powerset, (∏ u ∈ E \ U, a u f) * B U f
|
| 123 |
+
|
| 124 |
+
omit [Fintype V] [Fintype H] [DecidableEq H] in
|
| 125 |
+
lemma badExpansion_nonneg (a : V → (V → H) → ℝ)
|
| 126 |
+
(B : Finset V → (V → H) → ℝ) (ha : ∀ u f, 0 ≤ a u f)
|
| 127 |
+
(hB : ∀ E f, 0 ≤ B E f) (E : Finset V) (f : V → H) :
|
| 128 |
+
0 ≤ badExpansion a B E f := by
|
| 129 |
+
apply Finset.sum_nonneg
|
| 130 |
+
intro U hU
|
| 131 |
+
exact mul_nonneg (Finset.prod_nonneg (fun u _ => ha u f)) (hB U f)
|
| 132 |
+
|
| 133 |
+
omit [Fintype H] [DecidableEq H] in
|
| 134 |
+
omit [Fintype V] in
|
| 135 |
+
lemma badExpansion_add (a d : V → (V → H) → ℝ)
|
| 136 |
+
(B : Finset V → (V → H) → ℝ) (E : Finset V) (f : V → H) :
|
| 137 |
+
badExpansion (fun u f => d u f + a u f) B E f =
|
| 138 |
+
∑ S ∈ E.powerset, (∏ u ∈ S, d u f) * badExpansion a B (E \ S) f := by
|
| 139 |
+
unfold badExpansion
|
| 140 |
+
simp_rw [Finset.prod_add, Finset.sum_mul]
|
| 141 |
+
rw [sum_disjoint_swap]
|
| 142 |
+
apply Finset.sum_congr rfl
|
| 143 |
+
intro S hS
|
| 144 |
+
rw [Finset.mul_sum]
|
| 145 |
+
apply Finset.sum_congr rfl
|
| 146 |
+
intro U hU
|
| 147 |
+
have he : (E \ U) \ S = (E \ S) \ U := sdiff_sdiff_comm
|
| 148 |
+
rw [he, mul_assoc]
|
| 149 |
+
omit [DecidableEq H] in
|
| 150 |
+
|
| 151 |
+
lemma badExpansion_sum_le (a : V → (V → H) → ℝ)
|
| 152 |
+
(B : Finset V → (V → H) → ℝ) (E : Finset V) (g : V → H)
|
| 153 |
+
(M : ℝ) (_hM : 0 ≤ M)
|
| 154 |
+
(hterm : ∀ S, S ⊆ E → completionSum E g (term a B E S) ≤ M ^ E.card) :
|
| 155 |
+
completionSum E g (badExpansion a B E) ≤ (2 * M) ^ E.card := by
|
| 156 |
+
rw [show badExpansion a B E = (fun f => ∑ U ∈ E.powerset,
|
| 157 |
+
(∏ u ∈ E \ U, a u f) * B U f) from rfl, completionSum_sum]
|
| 158 |
+
calc
|
| 159 |
+
_ ≤ ∑ _U ∈ E.powerset, M ^ E.card := by
|
| 160 |
+
apply Finset.sum_le_sum
|
| 161 |
+
intro U hU
|
| 162 |
+
have hU : U ⊆ E := Finset.mem_powerset.mp hU
|
| 163 |
+
have he : E \ (E \ U) = U := Finset.sdiff_sdiff_eq_self hU
|
| 164 |
+
have ht := hterm (E \ U) Finset.sdiff_subset
|
| 165 |
+
change completionSum E g (fun f => (∏ u ∈ E \ U, a u f) *
|
| 166 |
+
B (E \ (E \ U)) f) ≤ M ^ E.card at ht
|
| 167 |
+
simpa only [he] using ht
|
| 168 |
+
_ = _ := by simp [mul_pow]
|
| 169 |
+
|
| 170 |
+
theorem all_singleton_enumeration
|
| 171 |
+
(a : V → (V → H) → ℝ) (d : V → H → ℝ) (B : Finset V → (V → H) → ℝ)
|
| 172 |
+
(W : H → H → ℝ) (C D : ℝ) (hC : 0 ≤ C) (_hD : 0 ≤ D)
|
| 173 |
+
(ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1)
|
| 174 |
+
(hd : ∀ u x, 0 ≤ d u x) (hsum : ∀ u, (∑ x : H, d u x) ≤ D)
|
| 175 |
+
(hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f)
|
| 176 |
+
(hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f)
|
| 177 |
+
(hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v))
|
| 178 |
+
(hrow : ∀ y, (∑ x : H, W x y) ≤ C)
|
| 179 |
+
(hpair : (∑ x : H, ∑ y : H, W x y) ≤ C ^ 2)
|
| 180 |
+
(hbad : ∀ A g, completionSum A g (B A) ≤ C ^ A.card)
|
| 181 |
+
(E : Finset V) (g : V → H) :
|
| 182 |
+
completionSum E g (badExpansion (fun u f => d u (f u) + a u f) B E) ≤
|
| 183 |
+
(D + 2 * ((Fintype.card V + 1 : ℝ) * C)) ^ E.card := by
|
| 184 |
+
let M : ℝ := (Fintype.card V + 1) * C
|
| 185 |
+
have hM : 0 ≤ M := by dsimp [M]; positivity
|
| 186 |
+
have hbnd (A : Finset V) (g : V → H) :
|
| 187 |
+
completionSum A g (badExpansion a B A) ≤ (2 * M) ^ A.card := by
|
| 188 |
+
apply badExpansion_sum_le a B A g M hM
|
| 189 |
+
intro S hS
|
| 190 |
+
exact shift_bad_enumeration a B W C hC ha hW hB hmono hshift hrow hpair hbad A S hS g
|
| 191 |
+
have he : badExpansion (fun u f => d u (f u) + a u f) B E =
|
| 192 |
+
fun f => ∑ S ∈ E.powerset, (∏ u ∈ S, d u (f u)) * badExpansion a B (E \ S) f := by
|
| 193 |
+
funext f
|
| 194 |
+
exact badExpansion_add a (fun u f => d u (f u)) B E f
|
| 195 |
+
rw [he, completionSum_sum]
|
| 196 |
+
calc
|
| 197 |
+
_ ≤ ∑ S ∈ E.powerset, D ^ S.card * (2 * M) ^ (E \ S).card := by
|
| 198 |
+
apply Finset.sum_le_sum
|
| 199 |
+
intro S hS
|
| 200 |
+
apply (independent_positions_exposure E S (Finset.mem_powerset.mp hS) g d hd
|
| 201 |
+
(badExpansion a B (E \ S)) ((2 * M) ^ (E \ S).card) (hbnd (E \ S))).trans
|
| 202 |
+
apply mul_le_mul_of_nonneg_right _ (pow_nonneg (by positivity) _)
|
| 203 |
+
calc
|
| 204 |
+
(∏ u ∈ S, ∑ x : H, d u x) ≤ ∏ _u ∈ S, D :=
|
| 205 |
+
Finset.prod_le_prod₀ (fun u _ => Finset.sum_nonneg (fun x _ => hd u x))
|
| 206 |
+
(fun u _ => hsum u)
|
| 207 |
+
_ = _ := Finset.prod_const _
|
| 208 |
+
_ = (D + 2 * M) ^ E.card := by
|
| 209 |
+
have := Finset.prod_add (fun _ : V => D) (fun _ => 2 * M) E
|
| 210 |
+
simpa only [Finset.prod_const] using this.symm
|
| 211 |
+
|
| 212 |
+
end SharpRamseyFive.ResidualElimination
|
| 213 |
+
|
| 214 |
+
namespace SharpRamseyFive.SingletonEnumeration
|
| 215 |
+
open MeasureTheory ProbabilityTheory
|
| 216 |
+
open scoped BigOperators NNReal
|
| 217 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 218 |
+
open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations
|
| 219 |
+
open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms
|
| 220 |
+
open SharpRamseyFive.ResidualElimination
|
| 221 |
+
open Classical
|
| 222 |
+
variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 223 |
+
[Fintype H] [DecidableEq H]
|
| 224 |
+
|
| 225 |
+
noncomputable def independentWeight (weight rate : D → ℝ≥0) (lines : H → Finset D)
|
| 226 |
+
(R J : ℕ) (base : ℝ) (h : H) : ℝ :=
|
| 227 |
+
|mass weight (lines h) - base| ^ (R / 2) +
|
| 228 |
+
(if R < J then 0 else ∑ d ∈ lines h, ((R : ℝ) * (rate d : ℝ)) ^ J)
|
| 229 |
+
|
| 230 |
+
omit [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H] in
|
| 231 |
+
lemma independentWeight_nonneg (weight rate : D → ℝ≥0) (lines : H → Finset D)
|
| 232 |
+
(R J : ℕ) (base : ℝ) (h : H) : 0 ≤ independentWeight weight rate lines R J base h := by
|
| 233 |
+
unfold independentWeight
|
| 234 |
+
split_ifs <;> positivity
|
| 235 |
+
|
| 236 |
+
theorem actual_all_singleton_enumeration (weight rate : D → ℝ≥0) (lines : H → Finset D)
|
| 237 |
+
{p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p)
|
| 238 |
+
(R : ℕ) (denom b mass C D₀ base : ℝ)
|
| 239 |
+
(hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hC : 0 ≤ C) (hD : 0 ≤ D₀)
|
| 240 |
+
(hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass)
|
| 241 |
+
(K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool)
|
| 242 |
+
(hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K))
|
| 243 |
+
(herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2)
|
| 244 |
+
(hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁)
|
| 245 |
+
(hN₂ : ∀ d e, d ≠ e →
|
| 246 |
+
(Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂)
|
| 247 |
+
(hBC : denom * (1 + branchingBound (V := V) (B := Fin R)
|
| 248 |
+
(fun z : H × V => lines z.1) rate denom b mass K
|
| 249 |
+
(N₁ * Fintype.card V) (N₂ * Fintype.card V) low) ≤ C)
|
| 250 |
+
(hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C)
|
| 251 |
+
(hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2)
|
| 252 |
+
(hDsum : (∑ x : H, independentWeight weight rate lines R J base x) ≤ D₀)
|
| 253 |
+
(E : Finset V) (g : V → H) :
|
| 254 |
+
completionSum E g (badExpansion
|
| 255 |
+
(fun u f => independentWeight weight rate lines R J base (f u) +
|
| 256 |
+
alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K)
|
| 257 |
+
(fun A f => vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J A) E) ≤
|
| 258 |
+
(D₀ + 2 * ((Fintype.card V + 1 : ℝ) * C)) ^ E.card := by
|
| 259 |
+
apply all_singleton_enumeration
|
| 260 |
+
(fun u f => alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K)
|
| 261 |
+
(fun _ x => independentWeight weight rate lines R J base x)
|
| 262 |
+
(fun A f => vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J A)
|
| 263 |
+
(shiftKernel weight lines p K) C D₀ hC hD
|
| 264 |
+
· intro u f
|
| 265 |
+
exact ⟨pow_nonneg (alpha_nonneg _ _ _ _) _,
|
| 266 |
+
pow_le_one₀ (alpha_nonneg _ _ _ _) (by
|
| 267 |
+
have := source_alpha_le weight (lines ∘ f) hp hc u
|
| 268 |
+
linarith)⟩
|
| 269 |
+
· exact fun _ x => independentWeight_nonneg weight rate lines R J base x
|
| 270 |
+
· exact fun _ => hDsum
|
| 271 |
+
· exact fun x y => (shiftKernel_range weight lines p K x y).1
|
| 272 |
+
· exact fun A f => vertexBadMass_nonneg _ _ _ _ _ _ _
|
| 273 |
+
· exact fun A A' hh f => vertexBadMass_antitone _ _ _ _ _ _ hh
|
| 274 |
+
· exact fun u f => shift_le_kernel_sum weight lines hp hc (by omega) u f
|
| 275 |
+
· exact hrow
|
| 276 |
+
· exact hpair
|
| 277 |
+
· intro A g
|
| 278 |
+
apply (actual_bad_completion weight rate lines (1 / (100 * p)) R denom b mass
|
| 279 |
+
hd hb hm hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ A g).trans
|
| 280 |
+
apply pow_le_pow_left₀ _ hBC
|
| 281 |
+
apply mul_nonneg hd.le
|
| 282 |
+
have hn := branchingBound_nonneg (V := V) (B := Fin R)
|
| 283 |
+
(fun z : H × V => lines z.1) rate denom b mass hd.le (by linarith) hm K
|
| 284 |
+
(N₁ * Fintype.card V) (N₂ * Fintype.card V) low
|
| 285 |
+
linarith
|
| 286 |
+
|
| 287 |
+
end SharpRamseyFive.SingletonEnumeration
|
| 288 |
+
|
| 289 |
+
namespace SharpRamseyFive.SingletonEnumeration
|
| 290 |
+
open MeasureTheory ProbabilityTheory
|
| 291 |
+
open scoped BigOperators NNReal
|
| 292 |
+
open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents
|
| 293 |
+
open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations
|
| 294 |
+
open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms
|
| 295 |
+
open SharpRamseyFive.ResidualElimination
|
| 296 |
+
open Classical
|
| 297 |
+
variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V]
|
| 298 |
+
[Fintype H] [DecidableEq H]
|
| 299 |
+
|
| 300 |
+
lemma inside_sum_le {C : Type} [Fintype C] [DecidableEq C]
|
| 301 |
+
(label : D → Option C) (c : C) (S : Finset D) (F : D → ℝ) (hF : ∀ d, 0 ≤ F d) :
|
| 302 |
+
(∑ d ∈ inside label c S, F d) ≤ ∑ d ∈ S, F d := by
|
| 303 |
+
have hi : Function.Injective (Subtype.val : IntDir label c → D) := Subtype.val_injective
|
| 304 |
+
rw [← Finset.sum_image (hi.injOn)]
|
| 305 |
+
apply Finset.sum_le_sum_of_subset_of_nonneg
|
| 306 |
+
· intro d hd
|
| 307 |
+
rcases Finset.mem_image.mp hd with ⟨e,he,rfl⟩
|
| 308 |
+
exact (Finset.mem_filter.mp he).2
|
| 309 |
+
· exact fun d _ _ => hF d
|
| 310 |
+
|
| 311 |
+
omit [Fintype H] [DecidableEq H] in
|
| 312 |
+
lemma extraWeight_le_independent (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 313 |
+
(f : V → H) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ)
|
| 314 |
+
(c : Components weight (lines ∘ f) t) :
|
| 315 |
+
extraWeight weight (lines ∘ f) t R J K L base c ≤
|
| 316 |
+
independentWeight weight (fun d => L * weight d) lines R J base
|
| 317 |
+
(f (vertex weight (lines ∘ f) t c)) +
|
| 318 |
+
alpha weight (lines ∘ f) t (vertex weight (lines ∘ f) t c) ^ K := by
|
| 319 |
+
unfold extraWeight independentWeight delta
|
| 320 |
+
have h := inside_sum_le (componentLabel weight (lines ∘ f) t) c
|
| 321 |
+
((lines ∘ f) (vertex weight (lines ∘ f) t c))
|
| 322 |
+
(fun d => ((R : ℝ) * ((L * weight d : ℝ≥0) : ℝ)) ^ J) (fun _ => by positivity)
|
| 323 |
+
dsimp only [Function.comp_def] at *
|
| 324 |
+
split_ifs <;> linarith
|
| 325 |
+
|
| 326 |
+
omit [Fintype H] [DecidableEq H] in
|
| 327 |
+
|
| 328 |
+
theorem designation_sum_le_vertex (weight : D → ℝ≥0) (lines : H → Finset D)
|
| 329 |
+
(f : V → H) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) :
|
| 330 |
+
let s := lines ∘ f
|
| 331 |
+
let S := simpleSet weight s t
|
| 332 |
+
let E := S.image (vertex weight s t)
|
| 333 |
+
(∑ U ∈ S.powerset, (∏ c ∈ S \ U, extraWeight weight s t R J K L base c) *
|
| 334 |
+
badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => L * weight i.1.2))
|
| 335 |
+
(blockTrunc (componentLabel weight s t) R J none) (isBad weight s t R) U) ≤
|
| 336 |
+
badExpansion
|
| 337 |
+
(fun u f => independentWeight weight (fun d => L * weight d) lines R J base (f u) +
|
| 338 |
+
alpha weight (lines ∘ f) t u ^ K)
|
| 339 |
+
(fun A f => vertexBadMass weight (fun d => L * weight d) (lines ∘ f) t R J A) E f := by
|
| 340 |
+
dsimp only
|
| 341 |
+
unfold badExpansion
|
| 342 |
+
rw [Finset.powerset_image, Finset.sum_image
|
| 343 |
+
(Finset.image_injective (vertex_injective weight (lines ∘ f) t)).injOn]
|
| 344 |
+
apply Finset.sum_le_sum
|
| 345 |
+
intro U hU
|
| 346 |
+
rw [← Finset.image_sdiff _ _ (vertex_injective weight (lines ∘ f) t),
|
| 347 |
+
Finset.prod_image (vertex_injective weight (lines ∘ f) t).injOn,
|
| 348 |
+
component_bad_mass_eq_vertex weight (fun d => L * weight d) (lines ∘ f) t R J U]
|
| 349 |
+
apply mul_le_mul_of_nonneg_right _ (vertexBadMass_nonneg _ _ _ _ _ _ _)
|
| 350 |
+
apply Finset.prod_le_prod₀
|
| 351 |
+
· exact fun c _ => extraWeight_nonneg _ _ _ _ _ _ _ _ c
|
| 352 |
+
· exact fun c _ => extraWeight_le_independent weight lines f t R J K L base c
|
| 353 |
+
|
| 354 |
+
end SharpRamseyFive.SingletonEnumeration
|
| 355 |
+
|
| 356 |
+
namespace SharpRamseyFive.ResidualElimination
|
| 357 |
+
open scoped BigOperators
|
| 358 |
+
open Classical
|
| 359 |
+
variable {V H C : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H]
|
| 360 |
+
[DecidableEq C]
|
| 361 |
+
|
| 362 |
+
theorem disjoint_blocks_exposure (E : Finset V) (I : Finset C) (T : C → Finset V)
|
| 363 |
+
(Win : (c : C) → (T c → H) → ℝ) (M : C → ℝ)
|
| 364 |
+
(hw : ∀ c x, 0 ≤ Win c x) (hM : ∀ c, 0 ≤ M c)
|
| 365 |
+
(hwithin : ∀ c ∈ I, T c ⊆ E)
|
| 366 |
+
(hdisj : ∀ c ∈ I, ∀ d ∈ I, c ≠ d → Disjoint (T c) (T d))
|
| 367 |
+
(hsum : ∀ c ∈ I, (∑ x : T c → H, Win c x) ≤ M c)
|
| 368 |
+
(F : (V → H) → ℝ) (K : ℝ) (hK : 0 ≤ K)
|
| 369 |
+
(hres : ∀ g, completionSum (E \ I.biUnion T) g F ≤ K) (g : V → H) :
|
| 370 |
+
completionSum E g (fun f => (∏ c ∈ I, Win c (fun v => f v)) * F f) ≤
|
| 371 |
+
(∏ c ∈ I, M c) * K := by
|
| 372 |
+
induction I using Finset.induction generalizing E g with
|
| 373 |
+
| empty => simpa using hres g
|
| 374 |
+
| @insert c I hc ih =>
|
| 375 |
+
have hwi : T c ⊆ E := hwithin c (Finset.mem_insert_self c I)
|
| 376 |
+
have hrwithin : ∀ d ∈ I, T d ⊆ E \ T c := by
|
| 377 |
+
intro d hd v hv
|
| 378 |
+
refine Finset.mem_sdiff.mpr ⟨hwithin d (Finset.mem_insert_of_mem hd) hv, ?_⟩
|
| 379 |
+
intro hvc
|
| 380 |
+
exact Finset.disjoint_left.mp
|
| 381 |
+
(hdisj d (Finset.mem_insert_of_mem hd) c (Finset.mem_insert_self _ _)
|
| 382 |
+
(by intro he; subst d; exact hc hd)) hv hvc
|
| 383 |
+
have he : (E \ T c) \ I.biUnion T = E \ (insert c I).biUnion T := by
|
| 384 |
+
ext v
|
| 385 |
+
simp only [Finset.mem_sdiff, Finset.biUnion_insert, Finset.mem_union]
|
| 386 |
+
tauto
|
| 387 |
+
have hr (g : V → H) :
|
| 388 |
+
completionSum (E \ T c) g
|
| 389 |
+
(fun f => (∏ d ∈ I, Win d (fun v => f v)) * F f) ≤ (∏ d ∈ I, M d) * K := by
|
| 390 |
+
apply ih (E \ T c) hrwithin
|
| 391 |
+
(fun d hd e he hne => hdisj d (Finset.mem_insert_of_mem hd)
|
| 392 |
+
e (Finset.mem_insert_of_mem he) hne)
|
| 393 |
+
(fun d hd => hsum d (Finset.mem_insert_of_mem hd))
|
| 394 |
+
intro g
|
| 395 |
+
rw [he]
|
| 396 |
+
exact hres g
|
| 397 |
+
simp_rw [Finset.prod_insert hc, mul_assoc]
|
| 398 |
+
apply (weighted_block_exposure E (T c) hwi g (Win c) (hw c)
|
| 399 |
+
(fun f => (∏ d ∈ I, Win d (fun v => f v)) * F f)
|
| 400 |
+
((∏ d ∈ I, M d) * K) hr).trans
|
| 401 |
+
exact mul_le_mul_of_nonneg_right (hsum c (Finset.mem_insert_self _ _))
|
| 402 |
+
(mul_nonneg (Finset.prod_nonneg (fun d _ => hM d)) hK)
|
| 403 |
+
|
| 404 |
+
end SharpRamseyFive.ResidualElimination
|
| 405 |
+
|
| 406 |
+
namespace SharpRamseyFive.ComponentPartition
|
| 407 |
+
open scoped BigOperators
|
| 408 |
+
open Classical
|
| 409 |
+
variable {V C : Type} [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C]
|
| 410 |
+
|
| 411 |
+
noncomputable def fiber (r : V → C) (c : C) : Finset V :=
|
| 412 |
+
Finset.univ.filter (fun v => r v = c)
|
| 413 |
+
noncomputable def singles (r : V → C) : Finset V :=
|
| 414 |
+
Finset.univ.filter (fun v => (fiber r (r v)).card = 1)
|
| 415 |
+
noncomputable def largeLabels (r : V → C) : Finset C :=
|
| 416 |
+
Finset.univ.filter (fun c => 2 ≤ (fiber r c).card)
|
| 417 |
+
|
| 418 |
+
omit [DecidableEq V] [Fintype C] in
|
| 419 |
+
@[simp] lemma mem_fiber (r : V → C) (c : C) (v : V) : v ∈ fiber r c ↔ r v = c := by
|
| 420 |
+
simp [fiber]
|
| 421 |
+
omit [DecidableEq V] [Fintype C] in
|
| 422 |
+
@[simp] lemma mem_singles (r : V → C) (v : V) :
|
| 423 |
+
v ∈ singles r ↔ (fiber r (r v)).card = 1 := by simp [singles]
|
| 424 |
+
omit [DecidableEq V] in
|
| 425 |
+
@[simp] lemma mem_largeLabels (r : V → C) (c : C) :
|
| 426 |
+
c ∈ largeLabels r ↔ 2 ≤ (fiber r c).card := by simp [largeLabels]
|
| 427 |
+
omit [DecidableEq V] [Fintype C] in
|
| 428 |
+
|
| 429 |
+
lemma self_mem_fiber (r : V → C) (v : V) : v ∈ fiber r (r v) := by simp
|
| 430 |
+
omit [DecidableEq V] [Fintype C] in
|
| 431 |
+
lemma fiber_card_pos (r : V → C) (v : V) : 0 < (fiber r (r v)).card :=
|
| 432 |
+
Finset.card_pos.mpr ⟨v,self_mem_fiber r v⟩
|
| 433 |
+
omit [DecidableEq V] [Fintype C] in
|
| 434 |
+
|
| 435 |
+
lemma fiber_disjoint (r : V → C) {c d : C} (hne : c ≠ d) :
|
| 436 |
+
Disjoint (fiber r c) (fiber r d) := by
|
| 437 |
+
apply Finset.disjoint_left.mpr
|
| 438 |
+
intro v hc hd
|
| 439 |
+
exact hne ((mem_fiber r c v).mp hc |>.symm.trans ((mem_fiber r d v).mp hd))
|
| 440 |
+
|
| 441 |
+
lemma large_union (r : V → C) : (largeLabels r).biUnion (fiber r) = Finset.univ \ singles r := by
|
| 442 |
+
ext v
|
| 443 |
+
simp only [Finset.mem_biUnion, mem_largeLabels, mem_fiber, Finset.mem_sdiff,
|
| 444 |
+
Finset.mem_univ, true_and, mem_singles]
|
| 445 |
+
constructor
|
| 446 |
+
· rintro ⟨c,hc,he⟩
|
| 447 |
+
rw [he]
|
| 448 |
+
omega
|
| 449 |
+
· intro hv
|
| 450 |
+
exact ⟨r v,by have := fiber_card_pos r v; omega,rfl⟩
|
| 451 |
+
end SharpRamseyFive.ComponentPartition
|
| 452 |
+
end
|
| 453 |
+
|
| 454 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/PoissonLaw.lean
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! High moments, finite-field subspaces, and incidence bounds. -/
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
open MeasureTheory ProbabilityTheory
|
| 9 |
+
open scoped BigOperators NNReal
|
| 10 |
+
open MeasureTheory ProbabilityTheory
|
| 11 |
+
open scoped BigOperators NNReal
|
| 12 |
+
namespace SharpRamseyFive.StaticCertificates
|
| 13 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 14 |
+
noncomputable def poissonLaw (rate : ι → ℝ≥0) : Measure (ι → ℕ) :=
|
| 15 |
+
Measure.pi (fun i => poissonMeasure (rate i))
|
| 16 |
+
|
| 17 |
+
instance flat_HighMomentRecovered_3 (rate : ι → ℝ≥0) : IsProbabilityMeasure (poissonLaw rate) := by
|
| 18 |
+
unfold poissonLaw
|
| 19 |
+
infer_instance
|
| 20 |
+
|
| 21 |
+
def positiveEvent (C : Finset ι) : Set (ι → ℕ) :=
|
| 22 |
+
(C : Set ι).pi (fun _ => ({0} : Set ℕ)ᶜ)
|
| 23 |
+
|
| 24 |
+
noncomputable def certificateIndicator (C : Finset ι) (ω : ι → ℕ) : ℝ :=
|
| 25 |
+
(positiveEvent C).indicator (fun _ => 1) ω
|
| 26 |
+
|
| 27 |
+
noncomputable def weight (rate : ι → ℝ≥0) (C : Finset ι) : ℝ :=
|
| 28 |
+
∏ i ∈ C, (rate i : ℝ)
|
| 29 |
+
|
| 30 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 31 |
+
lemma measurableSet_positiveEvent (C : Finset ι) : MeasurableSet (positiveEvent C) :=
|
| 32 |
+
MeasurableSet.pi C.finite_toSet.countable (fun _ _ => (measurableSet_singleton 0).compl)
|
| 33 |
+
omit [DecidableEq ι] in
|
| 34 |
+
|
| 35 |
+
lemma integrable_certificateIndicator (rate : ι → ℝ≥0) (C : Finset ι) :
|
| 36 |
+
Integrable (certificateIndicator C) (poissonLaw rate) :=
|
| 37 |
+
(integrable_const (1 : ℝ)).indicator (measurableSet_positiveEvent C)
|
| 38 |
+
|
| 39 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 40 |
+
lemma indicator_nonneg (C : Finset ι) (ω : ι → ℕ) :
|
| 41 |
+
0 ≤ certificateIndicator C ω := by
|
| 42 |
+
exact Set.indicator_nonneg (fun _ _ => zero_le_one) _
|
| 43 |
+
omit [DecidableEq ι] in
|
| 44 |
+
|
| 45 |
+
lemma integral_certificateIndicator (rate : ι → ℝ≥0) (C : Finset ι) :
|
| 46 |
+
(∫ ω, certificateIndicator C ω ∂poissonLaw rate) =
|
| 47 |
+
∏ i ∈ C, (1 - Real.exp (-(rate i : ℝ))) := by
|
| 48 |
+
unfold certificateIndicator
|
| 49 |
+
rw [integral_indicator_const _ (measurableSet_positiveEvent C)]
|
| 50 |
+
simp only [smul_eq_mul, mul_one]
|
| 51 |
+
rw [Measure.real, poissonLaw, positiveEvent, Measure.pi_pi_finset,
|
| 52 |
+
ENNReal.toReal_prod]
|
| 53 |
+
apply Finset.prod_congr rfl
|
| 54 |
+
intro i _
|
| 55 |
+
rw [← Measure.real, measureReal_compl (measurableSet_singleton 0),
|
| 56 |
+
probReal_univ, Measure.real, poissonMeasure_singleton]
|
| 57 |
+
simp only [pow_zero, Nat.factorial_zero, Nat.cast_one, mul_one, div_one]
|
| 58 |
+
rw [ENNReal.toReal_ofReal (Real.exp_pos _).le]
|
| 59 |
+
omit [DecidableEq ι] in
|
| 60 |
+
|
| 61 |
+
lemma integral_certificateIndicator_le (rate : ι → ℝ≥0) (C : Finset ι) :
|
| 62 |
+
(∫ ω, certificateIndicator C ω ∂poissonLaw rate) ≤ weight rate C := by
|
| 63 |
+
rw [integral_certificateIndicator]
|
| 64 |
+
apply Finset.prod_le_prod₀
|
| 65 |
+
· intro i _
|
| 66 |
+
have he := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (rate i).coe_nonneg)
|
| 67 |
+
linarith
|
| 68 |
+
· intro i _
|
| 69 |
+
have he := Real.add_one_le_exp (-(rate i : ℝ))
|
| 70 |
+
linarith
|
| 71 |
+
|
| 72 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 73 |
+
lemma weight_nonneg (rate : ι → ℝ≥0) (C : Finset ι) : 0 ≤ weight rate C := by
|
| 74 |
+
exact Finset.prod_nonneg (fun i _ => (rate i).coe_nonneg)
|
| 75 |
+
|
| 76 |
+
omit [Fintype ι] in
|
| 77 |
+
|
| 78 |
+
lemma weight_union (rate : ι → ℝ≥0) (C D : Finset ι) :
|
| 79 |
+
weight rate (C ∪ D) = weight rate C * weight rate (D \ C) := by
|
| 80 |
+
unfold weight
|
| 81 |
+
rw [← Finset.prod_union (Finset.disjoint_sdiff)]
|
| 82 |
+
congr 1
|
| 83 |
+
ext i
|
| 84 |
+
simp only [Finset.mem_union, Finset.mem_sdiff]
|
| 85 |
+
tauto
|
| 86 |
+
|
| 87 |
+
omit [Fintype ι] in
|
| 88 |
+
lemma positiveEvent_union (C D : Finset ι) :
|
| 89 |
+
positiveEvent (C ∪ D) = positiveEvent C ∩ positiveEvent D := by
|
| 90 |
+
ext ω
|
| 91 |
+
simp [positiveEvent, Set.mem_pi, or_imp, forall_and]
|
| 92 |
+
|
| 93 |
+
omit [DecidableEq ι] in
|
| 94 |
+
|
| 95 |
+
theorem static_union_bound {κ : Type*} (D : Finset κ) (requirements : κ → Finset ι)
|
| 96 |
+
(rate : ι → ℝ≥0) (E : Set (ι → ℕ)) (hE : MeasurableSet E)
|
| 97 |
+
(hcover : ∀ ω ∈ E, ∃ c ∈ D, ω ∈ positiveEvent (requirements c)) :
|
| 98 |
+
(poissonLaw rate).real E ≤ ∑ c ∈ D, weight rate (requirements c) := by
|
| 99 |
+
have hp (ω : ι → ℕ) : E.indicator (fun _ => (1 : ℝ)) ω ≤
|
| 100 |
+
∑ c ∈ D, certificateIndicator (requirements c) ω := by
|
| 101 |
+
by_cases hω : ω ∈ E
|
| 102 |
+
· obtain ⟨c, hc, he⟩ := hcover ω hω
|
| 103 |
+
have := Finset.single_le_sum (f := fun c => certificateIndicator (requirements c) ω)
|
| 104 |
+
(fun c _ => indicator_nonneg _ _) hc
|
| 105 |
+
simpa [certificateIndicator, he, hω] using this
|
| 106 |
+
· simp only [Set.indicator_of_notMem hω]
|
| 107 |
+
exact Finset.sum_nonneg (fun c _ => indicator_nonneg _ _)
|
| 108 |
+
calc
|
| 109 |
+
_ = ∫ ω, E.indicator (fun _ => (1 : ℝ)) ω ∂poissonLaw rate := by
|
| 110 |
+
rw [integral_indicator_const _ hE]
|
| 111 |
+
simp
|
| 112 |
+
_ ≤ ∫ ω, ∑ c ∈ D, certificateIndicator (requirements c) ω ∂poissonLaw rate :=
|
| 113 |
+
integral_mono ((integrable_const (1 : ℝ)).indicator hE)
|
| 114 |
+
(integrable_finsetSum _ (fun c _ => integrable_certificateIndicator _ _)) hp
|
| 115 |
+
_ = ∑ c ∈ D, ∫ ω, certificateIndicator (requirements c) ω ∂poissonLaw rate :=
|
| 116 |
+
integral_finsetSum _ (fun c _ => integrable_certificateIndicator _ _)
|
| 117 |
+
_ ≤ _ := Finset.sum_le_sum (fun c _ => integral_certificateIndicator_le _ _)
|
| 118 |
+
|
| 119 |
+
section PairWitnesses
|
| 120 |
+
|
| 121 |
+
variable {κ : Type*} [Fintype κ] [DecidableEq κ]
|
| 122 |
+
|
| 123 |
+
def witnessRequirements (T : Finset κ) (S : Finset ι) (f : T → S) : Finset (κ × ι) :=
|
| 124 |
+
T.attach.image (fun r => (r.val, (f r).val))
|
| 125 |
+
|
| 126 |
+
omit [Fintype ι] [Fintype κ] in
|
| 127 |
+
lemma witnessRequirements_card (T : Finset κ) (S : Finset ι) (f : T → S) :
|
| 128 |
+
(witnessRequirements T S f).card = T.card := by
|
| 129 |
+
rw [witnessRequirements, Finset.card_image_of_injective]
|
| 130 |
+
· exact Finset.card_attach
|
| 131 |
+
· intro a b h
|
| 132 |
+
exact Subtype.ext (congrArg Prod.fst h)
|
| 133 |
+
|
| 134 |
+
omit [Fintype ι] [Fintype κ] in
|
| 135 |
+
lemma witness_weight (rate : ι → ℝ≥0) (T : Finset κ) (S : Finset ι) (f : T → S) :
|
| 136 |
+
weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f) =
|
| 137 |
+
∏ r : T, (rate (f r) : ℝ) := by
|
| 138 |
+
unfold weight witnessRequirements
|
| 139 |
+
rw [Finset.prod_image]
|
| 140 |
+
· rw [Finset.univ_eq_attach T]
|
| 141 |
+
· intro a _ b _ h
|
| 142 |
+
exact Subtype.ext (congrArg Prod.fst h)
|
| 143 |
+
omit [Fintype ι] [Fintype κ] in
|
| 144 |
+
|
| 145 |
+
lemma sum_witness_weight (rate : ι → ℝ≥0) (T : Finset κ) (S : Finset ι) :
|
| 146 |
+
(∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) =
|
| 147 |
+
(∑ i ∈ S, (rate i : ℝ)) ^ T.card := by
|
| 148 |
+
simp_rw [witness_weight]
|
| 149 |
+
rw [← Fintype.prod_sum (fun (_r : T) (i : S) => (rate i : ℝ))]
|
| 150 |
+
rw [Finset.sum_coe_sort S (fun i => (rate i : ℝ))]
|
| 151 |
+
simp
|
| 152 |
+
|
| 153 |
+
omit [Fintype ι] in
|
| 154 |
+
|
| 155 |
+
theorem pair_certificate_weight (rate : ι → ℝ≥0) (S : Finset ι) (K : ℕ) :
|
| 156 |
+
(∑ T ∈ (Finset.univ : Finset κ).powersetCard K,
|
| 157 |
+
∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) =
|
| 158 |
+
(Fintype.card κ).choose K * (∑ i ∈ S, (rate i : ℝ)) ^ K := by
|
| 159 |
+
simp_rw [sum_witness_weight]
|
| 160 |
+
calc
|
| 161 |
+
_ = ∑ _T ∈ (Finset.univ : Finset κ).powersetCard K,
|
| 162 |
+
(∑ i ∈ S, (rate i : ℝ)) ^ K := by
|
| 163 |
+
apply Finset.sum_congr rfl
|
| 164 |
+
intro T hT
|
| 165 |
+
rw [(Finset.mem_powersetCard.mp hT).2]
|
| 166 |
+
_ = _ := by simp
|
| 167 |
+
|
| 168 |
+
omit [Fintype ι] in
|
| 169 |
+
|
| 170 |
+
theorem pair_certificate_weight_le (rate : ι → ℝ≥0) (S : Finset ι) (K : ℕ) :
|
| 171 |
+
(∑ T ∈ (Finset.univ : Finset κ).powersetCard K,
|
| 172 |
+
∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) ≤
|
| 173 |
+
((Fintype.card κ : ℝ) * ∑ i ∈ S, (rate i : ℝ)) ^ K := by
|
| 174 |
+
rw [pair_certificate_weight, mul_pow]
|
| 175 |
+
apply mul_le_mul_of_nonneg_right
|
| 176 |
+
· exact_mod_cast Nat.choose_le_pow (Fintype.card κ) K
|
| 177 |
+
· positivity
|
| 178 |
+
|
| 179 |
+
omit [Fintype ι] [Fintype κ] in
|
| 180 |
+
|
| 181 |
+
theorem pair_witness_exists (S : Finset ι) (T : Finset κ) (ω : κ × ι → ℕ)
|
| 182 |
+
(hT : ∀ r ∈ T, ∃ i ∈ S, ω (r, i) ≠ 0) :
|
| 183 |
+
∃ f : T → S, ω ∈ positiveEvent (witnessRequirements T S f) := by
|
| 184 |
+
classical
|
| 185 |
+
have h (r : T) : ∃ i : S, ω (r.val, i.val) ≠ 0 := by
|
| 186 |
+
obtain ⟨i, hi, he⟩ := hT r r.property
|
| 187 |
+
exact ⟨⟨i, hi⟩, he⟩
|
| 188 |
+
choose f hf using h
|
| 189 |
+
refine ⟨f, ?_⟩
|
| 190 |
+
intro p hp
|
| 191 |
+
obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp
|
| 192 |
+
exact hf r
|
| 193 |
+
|
| 194 |
+
def dictionary (C : Finset (κ × ι)) : Finset ι := C.image Prod.snd
|
| 195 |
+
|
| 196 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 197 |
+
lemma direction_mem_dictionary {C : Finset (κ × ι)} {r : κ} {i : ι}
|
| 198 |
+
(h : (r, i) ∈ C) : i ∈ dictionary C := Finset.mem_image_of_mem _ h
|
| 199 |
+
omit [Fintype ι] [Fintype κ] in
|
| 200 |
+
|
| 201 |
+
lemma witnessRequirements_disjoint {C : Finset (κ × ι)} (T : Finset κ) (S : Finset ι)
|
| 202 |
+
(f : T → S) (hnew : Disjoint S (dictionary C)) :
|
| 203 |
+
Disjoint C (witnessRequirements T S f) := by
|
| 204 |
+
apply Finset.disjoint_left.mpr
|
| 205 |
+
intro p hp hp'
|
| 206 |
+
obtain ⟨r, _, hr⟩ := Finset.mem_image.mp hp'
|
| 207 |
+
have he := congrArg Prod.snd hr
|
| 208 |
+
have hf : p.2 ∈ S := he ▸ (f r).property
|
| 209 |
+
exact Finset.disjoint_left.mp hnew hf (direction_mem_dictionary hp)
|
| 210 |
+
|
| 211 |
+
omit [Fintype ι] [Fintype κ] in
|
| 212 |
+
lemma weight_union_fresh (rate : κ × ι → ℝ≥0) (C D : Finset (κ × ι))
|
| 213 |
+
(hfresh : Disjoint C D) : weight rate (C ∪ D) = weight rate C * weight rate D := by
|
| 214 |
+
exact Finset.prod_union hfresh
|
| 215 |
+
|
| 216 |
+
omit [Fintype ι] [Fintype κ] in
|
| 217 |
+
|
| 218 |
+
theorem pair_dictionary_extension (rate : ι → ℝ≥0) (C : Finset (κ × ι))
|
| 219 |
+
(T : Finset κ) (S : Finset ι) (f : T → S) (hnew : Disjoint S (dictionary C)) :
|
| 220 |
+
weight (fun p : κ × ι => rate p.2) (C ∪ witnessRequirements T S f) =
|
| 221 |
+
weight (fun p : κ × ι => rate p.2) C * ∏ r : T, (rate (f r) : ℝ) := by
|
| 222 |
+
rw [weight_union_fresh _ _ _ (witnessRequirements_disjoint T S f hnew), witness_weight]
|
| 223 |
+
|
| 224 |
+
def anchorRequirements (C : Finset (κ × ι)) (r : κ) (i : ι) : Finset (κ × ι) :=
|
| 225 |
+
if i ∈ dictionary C then ∅ else {(r, i)}
|
| 226 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 227 |
+
|
| 228 |
+
lemma anchorRequirements_disjoint (C : Finset (κ × ι)) (r : κ) (i : ι) :
|
| 229 |
+
Disjoint C (anchorRequirements C r i) := by
|
| 230 |
+
unfold anchorRequirements
|
| 231 |
+
split_ifs with h
|
| 232 |
+
· exact Finset.disjoint_empty_right _
|
| 233 |
+
· simp only [Finset.disjoint_singleton_right]
|
| 234 |
+
exact fun hi => h (direction_mem_dictionary hi)
|
| 235 |
+
|
| 236 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 237 |
+
lemma anchorRequirements_weight (rate : ι → ℝ≥0) (C : Finset (κ × ι))
|
| 238 |
+
(r : κ) (i : ι) :
|
| 239 |
+
weight (fun p : κ × ι => rate p.2) (anchorRequirements C r i) =
|
| 240 |
+
if i ∈ dictionary C then 1 else (rate i : ℝ) := by
|
| 241 |
+
unfold anchorRequirements weight
|
| 242 |
+
split_ifs <;> simp
|
| 243 |
+
omit [Fintype ι] [Fintype κ] in
|
| 244 |
+
|
| 245 |
+
lemma anchor_dictionary_extension (rate : ι → ℝ≥0) (C : Finset (κ × ι))
|
| 246 |
+
(r : κ) (i : ι) :
|
| 247 |
+
weight (fun p : κ × ι => rate p.2) (C ∪ anchorRequirements C r i) =
|
| 248 |
+
weight (fun p : κ × ι => rate p.2) C *
|
| 249 |
+
(if i ∈ dictionary C then 1 else (rate i : ℝ)) := by
|
| 250 |
+
rw [weight_union_fresh _ _ _ (anchorRequirements_disjoint C r i), anchorRequirements_weight]
|
| 251 |
+
omit [Fintype ι] [Fintype κ] in
|
| 252 |
+
|
| 253 |
+
lemma anchor_dictionary_subset (C : Finset (κ × ι)) (r : κ) (i : ι) :
|
| 254 |
+
dictionary (C ∪ anchorRequirements C r i) ⊆ insert i (dictionary C) := by
|
| 255 |
+
intro d hd
|
| 256 |
+
obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hd
|
| 257 |
+
rcases Finset.mem_union.mp hp with hp | hp
|
| 258 |
+
· exact Finset.mem_insert_of_mem (direction_mem_dictionary hp)
|
| 259 |
+
· unfold anchorRequirements at hp
|
| 260 |
+
split_ifs at hp with h
|
| 261 |
+
· simp at hp
|
| 262 |
+
· have he := Finset.mem_singleton.mp hp
|
| 263 |
+
rw [he]
|
| 264 |
+
exact Finset.mem_insert_self _ _
|
| 265 |
+
|
| 266 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 267 |
+
|
| 268 |
+
lemma old_reference_has_hit (C : Finset (κ × ι)) (i : ι) (hi : i ∈ dictionary C)
|
| 269 |
+
(ω : (κ × ι) → ℕ) (hω : ω ∈ positiveEvent C) : ∃ r, ω (r, i) ≠ 0 := by
|
| 270 |
+
obtain ⟨p, hp, hpi⟩ := Finset.mem_image.mp hi
|
| 271 |
+
refine ⟨p.1, ?_⟩
|
| 272 |
+
have hh := hω p hp
|
| 273 |
+
simpa [← hpi] using hh
|
| 274 |
+
|
| 275 |
+
omit [Fintype ι] [DecidableEq κ] in
|
| 276 |
+
|
| 277 |
+
theorem anchor_choice_weight_le (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) :
|
| 278 |
+
(∑ _i ∈ S ∩ dictionary C, (1 : ℝ)) +
|
| 279 |
+
(∑ _r : κ, ∑ i ∈ S \ dictionary C, (rate i : ℝ)) ≤
|
| 280 |
+
(dictionary C).card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ) := by
|
| 281 |
+
apply add_le_add
|
| 282 |
+
· simp only [Finset.sum_const, nsmul_eq_mul, mul_one]
|
| 283 |
+
exact_mod_cast Finset.card_le_card (Finset.inter_subset_right (s₁ := S))
|
| 284 |
+
· simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
|
| 285 |
+
apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _)
|
| 286 |
+
exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.sdiff_subset)
|
| 287 |
+
(by intro i _ _; exact (rate i).coe_nonneg)
|
| 288 |
+
|
| 289 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 290 |
+
lemma dictionary_card_le (C : Finset (κ × ι)) : (dictionary C).card ≤ C.card :=
|
| 291 |
+
Finset.card_image_le
|
| 292 |
+
|
| 293 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 294 |
+
lemma anchorRequirements_card_le (C : Finset (κ × ι)) (r : κ) (i : ι) :
|
| 295 |
+
(anchorRequirements C r i).card ≤ 1 := by
|
| 296 |
+
unfold anchorRequirements
|
| 297 |
+
split_ifs <;> simp
|
| 298 |
+
omit [Fintype ι] [Fintype κ] in
|
| 299 |
+
|
| 300 |
+
lemma anchor_extension_card (C : Finset (κ × ι)) (r : κ) (i : ι) :
|
| 301 |
+
(C ∪ anchorRequirements C r i).card ≤ C.card + 1 :=
|
| 302 |
+
(Finset.card_union_le _ _).trans (Nat.add_le_add_left (anchorRequirements_card_le C r i) _)
|
| 303 |
+
omit [Fintype ι] [Fintype κ] in
|
| 304 |
+
|
| 305 |
+
lemma pair_extension_card (C : Finset (κ × ι)) (T : Finset κ) (S : Finset ι) (f : T → S) :
|
| 306 |
+
(C ∪ witnessRequirements T S f).card ≤ C.card + T.card := by
|
| 307 |
+
simpa only [witnessRequirements_card] using Finset.card_union_le C (witnessRequirements T S f)
|
| 308 |
+
|
| 309 |
+
abbrev AnchorChoice (C : Finset (κ × ι)) (S : Finset ι) :=
|
| 310 |
+
{i // i ∈ S ∩ dictionary C} ⊕ (κ × {i // i ∈ S \ dictionary C})
|
| 311 |
+
|
| 312 |
+
def AnchorChoice.direction {C : Finset (κ × ι)} {S : Finset ι} : AnchorChoice C S → ι
|
| 313 |
+
| .inl d => d.val
|
| 314 |
+
| .inr rd => rd.2.val
|
| 315 |
+
|
| 316 |
+
def AnchorChoice.requirements {C : Finset (κ × ι)} {S : Finset ι} :
|
| 317 |
+
AnchorChoice C S → Finset (κ × ι)
|
| 318 |
+
| .inl _ => ∅
|
| 319 |
+
| .inr rd => {(rd.1, rd.2.val)}
|
| 320 |
+
|
| 321 |
+
noncomputable def AnchorChoice.cost (rate : ι → ℝ≥0)
|
| 322 |
+
{C : Finset (κ × ι)} {S : Finset ι} : AnchorChoice C S → ℝ
|
| 323 |
+
| .inl _ => 1
|
| 324 |
+
| .inr rd => rate rd.2.val
|
| 325 |
+
|
| 326 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 327 |
+
lemma AnchorChoice.cost_nonneg (rate : ι → ℝ≥0)
|
| 328 |
+
{C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) : 0 ≤ x.cost rate := by
|
| 329 |
+
cases x <;> simp [AnchorChoice.cost]
|
| 330 |
+
|
| 331 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 332 |
+
lemma AnchorChoice.direction_mem {C : Finset (κ × ι)} {S : Finset ι}
|
| 333 |
+
(x : AnchorChoice C S) : x.direction ∈ S := by
|
| 334 |
+
cases x with
|
| 335 |
+
| inl d => exact (Finset.mem_inter.mp d.property).1
|
| 336 |
+
| inr rd => exact (Finset.mem_sdiff.mp rd.2.property).1
|
| 337 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 338 |
+
|
| 339 |
+
lemma AnchorChoice.fresh {C : Finset (κ × ι)} {S : Finset ι}
|
| 340 |
+
(x : AnchorChoice C S) : Disjoint C x.requirements := by
|
| 341 |
+
cases x with
|
| 342 |
+
| inl d => exact Finset.disjoint_empty_right _
|
| 343 |
+
| inr rd =>
|
| 344 |
+
apply Finset.disjoint_singleton_right.mpr
|
| 345 |
+
intro he
|
| 346 |
+
exact (Finset.mem_sdiff.mp rd.2.property).2 (direction_mem_dictionary he)
|
| 347 |
+
|
| 348 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 349 |
+
lemma AnchorChoice.weight (rate : ι → ℝ≥0)
|
| 350 |
+
{C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) :
|
| 351 |
+
weight (fun p : κ × ι => rate p.2) x.requirements = x.cost rate := by
|
| 352 |
+
cases x <;> simp [AnchorChoice.requirements, StaticCertificates.weight, AnchorChoice.cost]
|
| 353 |
+
|
| 354 |
+
omit [Fintype ι] [Fintype κ] [DecidableEq κ] in
|
| 355 |
+
lemma AnchorChoice.distinct_events {C : Finset (κ × ι)} {S : Finset ι}
|
| 356 |
+
(x y : AnchorChoice C S) (hne : x.direction ≠ y.direction) :
|
| 357 |
+
Disjoint x.requirements y.requirements := by
|
| 358 |
+
cases x with
|
| 359 |
+
| inl d => exact Finset.disjoint_empty_left _
|
| 360 |
+
| inr rd =>
|
| 361 |
+
cases y with
|
| 362 |
+
| inl d => exact Finset.disjoint_empty_right _
|
| 363 |
+
| inr re =>
|
| 364 |
+
apply Finset.disjoint_singleton_left.mpr
|
| 365 |
+
simp only [AnchorChoice.requirements, Finset.mem_singleton]
|
| 366 |
+
intro he
|
| 367 |
+
exact hne (congrArg Prod.snd he)
|
| 368 |
+
|
| 369 |
+
omit [Fintype ι] [Fintype κ] in
|
| 370 |
+
|
| 371 |
+
lemma two_anchor_extension_weight (rate : ι → ℝ≥0)
|
| 372 |
+
{C : Finset (κ × ι)} {S : Finset ι} (x y : AnchorChoice C S)
|
| 373 |
+
(hne : x.direction ≠ y.direction) :
|
| 374 |
+
weight (fun p : κ × ι => rate p.2) (C ∪ (x.requirements ∪ y.requirements)) =
|
| 375 |
+
weight (fun p : κ × ι => rate p.2) C * (x.cost rate * y.cost rate) := by
|
| 376 |
+
rw [weight_union_fresh _ _ _ (Finset.disjoint_union_right.mpr ⟨x.fresh, y.fresh⟩),
|
| 377 |
+
weight_union_fresh _ _ _ (x.distinct_events y hne), x.weight rate, y.weight rate]
|
| 378 |
+
|
| 379 |
+
omit [Fintype ι] [DecidableEq κ] in
|
| 380 |
+
lemma sum_anchor_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) :
|
| 381 |
+
(∑ x : AnchorChoice C S, x.cost rate) =
|
| 382 |
+
(S ∩ dictionary C).card + Fintype.card κ * ∑ i ∈ S \ dictionary C, (rate i : ℝ) := by
|
| 383 |
+
rw [Fintype.sum_sum_type]
|
| 384 |
+
simp only [AnchorChoice.cost, Finset.sum_const, Finset.card_univ,
|
| 385 |
+
Fintype.card_coe, nsmul_eq_mul, mul_one, Fintype.sum_prod_type]
|
| 386 |
+
rw [Finset.sum_coe_sort (S \ dictionary C) (fun i => (rate i : ℝ))]
|
| 387 |
+
|
| 388 |
+
omit [Fintype ι] [DecidableEq κ] in
|
| 389 |
+
|
| 390 |
+
theorem sum_anchor_cost_le (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) :
|
| 391 |
+
(∑ x : AnchorChoice C S, x.cost rate) ≤
|
| 392 |
+
C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ) := by
|
| 393 |
+
rw [sum_anchor_cost]
|
| 394 |
+
apply add_le_add
|
| 395 |
+
· exact_mod_cast (Finset.card_le_card (Finset.inter_subset_right (s₁ := S))).trans
|
| 396 |
+
(dictionary_card_le C)
|
| 397 |
+
· apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _)
|
| 398 |
+
exact Finset.sum_le_sum_of_subset_of_nonneg Finset.sdiff_subset
|
| 399 |
+
(by intro i _ _; exact (rate i).coe_nonneg)
|
| 400 |
+
|
| 401 |
+
section AnchorGeometry
|
| 402 |
+
variable {H : Type*} [Fintype H] [DecidableEq H]
|
| 403 |
+
|
| 404 |
+
omit [DecidableEq H] in
|
| 405 |
+
omit [Fintype ι] [DecidableEq κ] in
|
| 406 |
+
|
| 407 |
+
theorem one_anchor_geometric_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι))
|
| 408 |
+
(S : Finset ι) (lineSet : H → Finset ι) (N₁ : ℕ)
|
| 409 |
+
(hN : ∀ d, (Finset.univ.filter (fun H => d ∈ lineSet H)).card ≤ N₁) :
|
| 410 |
+
(∑ x : AnchorChoice C S, x.cost rate *
|
| 411 |
+
(Finset.univ.filter (fun H => x.direction ∈ lineSet H)).card) ≤
|
| 412 |
+
(N₁ : ℝ) * (C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ)) := by
|
| 413 |
+
calc
|
| 414 |
+
_ ≤ ∑ x : AnchorChoice C S, x.cost rate * N₁ := by
|
| 415 |
+
apply Finset.sum_le_sum
|
| 416 |
+
intro x _
|
| 417 |
+
apply mul_le_mul_of_nonneg_left _ (x.cost_nonneg rate)
|
| 418 |
+
exact_mod_cast hN x.direction
|
| 419 |
+
_ = (N₁ : ℝ) * ∑ x : AnchorChoice C S, x.cost rate := by
|
| 420 |
+
rw [← Finset.sum_mul, mul_comm]
|
| 421 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left (sum_anchor_cost_le rate C S) (Nat.cast_nonneg _)
|
| 422 |
+
|
| 423 |
+
omit [DecidableEq H] in
|
| 424 |
+
omit [Fintype ι] [DecidableEq κ] in
|
| 425 |
+
|
| 426 |
+
theorem two_anchor_geometric_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι))
|
| 427 |
+
(S : Finset ι) (lineSet : H → Finset ι) (N₂ : ℕ)
|
| 428 |
+
(hN : ∀ d e, d ≠ e →
|
| 429 |
+
(Finset.univ.filter (fun H => d ∈ lineSet H ∧ e ∈ lineSet H)).card ≤ N₂) :
|
| 430 |
+
(∑ x : AnchorChoice C S, ∑ y : AnchorChoice C S,
|
| 431 |
+
if x.direction ≠ y.direction then x.cost rate * y.cost rate *
|
| 432 |
+
(Finset.univ.filter (fun H => x.direction ∈ lineSet H ∧ y.direction ∈ lineSet H)).card
|
| 433 |
+
else 0) ≤
|
| 434 |
+
(N₂ : ℝ) * (C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ)) ^ 2 := by
|
| 435 |
+
classical
|
| 436 |
+
let A : ℝ := ∑ x : AnchorChoice C S, x.cost rate
|
| 437 |
+
have hA : 0 ≤ A := Finset.sum_nonneg (fun x _ => x.cost_nonneg rate)
|
| 438 |
+
calc
|
| 439 |
+
_ ≤ ∑ x : AnchorChoice C S, ∑ y : AnchorChoice C S,
|
| 440 |
+
x.cost rate * y.cost rate * N₂ := by
|
| 441 |
+
apply Finset.sum_le_sum
|
| 442 |
+
intro x _
|
| 443 |
+
apply Finset.sum_le_sum
|
| 444 |
+
intro y _
|
| 445 |
+
split_ifs with hxy
|
| 446 |
+
· apply mul_le_mul_of_nonneg_left _ (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate))
|
| 447 |
+
exact_mod_cast hN x.direction y.direction hxy
|
| 448 |
+
· exact mul_nonneg (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate)) (Nat.cast_nonneg _)
|
| 449 |
+
_ = (N₂ : ℝ) * A ^ 2 := by
|
| 450 |
+
simp only [Finset.sum_mul, Finset.mul_sum, A, pow_two]
|
| 451 |
+
apply Finset.sum_congr rfl
|
| 452 |
+
intro x _
|
| 453 |
+
apply Finset.sum_congr rfl
|
| 454 |
+
intro y _
|
| 455 |
+
ring
|
| 456 |
+
_ ≤ _ := by
|
| 457 |
+
apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _)
|
| 458 |
+
exact pow_le_pow_left₀ hA (sum_anchor_cost_le rate C S) 2
|
| 459 |
+
|
| 460 |
+
end AnchorGeometry
|
| 461 |
+
end PairWitnesses
|
| 462 |
+
end SharpRamseyFive.StaticCertificates
|
| 463 |
+
end
|
| 464 |
+
|
| 465 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/ProtocolEntropy.lean
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Marking.MarkingDeficit
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey.Selection
|
| 8 |
+
open Finset Real
|
| 9 |
+
open scoped Classical
|
| 10 |
+
noncomputable section
|
| 11 |
+
variable {Ω α Γ : Type*} [Fintype Ω] [Fintype α] [Fintype Γ]
|
| 12 |
+
|
| 13 |
+
theorem entropy_append_alphabet (p : Law Ω) (C : Ω→Γ) (F : Ω→α)
|
| 14 |
+
(D : Γ→Finset α) (hD : ∀ x,p.mass x≠0→F x∈D (C x)) :
|
| 15 |
+
entropy (p.map (fun x=>(F x,C x))) ≤ entropy (p.map C)+
|
| 16 |
+
∑ x,p.mass x*log (D (C x)).card := by
|
| 17 |
+
rw [entropy_cond_chain,←p.sum_map C (fun c=>log (D c).card)]
|
| 18 |
+
apply add_le_add le_rfl
|
| 19 |
+
apply sum_le_sum
|
| 20 |
+
intro c _
|
| 21 |
+
by_cases hc : (p.map C).mass c=0
|
| 22 |
+
· simp [hc]
|
| 23 |
+
· apply mul_le_mul_of_nonneg_left _ ((p.map C).nonneg c)
|
| 24 |
+
apply entropy_mapped_support
|
| 25 |
+
intro x hx
|
| 26 |
+
obtain ⟨hp,he⟩ := p.cond_support C c hc x hx
|
| 27 |
+
simpa only [←he] using hD x hp
|
| 28 |
+
|
| 29 |
+
def ProtocolValid (D : ∀ n:ℕ,(Fin n→α)→Finset α) :
|
| 30 |
+
∀ n:ℕ,(Fin n→α)→Prop
|
| 31 |
+
| 0,_ => True
|
| 32 |
+
| n+1,x => ProtocolValid D n (Fin.init x) ∧ x (Fin.last n)∈D n (Fin.init x)
|
| 33 |
+
|
| 34 |
+
noncomputable def protocolCost (D : ∀ n:ℕ,(Fin n→α)→Finset α) :
|
| 35 |
+
∀ n:ℕ,(Fin n→α)→ℝ
|
| 36 |
+
| 0,_ => 0
|
| 37 |
+
| n+1,x => protocolCost D n (Fin.init x)+log (D n (Fin.init x)).card
|
| 38 |
+
|
| 39 |
+
omit [Fintype Γ] in
|
| 40 |
+
|
| 41 |
+
theorem protocol_entropy (p : Law Ω) (D : ∀ n:ℕ,(Fin n→α)→Finset α)
|
| 42 |
+
(n : ℕ) (F : Ω→Fin n→α) (hF : ∀ x,p.mass x≠0→ProtocolValid D n (F x)) :
|
| 43 |
+
entropy (p.map F)≤∑ x,p.mass x*protocolCost D n (F x) := by
|
| 44 |
+
induction n with
|
| 45 |
+
| zero =>
|
| 46 |
+
have h := entropy_le_log_card (p.map F) univ (fun x hx=>False.elim (hx (mem_univ x)))
|
| 47 |
+
simpa only [card_univ,Fintype.card_fun,Fintype.card_fin,pow_zero,
|
| 48 |
+
Nat.cast_one,log_one,protocolCost,mul_zero,sum_const_zero] using h
|
| 49 |
+
| succ n ih =>
|
| 50 |
+
let C := fun x=>Fin.init (F x)
|
| 51 |
+
let a := fun x=>F x (Fin.last n)
|
| 52 |
+
have hi := ih C (fun x hx=>(hF x hx).1)
|
| 53 |
+
have ha := entropy_append_alphabet p C a (D n) (fun x hx=>(hF x hx).2)
|
| 54 |
+
have he : entropy (p.map (fun x=>(a x,C x)))=entropy (p.map F) := by
|
| 55 |
+
have h := entropy_map_eq_of_leftInverse (p.map F)
|
| 56 |
+
(fun y:Fin (n+1)→α=>(y (Fin.last n),Fin.init y))
|
| 57 |
+
(fun z:α×(Fin n→α)=>Fin.snoc z.2 z.1) (fun y=>Fin.snoc_init_self y)
|
| 58 |
+
rw [Law.map_map] at h
|
| 59 |
+
exact h
|
| 60 |
+
rw [he] at ha
|
| 61 |
+
have hs : (∑ x,p.mass x*protocolCost D n (C x))+
|
| 62 |
+
(∑ x,p.mass x*log (D n (C x)).card)=
|
| 63 |
+
∑ x,p.mass x*protocolCost D (n+1) (F x) := by
|
| 64 |
+
simp only [protocolCost,mul_add,sum_add_distrib,C]
|
| 65 |
+
rw [←hs]
|
| 66 |
+
linarith
|
| 67 |
+
|
| 68 |
+
omit [Fintype Γ] in
|
| 69 |
+
|
| 70 |
+
theorem protocol_entropy_maximum (p : Law Ω)
|
| 71 |
+
(D : ∀ n:ℕ,(Fin n→α)→Finset α) (n : ℕ) (F : Ω→Fin n→α) (K : ℝ)
|
| 72 |
+
(hF : ∀ x,p.mass x≠0→ProtocolValid D n (F x))
|
| 73 |
+
(hK : ∀ x,p.mass x≠0→protocolCost D n (F x)≤K) :
|
| 74 |
+
entropy (p.map F)≤K := by
|
| 75 |
+
apply (protocol_entropy p D n F hF).trans
|
| 76 |
+
calc
|
| 77 |
+
_ ≤ ∑ x,p.mass x*K := by
|
| 78 |
+
apply sum_le_sum
|
| 79 |
+
intro x _
|
| 80 |
+
by_cases hx : p.mass x=0
|
| 81 |
+
· simp [hx]
|
| 82 |
+
· exact mul_le_mul_of_nonneg_left (hK x hx) (p.nonneg x)
|
| 83 |
+
_ = K := by rw [←sum_mul,p.total,one_mul]
|
| 84 |
+
|
| 85 |
+
end
|
| 86 |
+
end SharpLogRamsey.Selection
|
| 87 |
+
|
| 88 |
+
end
|
| 89 |
+
|
| 90 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/ReciprocalEntropy.lean
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Trees.PivotAlphabetCost
|
| 3 |
+
import OAI.Combinatorics.SharpRamsey.Trees.ChronologicalExecution
|
| 4 |
+
import OAI.Combinatorics.SharpRamsey.Execution.ExecutedOverhead
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
namespace SharpLogRamsey.ActualPivot
|
| 10 |
+
open Finset Real Incidence Validation ScheduledBanks PublicTables ReadyTests
|
| 11 |
+
PivotGeometry ProjectiveDuality TreeDecoder FreshExecution ExecutedPotential
|
| 12 |
+
open scoped Classical BigOperators
|
| 13 |
+
noncomputable section
|
| 14 |
+
variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V]
|
| 15 |
+
[FiniteDimensional K V]
|
| 16 |
+
[Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))]
|
| 17 |
+
[Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))]
|
| 18 |
+
{I Ω : Type*} [Fintype I] [Fintype Ω]
|
| 19 |
+
{n : ℕ} {b τ P H : ℝ}
|
| 20 |
+
|
| 21 |
+
def Book.publicAlphabet (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3))
|
| 22 |
+
(z : I→Banks (K:=K) (V:=V) b) (U : ChronoDomains (K:=K) (V:=V)) :
|
| 23 |
+
Finset (I×Code (K:=K) (V:=V) b) :=
|
| 24 |
+
univ.biUnion (fun i=>(book.allowed (z i).1 U.swap).image (fun c=>(i,c)))
|
| 25 |
+
|
| 26 |
+
variable (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3))
|
| 27 |
+
|
| 28 |
+
omit [Finite K] in
|
| 29 |
+
lemma Book.mem_publicAlphabet (z : I→Banks (K:=K) (V:=V) b)
|
| 30 |
+
(U : ChronoDomains (K:=K) (V:=V)) (i : I) (c : Code (K:=K) (V:=V) b)
|
| 31 |
+
(hc : c∈book.allowed (z i).1 U.swap) : (i,c)∈book.publicAlphabet z U := by
|
| 32 |
+
exact mem_biUnion.mpr ⟨i,mem_univ _,mem_image.mpr ⟨c,hc,rfl⟩⟩
|
| 33 |
+
|
| 34 |
+
omit [Finite K] in
|
| 35 |
+
lemma Book.publicAlphabet_card (z : I→Banks (K:=K) (V:=V) b)
|
| 36 |
+
(U : ChronoDomains (K:=K) (V:=V)) :
|
| 37 |
+
(book.publicAlphabet z U).card≤∑ i,(book.allowed (z i).1 U.swap).card := by
|
| 38 |
+
apply (card_biUnion_le).trans
|
| 39 |
+
exact sum_le_sum (fun i _=>card_image_le)
|
| 40 |
+
|
| 41 |
+
variable (hb : 0≤b) (hH : 0≤H) (hP : 4≤P) (haP : b+log 1000000≤P)
|
| 42 |
+
include hb hH hP haP
|
| 43 |
+
|
| 44 |
+
lemma Book.publicAlphabet_log (z : I→Banks (K:=K) (V:=V) b)
|
| 45 |
+
(U : ChronoDomains (K:=K) (V:=V)) :
|
| 46 |
+
log ((book.publicAlphabet z U).card:ℝ)≤
|
| 47 |
+
log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+
|
| 48 |
+
(2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) := by
|
| 49 |
+
let L := headerCost (K:=K) (V:=V)+
|
| 50 |
+
(2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P)
|
| 51 |
+
have hL : 0≤L := add_nonneg headerCost_nonneg
|
| 52 |
+
(mul_nonneg (by positivity) (add_nonneg (potential_nonneg _ _) (by linarith)))
|
| 53 |
+
have hs : potential ((Nat.card K:ℝ)^(n+3)) U.swap=potential ((Nat.card K:ℝ)^(n+3)) U := by
|
| 54 |
+
dsimp only [potential,Prod.swap]; rw [mul_comm]
|
| 55 |
+
have hc : ((book.publicAlphabet z U).card:ℝ)≤((Fintype.card I:ℝ)+1)*exp L := by
|
| 56 |
+
calc
|
| 57 |
+
_ ≤ ∑ i,((book.allowed (z i).1 U.swap).card:ℝ) := by exact_mod_cast book.publicAlphabet_card z U
|
| 58 |
+
_ ≤ ∑ _i : I,exp L := by
|
| 59 |
+
apply sum_le_sum
|
| 60 |
+
intro i _
|
| 61 |
+
simpa only [hs] using book.allowed_card_exp hb hH hP haP (z i).1 U.swap
|
| 62 |
+
_ = (Fintype.card I:ℝ)*exp L := by simp only [sum_const,card_univ,nsmul_eq_mul]
|
| 63 |
+
_ ≤ _ := mul_le_mul_of_nonneg_right (by linarith) (exp_pos L).le
|
| 64 |
+
by_cases hz : (book.publicAlphabet z U).card=0
|
| 65 |
+
· rw [hz,Nat.cast_zero,log_zero,add_assoc]
|
| 66 |
+
exact add_nonneg (log_nonneg (by have := Nat.cast_nonneg (α:=ℝ) (Fintype.card I); linarith)) hL
|
| 67 |
+
· apply (log_le_iff_le_exp (by exact_mod_cast Nat.pos_of_ne_zero hz)).mpr
|
| 68 |
+
rw [add_assoc,exp_add,exp_log (by positivity)]
|
| 69 |
+
exact hc
|
| 70 |
+
|
| 71 |
+
local instance publicCodeDecidableEq : DecidableEq (I×Code (K:=K) (V:=V) b) := Classical.decEq _
|
| 72 |
+
|
| 73 |
+
variable (hdim : Module.finrank K V=n+3) (hτ : 0≤τ) (hτsmall : τ≤1/40000)
|
| 74 |
+
|
| 75 |
+
theorem Book.actual_full_entropy (p : Selection.Law Ω)
|
| 76 |
+
(s : Ω→I→Original (K:=K) (V:=V) n b) (z : I→Banks (K:=K) (V:=V) b)
|
| 77 |
+
(t : Ω→BinaryTree I) (U : ChronoDomains (K:=K) (V:=V))
|
| 78 |
+
(N ht m : ℕ) (targets : Ω→I→List (Projectivization K (Module.Dual K V)×Projectivization K V))
|
| 79 |
+
(counts : Ω→I→ℕ) (hcounts : ∀ ω i,counts ω i ≤ m)
|
| 80 |
+
(hN : ∀ ω,(t ω).numNodes≤N) (hht : ∀ ω,(t ω).height≤ht) :
|
| 81 |
+
let rd := fixedRead (fun _i : I=>chronoRead (K:=K) (V:=V) b) z
|
| 82 |
+
let ch := fun ω=>fixedChoose (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) z
|
| 83 |
+
let M := fun ω=>codeTree (countReader rd)
|
| 84 |
+
(countChoose (fun y x=>SharpLogRamsey.Incidence.Incident x y) rd (ch ω) (targets ω) (counts ω)) (t ω) U
|
| 85 |
+
let S := univ.image M
|
| 86 |
+
let msg : Ω→S := fun ω=>⟨M ω,mem_image.mpr ⟨ω,mem_univ _,rfl⟩⟩
|
| 87 |
+
Selection.entropy (p.map msg)≤((2*N+1:ℕ):ℝ)*log 2+
|
| 88 |
+
(N:ℝ)*(log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+log (m+1:ℕ))+
|
| 89 |
+
(2*(H+22)*(Nat.card K:ℝ)*P)*
|
| 90 |
+
((ht:ℝ)*(potential ((Nat.card K:ℝ)^(n+3)) U+(N:ℝ)*(b+log 4+2*log 2000))+(N:ℝ)*P) := by
|
| 91 |
+
apply full_execution_entropy_overhead p ((Nat.card K:ℝ)^(n+3)) 2000 b
|
| 92 |
+
(2*(H+22)*(Nat.card K:ℝ)*P) P (log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V))
|
| 93 |
+
(by have : 0<Nat.card K:=Nat.zero_lt_one.trans (Finite.one_lt_card (α:=K)); positivity)
|
| 94 |
+
(by norm_num) hb (by positivity) (by linarith)
|
| 95 |
+
(add_nonneg (log_nonneg (by have := Nat.cast_nonneg (α:=ℝ) (Fintype.card I); linarith)) headerCost_nonneg)
|
| 96 |
+
N ht m _ (book.publicAlphabet z) _ _ t U targets counts hcounts hN hht
|
| 97 |
+
· intro ω i U c hc
|
| 98 |
+
obtain ⟨x,hx,rfl⟩:=Option.map_eq_some_iff.mp hc
|
| 99 |
+
apply book.mem_publicAlphabet
|
| 100 |
+
exact book.choose_allowed hdim hτ hτsmall (s ω i) (z i) U.swap x hx
|
| 101 |
+
· intro ω i U c hc
|
| 102 |
+
obtain ⟨x,hx,rfl⟩:=Option.map_eq_some_iff.mp hc
|
| 103 |
+
have hh:=book.choose_caps hdim hτ hτsmall (s ω i) U.swap (z i) x hx
|
| 104 |
+
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⟩
|
| 105 |
+
simpa only [mul_comm] using (s ω i).product
|
| 106 |
+
· intro ω i U c hc
|
| 107 |
+
exact book.publicAlphabet_log hb hH hP haP z U
|
| 108 |
+
|
| 109 |
+
end
|
| 110 |
+
end SharpLogRamsey.ActualPivot
|
| 111 |
+
|
| 112 |
+
end
|
| 113 |
+
|
| 114 |
+
end OAI
|
lean/OAI/Combinatorics/SharpRamsey/Entropy/SelectedEntropy.lean
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Combinatorics.SharpRamsey.Marking.SelectionLogBound
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
namespace SharpLogRamsey.Selection
|
| 8 |
+
open Real Finset
|
| 9 |
+
open scoped Classical
|
| 10 |
+
noncomputable section
|
| 11 |
+
variable {Ω α : Type} [Fintype Ω] [Fintype α] [Nonempty α]
|
| 12 |
+
|
| 13 |
+
theorem selected_map_entropy {N ℓ d : ℕ} (hd : 1 ≤ d) (hℓ : 0 < ℓ) (hN : ℓ ≤ N)
|
| 14 |
+
(p : Law Ω) (stream : Ω → Fin N → α) (F : Ω → Fin ℓ → α)
|
| 15 |
+
(reverse : (Fin ℓ → α) → (Fin ℓ → α))
|
| 16 |
+
{C q σ η c : ℝ} (hC : 0 < C) (hq : 0 < q) (hσ : 0 < σ) (hc : 0 < c)
|
| 17 |
+
(hdom : ∀ g, (p.map stream).mass g ≤ C/(Fintype.card α:ℝ)^N)
|
| 18 |
+
(hselect : ∀ x, p.mass x ≠ 0 → Occurs (F x) (stream x) ∨ Occurs (reverse (F x)) (stream x))
|
| 19 |
+
(hsize : (N:ℝ) ≤ q^d*σ) (hlength : c*q*σ^(1+η) ≤ (ℓ:ℝ))
|
| 20 |
+
(halphabet : q^(2*d-1) ≤ (Fintype.card α:ℝ)) :
|
| 21 |
+
(ℓ:ℝ)*((d:ℝ)*log q+η*log σ+log c-1)-log (2*C) ≤ entropy (p.map F) := by
|
| 22 |
+
let P := p.map (fun x => (stream x,F x))
|
| 23 |
+
have hfst : P.fst = p.map stream := by
|
| 24 |
+
rw [←Law.map_fst]
|
| 25 |
+
dsimp only [P]
|
| 26 |
+
rw [Law.map_map]
|
| 27 |
+
rfl
|
| 28 |
+
have hsnd : P.snd = p.map F := by
|
| 29 |
+
rw [←Law.map_snd]
|
| 30 |
+
dsimp only [P]
|
| 31 |
+
rw [Law.map_map]
|
| 32 |
+
rfl
|
| 33 |
+
have hh := selected_entropy_source_scales hd hℓ hN P reverse hC hq hσ hc
|
| 34 |
+
(by simpa only [hfst] using hdom) (by
|
| 35 |
+
intro g f hgf
|
| 36 |
+
obtain ⟨x,hx,he⟩ := p.map_support (fun x => (stream x,F x)) (g,f) hgf
|
| 37 |
+
have hh := hselect x hx
|
| 38 |
+
have he1 : stream x = g := congrArg Prod.fst he
|
| 39 |
+
have he2 : F x = f := congrArg Prod.snd he
|
| 40 |
+
simpa only [he1,he2] using hh) hsize hlength halphabet
|
| 41 |
+
rwa [hsnd] at hh
|
| 42 |
+
|
| 43 |
+
theorem selected_map_linear_deficit {N ℓ d : ℕ} (hd : 1 ≤ d) (hℓ : 0 < ℓ) (hN : ℓ ≤ N)
|
| 44 |
+
(p : Law Ω) (stream : Ω → Fin N → α) (F : Ω → Fin ℓ → α)
|
| 45 |
+
(reverse : (Fin ℓ → α) → (Fin ℓ → α))
|
| 46 |
+
{C q σ η c : ℝ} (hC : 0 < C) (hq : 0 < q) (hσ : 1 ≤ σ) (hη : 0 ≤ η) (hc : 0 < c)
|
| 47 |
+
(hdom : ∀ g, (p.map stream).mass g ≤ C/(Fintype.card α:ℝ)^N)
|
| 48 |
+
(hselect : ∀ x, p.mass x ≠ 0 → Occurs (F x) (stream x) ∨ Occurs (reverse (F x)) (stream x))
|
| 49 |
+
(hsize : (N:ℝ) ≤ q^d*σ) (hlength : c*q*σ^(1+η) ≤ (ℓ:ℝ))
|
| 50 |
+
(halphabet : q^(2*d-1) ≤ (Fintype.card α:ℝ)) :
|
| 51 |
+
(ℓ:ℝ)*((d:ℝ)*log q)-(1+|log c|+|log (2*C)|)*ℓ ≤ entropy (p.map F) := by
|
| 52 |
+
have hh := selected_map_entropy hd hℓ hN p stream F reverse hC hq (by linarith) hc
|
| 53 |
+
hdom hselect hsize hlength halphabet
|
| 54 |
+
have hpos : (1:ℝ) ≤ ℓ := by exact_mod_cast hℓ
|
| 55 |
+
have hl : 0 ≤ log σ := log_nonneg hσ
|
| 56 |
+
have hgain : 0 ≤ (ℓ:ℝ)*(η*log σ) := mul_nonneg (Nat.cast_nonneg _) (mul_nonneg hη hl)
|
| 57 |
+
have hc' : -|log c| ≤ log c := neg_abs_le _
|
| 58 |
+
have hm : log (2*C) ≤ |log (2*C)| := le_abs_self _
|
| 59 |
+
have hm' : |log (2*C)| ≤ (ℓ:ℝ)*|log (2*C)| := le_mul_of_one_le_left (abs_nonneg _) hpos
|
| 60 |
+
have hc'' := mul_le_mul_of_nonneg_left hc' (Nat.cast_nonneg ℓ)
|
| 61 |
+
nlinarith only [hh,hgain,hm,hm',hc'']
|
| 62 |
+
end
|
| 63 |
+
end SharpLogRamsey.Selection
|
| 64 |
+
|
| 65 |
+
end
|
| 66 |
+
|
| 67 |
+
end OAI
|