File size: 5,551 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 | import OAI.Combinatorics.GraphThreshold.GraphEncoding
import OAI.Combinatorics.GraphThreshold.FiniteProbability
namespace OAI
noncomputable section
attribute [local instance] Classical.propDecidable
namespace LeanBlast.SecondKahnKalai
universe u
variable {n : ℕ} {V : Type u}
/-- Regard an actual subgraph as a subgraph of the complete graph. Its vertex set,
including all isolated vertices, is unchanged. -/
def subgraphToComplete {G : SimpleGraph (Fin n)} (K : G.Subgraph) :
(⊤ : SimpleGraph (Fin n)).Subgraph where
verts := K.verts
Adj := K.Adj
adj_sub h := h.ne
edge_vert := K.edge_vert
symm := K.symm
/-- A complete-graph subgraph whose edges occur in G is the same actual subgraph of G. -/
def subgraphFromComplete (G : SimpleGraph (Fin n))
(K : (⊤ : SimpleGraph (Fin n)).Subgraph) (hK : K.spanningCoe ≤ G) :
G.Subgraph where
verts := K.verts
Adj := K.Adj
adj_sub h := hK h
edge_vert := K.edge_vert
symm := K.symm
/-- Copies are put in bijection without choosing or counting graph embeddings. -/
def completeCopyEquiv (G : SimpleGraph (Fin n)) (F : SimpleGraph V) :
{K : G.Subgraph // Nonempty (F ≃g K.coe)} ≃
{K : (⊤ : SimpleGraph (Fin n)).Subgraph //
Nonempty (F ≃g K.coe) ∧ K.spanningCoe ≤ G} where
toFun K := ⟨subgraphToComplete K.val, K.property, fun _ _ h => K.val.adj_sub h⟩
invFun K := ⟨subgraphFromComplete G K.val K.property.2, K.property.1⟩
left_inv _ := rfl
right_inv _ := rfl
theorem copyCount_eq_complete_card (G : SimpleGraph (Fin n)) (F : SimpleGraph V) :
G.copyCount F = Nat.card
{K : (⊤ : SimpleGraph (Fin n)).Subgraph //
Nonempty (F ≃g K.coe) ∧ K.spanningCoe ≤ G} := by
classical
calc
G.copyCount F = Fintype.card {K : G.Subgraph // Nonempty (F ≃g K.coe)} := by
rw [SimpleGraph.copyCount, Fintype.card_subtype]
apply congrArg Finset.card
ext K
simp
_ = Fintype.card {K : (⊤ : SimpleGraph (Fin n)).Subgraph //
Nonempty (F ≃g K.coe) ∧ K.spanningCoe ≤ G} :=
Fintype.card_congr (completeCopyEquiv G F)
_ = _ := Nat.card_eq_fintype_card.symm
theorem copyCount_eq_sum_complete (G : SimpleGraph (Fin n)) (F : SimpleGraph V) :
(G.copyCount F : ℝ) =
∑ K : (⊤ : SimpleGraph (Fin n)).Subgraph,
if Nonempty (F ≃g K.coe) then (if K.spanningCoe ≤ G then (1 : ℝ) else 0)
else 0 := by
classical
rw [copyCount_eq_complete_card, Nat.card_eq_fintype_card, Fintype.card_subtype]
rw [Finset.card_eq_sum_ones]
simp only [Nat.cast_sum, Finset.sum_filter]
apply Finset.sum_congr rfl
intro K _
by_cases hF : Nonempty (F ≃g K.coe) <;> simp [hF]
/-- Adding ambient isolated vertices does not change the edge count. -/
theorem edgeCount_spanningCoe {G : SimpleGraph (Fin n)} (K : G.Subgraph) :
edgeCount K.spanningCoe = edgeCount K.coe := by
unfold edgeCount
rw [SimpleGraph.Subgraph.edgeSet_spanningCoe, ← K.image_coe_edgeSet_coe]
exact Nat.card_congr
(Equiv.Set.image (Sym2.map (Subtype.val : K.verts → Fin n)) K.coe.edgeSet
(Sym2.map.injective Subtype.val_injective)).symm
theorem card_graphEdges_of_copy (F : SimpleGraph V)
(K : (⊤ : SimpleGraph (Fin n)).Subgraph) (hK : Nonempty (F ≃g K.coe)) :
(graphEdges K.spanningCoe).card = edgeCount F := by
obtain ⟨f⟩ := hK
rw [card_graphEdges, edgeCount_spanningCoe]
exact (Nat.card_congr f.mapEdgeSet).symm
theorem subgraph_survival_probability (p : ℝ)
(K : (⊤ : SimpleGraph (Fin n)).Subgraph) :
bernoulliProbability p (fun W : Finset (Edge n) =>
K.spanningCoe ≤ graphOfEdges W) = p ^ edgeCount K.coe := by
have h : ∀ W : Finset (Edge n),
K.spanningCoe ≤ graphOfEdges W ↔ graphEdges K.spanningCoe ⊆ W := by
intro W
calc
K.spanningCoe ≤ graphOfEdges W ↔
graphOfEdges (graphEdges K.spanningCoe) ≤ graphOfEdges W := by
rw [graphOfEdges_graphEdges]
_ ↔ graphEdges K.spanningCoe ⊆ W := graphOfEdges_le_iff
simp_rw [h]
rw [bernoulliProbability_subset, card_graphEdges, edgeCount_spanningCoe]
/-- The exact expected number of unlabelled, non-induced copies. The counted
objects include their vertex sets, so the identity retains isolated vertices. -/
theorem expectedCopies_formula (n : ℕ) (p : ℝ) (F : SimpleGraph V) :
expectedCopies n p F =
((⊤ : SimpleGraph (Fin n)).copyCount F : ℝ) * p ^ edgeCount F := by
classical
calc
expectedCopies n p F =
∑ K : (⊤ : SimpleGraph (Fin n)).Subgraph,
if Nonempty (F ≃g K.coe) then p ^ edgeCount F else 0 := by
unfold expectedCopies bernoulliExpectation
simp_rw [copyCount_eq_sum_complete, Finset.mul_sum]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro K _
by_cases hK : Nonempty (F ≃g K.coe)
· simp only [hK, ite_true]
have hsurv := subgraph_survival_probability p K
have hedge : edgeCount K.coe = edgeCount F :=
(Nat.card_congr hK.some.mapEdgeSet).symm
rw [hedge] at hsurv
rw [← hsurv]
unfold bernoulliProbability
apply Finset.sum_congr rfl
intro W _
by_cases hW : K.spanningCoe ≤ graphOfEdges W <;> simp [hW]
· simp [hK]
_ = ((⊤ : SimpleGraph (Fin n)).copyCount F : ℝ) * p ^ edgeCount F := by
rw [copyCount_eq_sum_complete, Finset.sum_mul]
apply Finset.sum_congr rfl
intro K _
by_cases hK : Nonempty (F ≃g K.coe) <;> simp [hK]
end LeanBlast.SecondKahnKalai
end
end OAI
|