@@ -6,6 +6,7 @@ Authors: Alena Gusakov, Arthur Paulino, Kyle Miller, Pim Otte
6
6
import Mathlib.Combinatorics.SimpleGraph.Connectivity.Subgraph
7
7
import Mathlib.Combinatorics.SimpleGraph.Connectivity.WalkCounting
8
8
import Mathlib.Combinatorics.SimpleGraph.DegreeSum
9
+ import Mathlib.Combinatorics.SimpleGraph.Operations
9
10
import Mathlib.Data.Fintype.Order
10
11
import Mathlib.Data.Set.Functor
11
12
@@ -89,6 +90,16 @@ lemma IsMatching.map_ofLE (h : M.IsMatching) (hGG' : G ≤ G') :
89
90
use w
90
91
simpa using hv' ▸ hw
91
92
93
+ lemma IsMatching.not_adj_left_of_ne {M : Subgraph G} {u v w : V} (hM : M.IsMatching) (huv : v ≠ w)
94
+ (hadj : M.Adj u v) : ¬M.Adj u w := by
95
+ intro hadj'
96
+ obtain ⟨x, hx⟩ := hM (M.edge_vert hadj)
97
+ exact huv (hx.2 _ hadj ▸ (hx.2 _ hadj').symm)
98
+
99
+ lemma IsMatching.not_adj_right_of_ne {M : Subgraph G} {u v w : V} (hM : M.IsMatching) (huw : u ≠ w)
100
+ (hadj : M.Adj u v) : ¬M.Adj w v :=
101
+ fun hadj' ↦ hM.not_adj_left_of_ne huw hadj.symm hadj'.symm
102
+
92
103
lemma IsMatching.sup (hM : M.IsMatching) (hM' : M'.IsMatching)
93
104
(hd : Disjoint M.support M'.support) : (M ⊔ M').IsMatching := by
94
105
intro v hv
@@ -354,6 +365,35 @@ lemma IsCycles.induce_supp (c : G.ConnectedComponent) (h : G.IsCycles) :
354
365
ext w'
355
366
simp only [mem_neighborSet, c.adj_spanningCoe_induce_supp, hw, true_and]
356
367
368
+ lemma Walk.IsCycle.isCycles_spanningCoe_toSubgraph {u : V} {p : G.Walk u u} (hpc : p.IsCycle) :
369
+ p.toSubgraph.spanningCoe.IsCycles := by
370
+ intro v hv
371
+ apply hpc.ncard_neighborSet_toSubgraph_eq_two
372
+ obtain ⟨_, hw⟩ := hv
373
+ exact p.mem_verts_toSubgraph.mp <| p.toSubgraph.edge_vert hw
374
+
375
+ lemma Walk.IsPath.isCycles_spanningCoe_toSubgraph_sup_edge {u v} {p : G.Walk u v} (hp : p.IsPath)
376
+ (h : u ≠ v) (hs : s(v, u) ∉ p.edges) : (p.toSubgraph.spanningCoe ⊔ edge v u).IsCycles := by
377
+ let c := (p.mapLe (OrderTop.le_top G)).cons (by simp [h.symm] : (completeGraph V).Adj v u)
378
+ have : p.toSubgraph.spanningCoe ⊔ edge v u = c.toSubgraph.spanningCoe := by
379
+ ext w x
380
+ simp only [sup_adj, Subgraph.spanningCoe_adj, completeGraph_eq_top, edge_adj, c,
381
+ Walk.toSubgraph, Subgraph.sup_adj, subgraphOfAdj_adj, adj_toSubgraph_mapLe]
382
+ aesop
383
+ exact this ▸ IsCycle.isCycles_spanningCoe_toSubgraph (by simp [Walk.cons_isCycle_iff, c, hp, hs])
384
+
385
+ lemma Walk.IsCycle.adj_toSubgraph_iff_of_isCycles [LocallyFinite G] {u} {p : G.Walk u u}
386
+ (hp : p.IsCycle) (hcyc : G.IsCycles) (hv : v ∈ p.toSubgraph.verts) :
387
+ ∀ w, p.toSubgraph.Adj v w ↔ G.Adj v w := by
388
+ refine fun w ↦ Subgraph.adj_iff_of_neighborSet_equiv (?_ : Inhabited _).default (Set.toFinite _)
389
+ apply Classical.inhabited_of_nonempty
390
+ rw [← Cardinal.eq, ← Set.cast_ncard (Set.toFinite _),
391
+ ← Set.cast_ncard (finite_neighborSet_toSubgraph p), hcyc
392
+ (Set.Nonempty.mono (p.toSubgraph.neighborSet_subset v) <|
393
+ Set.nonempty_of_ncard_ne_zero <| by simp [Set.Nonempty.mono,
394
+ hp.ncard_neighborSet_toSubgraph_eq_two (by aesop), Set.nonempty_of_ncard_ne_zero]),
395
+ hp.ncard_neighborSet_toSubgraph_eq_two (by aesop)]
396
+
357
397
open scoped symmDiff
358
398
359
399
lemma Subgraph.IsPerfectMatching.symmDiff_isCycles
@@ -490,6 +530,35 @@ def IsAlternating (G G' : SimpleGraph V) :=
490
530
lemma IsAlternating.mono {G'' : SimpleGraph V} (halt : G.IsAlternating G') (h : G'' ≤ G) :
491
531
G''.IsAlternating G' := fun _ _ _ hww' hvw hvw' ↦ halt hww' (h hvw) (h hvw')
492
532
533
+ lemma IsAlternating.spanningCoe (halt : G.IsAlternating G') (H : Subgraph G) :
534
+ H.spanningCoe.IsAlternating G' := by
535
+ intro v w w' hww' hvw hvv'
536
+ simp only [Subgraph.spanningCoe_adj] at hvw hvv'
537
+ exact halt hww' hvw.adj_sub hvv'.adj_sub
538
+
539
+ lemma IsAlternating.sup_edge {u x : V} (halt : G.IsAlternating G') (hnadj : ¬G'.Adj u x)
540
+ (hu' : ∀ u', u' ≠ u → G.Adj x u' → G'.Adj x u')
541
+ (hx' : ∀ x', x' ≠ x → G.Adj x' u → G'.Adj x' u) : (G ⊔ edge u x).IsAlternating G' := by
542
+ by_cases hadj : G.Adj u x
543
+ · rwa [sup_edge_of_adj G hadj]
544
+ intro v w w' hww' hvw hvv'
545
+ simp only [sup_adj, edge_adj] at hvw hvv'
546
+ obtain hl | hr := hvw <;> obtain h1 | h2 := hvv'
547
+ · exact halt hww' hl h1
548
+ · rw [G'.adj_congr_of_sym2 (by aesop : s(v, w') = s(u, x))]
549
+ simp only [hnadj, not_false_eq_true, iff_true]
550
+ rcases h2.1 with ⟨h2l1, h2l2⟩ | ⟨h2r1,h2r2⟩
551
+ · subst h2l1 h2l2
552
+ exact (hx' _ hww' hl.symm).symm
553
+ · aesop
554
+ · rw [G'.adj_congr_of_sym2 (by aesop : s(v, w) = s(u, x))]
555
+ simp only [hnadj, false_iff, not_not]
556
+ rcases hr.1 with ⟨hrl1, hrl2⟩ | ⟨hrr1, hrr2⟩
557
+ · subst hrl1 hrl2
558
+ exact (hx' _ hww'.symm h1.symm).symm
559
+ · aesop
560
+ · aesop
561
+
493
562
lemma IsPerfectMatching.symmDiff_of_isAlternating (hM : M.IsPerfectMatching)
494
563
(hG' : G'.IsAlternating M.spanningCoe) (hG'cyc : G'.IsCycles) :
495
564
(⊤ : Subgraph (M.spanningCoe ∆ G')).IsPerfectMatching := by
0 commit comments