Download data/lean/OAI/Combinatorics/CliqueFree/TriangleState.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.83 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/CliqueFree/TriangleState.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/CliqueFree/TriangleState.lean
-
curl -L -o TriangleState.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/CliqueFree/TriangleState.lean
7.83 kB
| import OAI.Combinatorics.CliqueFree.EdgeState | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators | |
| open Finset | |
| attribute [local instance] Classical.propDecidable | |
| namespace CliqueFreeIndependence.WeightedGraph | |
| universe u v | |
| variable {V : Type u} [Fintype V] | |
| attribute [local instance 10000] edgeStateDecEq | |
| abbrev TriangleState (G : SimpleGraph V) := | |
| {t : V Γ V Γ V // G.Adj t.1 t.2.1 β§ G.Adj t.1 t.2.2 β§ G.Adj t.2.1 t.2.2} | |
| noncomputable instance triangleStateFintype (G : SimpleGraph V) : Fintype (TriangleState G) := | |
| Subtype.fintype _ | |
| namespace TriangleState | |
| variable {G : SimpleGraph V} | |
| def first (t : TriangleState G) : V := t.val.1 | |
| def second (t : TriangleState G) : V := t.val.2.1 | |
| def third (t : TriangleState G) : V := t.val.2.2 | |
| omit [Fintype V] in | |
| @[simp] lemma adj12 (t : TriangleState G) : G.Adj t.first t.second := t.property.1 | |
| omit [Fintype V] in | |
| @[simp] lemma adj13 (t : TriangleState G) : G.Adj t.first t.third := t.property.2.1 | |
| omit [Fintype V] in | |
| @[simp] lemma adj23 (t : TriangleState G) : G.Adj t.second t.third := t.property.2.2 | |
| def edge12 (t : TriangleState G) : EdgeState G := β¨(t.first, t.second), t.adj12β© | |
| def edge13 (t : TriangleState G) : EdgeState G := β¨(t.first, t.third), t.adj13β© | |
| def edge23 (t : TriangleState G) : EdgeState G := β¨(t.second, t.third), t.adj23β© | |
| def swap (t : TriangleState G) : TriangleState G := | |
| β¨(t.second, t.first, t.third), t.adj12.symm, t.adj23, t.adj13β© | |
| def rotate (t : TriangleState G) : TriangleState G := | |
| β¨(t.second, t.third, t.first), t.adj23, t.adj12.symm, t.adj13.symmβ© | |
| def swapEquiv : TriangleState G β TriangleState G where | |
| toFun := swap | |
| invFun := swap | |
| left_inv t := by cases t; rfl | |
| right_inv t := by cases t; rfl | |
| def rotateEquiv : TriangleState G β TriangleState G where | |
| toFun := rotate | |
| invFun := rotate β rotate | |
| left_inv t := by cases t; rfl | |
| right_inv t := by cases t; rfl | |
| noncomputable def weight (w : V β β) (t : TriangleState G) : β := | |
| w t.first * w t.second * w t.third | |
| omit [Fintype V] in | |
| lemma weight_pos {w : V β β} (hw : β u, 0 < w u) (t : TriangleState G) : | |
| 0 < weight w t := mul_pos (mul_pos (hw _) (hw _)) (hw _) | |
| omit [Fintype V] in | |
| @[simp] lemma weight_swap (w : V β β) (t : TriangleState G) : | |
| weight w (swap t) = weight w t := by unfold weight swap first second third; ring | |
| omit [Fintype V] in | |
| @[simp] lemma weight_rotate (w : V β β) (t : TriangleState G) : | |
| weight w (rotate t) = weight w t := by unfold weight rotate first second third; ring | |
| lemma sum_rotate (w : V β β) (f : TriangleState G β β) : | |
| (β t, weight w t * f (rotate t)) = β t, weight w t * f t := by | |
| simpa only [rotateEquiv, Equiv.coe_fn_mk, weight_rotate] using rotateEquiv.sum_comp (fun t β¦ weight w t * f t) | |
| lemma sum_swap (w : V β β) (f : TriangleState G β β) : | |
| (β t, weight w t * f (swap t)) = β t, weight w t * f t := by | |
| simpa only [swapEquiv, Equiv.coe_fn_mk, weight_swap] using swapEquiv.sum_comp (fun t β¦ weight w t * f t) | |
| lemma sum_eq (f : V β V β V β β) : | |
| (β t : TriangleState G, f t.first t.second t.third) = | |
| β u, β v β neighbors G u, β z β neighbors G u, | |
| if G.Adj v z then f u v z else 0 := by | |
| classical | |
| change (β t : {t : V Γ V Γ V // _}, f t.val.1 t.val.2.1 t.val.2.2) = _ | |
| rw [β Finset.sum_subtype (univ.filter fun t : V Γ V Γ V β¦ | |
| G.Adj t.1 t.2.1 β§ G.Adj t.1 t.2.2 β§ G.Adj t.2.1 t.2.2) | |
| (by simp) (fun t : V Γ V Γ V β¦ f t.1 t.2.1 t.2.2)] | |
| simp only [sum_filter, Fintype.sum_prod_type, neighbors] | |
| apply sum_congr rfl | |
| intro u _ | |
| apply sum_congr rfl | |
| intro v _ | |
| by_cases huv : G.Adj u v | |
| Β· simp only [huv, true_and, βreduceIte] | |
| apply sum_congr rfl | |
| intro z _ | |
| by_cases huz : G.Adj u z <;> simp [huz] | |
| Β· simp [huv] | |
| lemma sum_weight (w : V β β) : (β t : TriangleState G, weight w t) = 6 * triangleMass G w := by | |
| simp only [weight] | |
| rw [sum_eq (fun u v z β¦ w u * w v * w z), triangleMass_eq_sum] | |
| simp only [triangleAt, commonMass_eq_sum, mul_sum, mul_ite, mul_zero, mul_assoc] | |
| lemma marginal (w : V β β) (f : V β V β β) : | |
| (β t : TriangleState G, weight w t * f t.first t.second) = | |
| β e : EdgeState G, w e.src * w e.dst * commonMass G w e.src e.dst * f e.src e.dst := by | |
| simp only [weight] | |
| rw [sum_eq (fun u v z β¦ w u * w v * w z * f u v), EdgeState.sum_eq (fun u v β¦ w u * w v * commonMass G w u v * f u v)] | |
| apply sum_congr rfl | |
| intro u _ | |
| apply sum_congr rfl | |
| intro v _ | |
| rw [commonMass_eq_sum] | |
| simp only [mul_sum, sum_mul, mul_ite, ite_mul, mul_zero, zero_mul] | |
| end TriangleState | |
| namespace TriangleState | |
| variable {G : SimpleGraph V} | |
| def flip (t : TriangleState G) : TriangleState G := | |
| β¨(t.first, t.third, t.second), t.adj13, t.adj12, t.adj23.symmβ© | |
| def flipEquiv : TriangleState G β TriangleState G where | |
| toFun := flip | |
| invFun := flip | |
| left_inv t := by cases t; rfl | |
| right_inv t := by cases t; rfl | |
| omit [Fintype V] in | |
| @[simp] lemma weight_flip (w : V β β) (t : TriangleState G) : | |
| weight w (flip t) = weight w t := by unfold weight flip first second third; ring | |
| lemma sum_flip (w : V β β) (f : TriangleState G β β) : | |
| (β t, weight w t * f (flip t)) = β t, weight w t * f t := by | |
| simpa only [flipEquiv, Equiv.coe_fn_mk, weight_flip] using | |
| flipEquiv.sum_comp (fun t β¦ weight w t * f t) | |
| abbrev CornerPairs (G : SimpleGraph V) := | |
| {p : EdgeState G Γ EdgeState G // p.1.src = p.2.src β§ G.Adj p.1.dst p.2.dst} | |
| def cornerEquiv : TriangleState G β CornerPairs G where | |
| toFun t := β¨(t.edge12, t.edge13), rfl, t.adj23β© | |
| invFun p := β¨(p.val.1.src, p.val.1.dst, p.val.2.dst), p.val.1.adj, | |
| by rw [p.property.1]; exact p.val.2.adj, p.property.2β© | |
| left_inv t := by cases t; rfl | |
| right_inv p := by | |
| apply Subtype.ext | |
| apply Prod.ext | |
| Β· rfl | |
| Β· apply Subtype.ext | |
| exact Prod.ext p.property.1 rfl | |
| lemma corner_sum (w : V β β) (f : EdgeState G β EdgeState G β β) : | |
| (β t : TriangleState G, weight w t * f t.edge12 t.edge13) = | |
| β e : EdgeState G, β z : EdgeState G, | |
| if e.src = z.src β§ G.Adj e.dst z.dst | |
| then w e.src * w e.dst * w z.dst * f e z else 0 := by | |
| classical | |
| calc | |
| _ = β p : CornerPairs G, w p.val.1.src * w p.val.1.dst * w p.val.2.dst * f p.val.1 p.val.2 := | |
| (cornerEquiv.sum_comp (fun p β¦ w p.val.1.src * w p.val.1.dst * w p.val.2.dst * f p.val.1 p.val.2)) | |
| _ = β p : EdgeState G Γ EdgeState G, | |
| if p.1.src = p.2.src β§ G.Adj p.1.dst p.2.dst | |
| then w p.1.src * w p.1.dst * w p.2.dst * f p.1 p.2 else 0 := by | |
| rw [β Finset.sum_subtype (univ.filter fun p : EdgeState G Γ EdgeState G β¦ | |
| p.1.src = p.2.src β§ G.Adj p.1.dst p.2.dst) (by simp) | |
| (fun p β¦ w p.1.src * w p.1.dst * w p.2.dst * f p.1 p.2), sum_filter] | |
| _ = _ := Fintype.sum_prod_type _ | |
| end TriangleState | |
| namespace TriangleState | |
| variable {G : SimpleGraph V} | |
| lemma sum_edge_permutations (w : V β β) (g : EdgeState G β β) : | |
| (β t, weight w t * g t.edge12.rev) = (β t, weight w t * g t.edge12) β§ | |
| (β t, weight w t * g t.edge13) = (β t, weight w t * g t.edge12) β§ | |
| (β t, weight w t * g t.edge13.rev) = (β t, weight w t * g t.edge12) β§ | |
| (β t, weight w t * g t.edge23) = (β t, weight w t * g t.edge12) β§ | |
| (β t, weight w t * g t.edge23.rev) = (β t, weight w t * g t.edge12) := by | |
| refine β¨sum_swap w (fun t β¦ g t.edge12), sum_flip w (fun t β¦ g t.edge12), ?_, | |
| sum_rotate w (fun t β¦ g t.edge12), ?_β© | |
| Β· exact (sum_rotate w (fun t β¦ g (rotate t).edge12)).trans (sum_rotate w (fun t β¦ g t.edge12)) | |
| Β· exact (sum_rotate w (fun t β¦ g (swap t).edge12)).trans (sum_swap w (fun t β¦ g t.edge12)) | |
| end TriangleState | |
| end CliqueFreeIndependence.WeightedGraph | |
| end | |
| end OAI | |