File size: 5,089 Bytes
e320e82 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | import OAI.Combinatorics.GraphThreshold.GraphEncoding
import Mathlib.Tactic
namespace OAI
noncomputable section
namespace LeanBlast.SecondKahnKalai
section BernoulliEndpoints
variable {X : Type*} [Fintype X] [DecidableEq X]
theorem bernoulliWeight_zero (W : Finset X) :
bernoulliWeight 0 W = if W = ∅ then 1 else 0 := by
by_cases hW : W = ∅
· subst W
simp [bernoulliWeight]
· rw [ite_eq_right hW]
obtain ⟨x, hx⟩ := Finset.nonempty_iff_ne_empty.mpr hW
exact Finset.prod_eq_zero (Finset.mem_univ x) (by simp [hx])
theorem bernoulliWeight_one (W : Finset X) :
bernoulliWeight 1 W = if W = Finset.univ then 1 else 0 := by
by_cases hW : W = Finset.univ
· subst W
simp [bernoulliWeight]
· rw [ite_eq_right hW]
obtain ⟨x, hx⟩ : ∃ x : X, x ∉ W := by
simpa [Finset.eq_univ_iff_forall] using hW
exact Finset.prod_eq_zero (Finset.mem_univ x) (by simp [hx])
@[simp]
theorem bernoulliExpectation_zero (f : Finset X → ℝ) :
bernoulliExpectation 0 f = f ∅ := by
simp [bernoulliExpectation, bernoulliWeight_zero]
@[simp]
theorem bernoulliExpectation_one (f : Finset X → ℝ) :
bernoulliExpectation 1 f = f Finset.univ := by
simp [bernoulliExpectation, bernoulliWeight_one]
@[simp]
theorem bernoulliProbability_zero (P : Finset X → Prop) [DecidablePred P] :
bernoulliProbability 0 P = if P ∅ then 1 else 0 := by
classical
unfold bernoulliProbability
rw [Finset.sum_eq_single ∅]
· simp [bernoulliWeight_zero]
· intro W _ hW
simp [bernoulliWeight_zero, hW]
· simp
@[simp]
theorem bernoulliProbability_one (P : Finset X → Prop) [DecidablePred P] :
bernoulliProbability 1 P = if P Finset.univ then 1 else 0 := by
classical
unfold bernoulliProbability
rw [Finset.sum_eq_single Finset.univ]
· simp [bernoulliWeight_one]
· intro W _ hW
simp [bernoulliWeight_one, hW]
· simp
end BernoulliEndpoints
theorem copyCount_iso_target {V W U : Type*} [Fintype V]
(G : SimpleGraph V) {H : SimpleGraph W} {F : SimpleGraph U}
(e : H ≃g F) : G.copyCount H = G.copyCount F := by
classical
unfold SimpleGraph.copyCount
congr 1
apply Finset.filter_congr
intro J _
constructor
· rintro ⟨g⟩
exact ⟨g.comp e.symm⟩
· rintro ⟨g⟩
exact ⟨g.comp e⟩
theorem expectedCopies_iso {V W : Type*} (n : ℕ) (p : ℝ)
{H : SimpleGraph V} {F : SimpleGraph W} (e : H ≃g F) :
expectedCopies n p H = expectedCopies n p F := by
unfold expectedCopies bernoulliExpectation
simp_rw [copyCount_iso_target _ e]
theorem containmentProbability_iso {V W : Type*} (n : ℕ) (p : ℝ)
{H : SimpleGraph V} {F : SimpleGraph W} (e : H ≃g F) :
containmentProbability n p H = containmentProbability n p F := by
unfold containmentProbability
congr 1
funext K
rw [copyCount_iso_target _ e]
theorem isContained_top_of_card_le {V : Type*} [Fintype V] (n : ℕ)
(H : SimpleGraph V) (hcard : Fintype.card V ≤ n) :
H.IsContained (⊤ : SimpleGraph (Fin n)) := by
obtain ⟨f⟩ := Function.Embedding.nonempty_of_card_le
(show Fintype.card V ≤ Fintype.card (Fin n) by simpa using hcard)
refine ⟨{ toHom := ⟨f, ?_⟩, injective' := f.injective }⟩
intro a b hab
exact f.injective.ne hab.ne
theorem expectedCopies_one_ge_one {V : Type*} [Fintype V] (n : ℕ)
(H : SimpleGraph V) (hcard : Fintype.card V ≤ n) :
1 ≤ expectedCopies n 1 H := by
have hp : 0 < (⊤ : SimpleGraph (Fin n)).copyCount H :=
SimpleGraph.copyCount_pos.mpr (isContained_top_of_card_le n H hcard)
simpa only [expectedCopies, bernoulliExpectation_one, graphOfEdges_univ,
Nat.one_le_cast] using Nat.succ_le_of_lt hp
theorem containmentProbability_one {V : Type*} [Fintype V] (n : ℕ)
(H : SimpleGraph V) (hcard : Fintype.card V ≤ n) :
containmentProbability n 1 H = 1 := by
classical
have hp : 0 < (⊤ : SimpleGraph (Fin n)).copyCount H :=
SimpleGraph.copyCount_pos.mpr (isContained_top_of_card_le n H hcard)
simp only [containmentProbability, bernoulliProbability_one, graphOfEdges_univ, hp,
ite_true]
theorem copyCount_bot_of_edge {V W : Type*} [Fintype V] [Fintype W]
(H : SimpleGraph V) (he : 1 ≤ edgeCount H) :
(⊥ : SimpleGraph W).copyCount H = 0 := by
apply SimpleGraph.copyCount_eq_zero.mpr
rintro ⟨f⟩
have hbot : H = ⊥ := by
apply SimpleGraph.eq_bot_iff_forall_not_adj.mpr
intro a b hab
exact f.toHom.map_adj hab
have hz := (edgeCount_eq_zero_iff H).mpr hbot
omega
theorem expectedCopies_zero {V : Type*} [Fintype V] (n : ℕ)
(H : SimpleGraph V) (he : 1 ≤ edgeCount H) :
expectedCopies n 0 H = 0 := by
simp [expectedCopies, copyCount_bot_of_edge H he]
theorem containmentProbability_zero {V : Type*} [Fintype V] (n : ℕ)
(H : SimpleGraph V) (he : 1 ≤ edgeCount H) :
containmentProbability n 0 H = 0 := by
classical
simp only [containmentProbability, bernoulliProbability_zero, graphOfEdges_empty,
copyCount_bot_of_edge H he, lt_self_iff_false, ite_false]
end LeanBlast.SecondKahnKalai
end
end OAI
|