Theorem: SimpleGraph.ConnectedComponent.odd_matches_node_outside
File: Mathlib/Combinatorics/SimpleGraph/Matching.lean

Proof steps:
state_before: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
⊢ ∃ w ∈ u, ∃ v, M.Adj (↑v) w ∧ v ∈ c.supp
state_after: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
⊢ False
tactic: by_contra! h
state_before: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
⊢ False
state_after: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
hMmatch : (M.induce (Subtype.val '' c.supp)).IsMatching
⊢ False
tactic: have hMmatch : (M.induce c.supp).IsMatching := by
    intro v hv
    obtain ⟨w, hw⟩ := hM.1 (hM.2 v)
    obtain ⟨⟨v', hv'⟩, ⟨hv , rfl⟩⟩ := hv
    use w
    have hwnu : w ∉ u := fun hw' ↦ h w hw' ⟨v', hv'⟩ (hw.1) hv
    refine ⟨⟨⟨⟨v', hv'⟩, hv, rfl⟩, ?_, hw.1⟩, fun _ hy ↦ hw.2 _ hy.2.2⟩
    apply ConnectedComponent.mem_coe_supp_of_adj ⟨⟨v', hv'⟩, ⟨hv, rfl⟩⟩ ⟨by trivial, hwnu⟩
    simp only [Subgraph.induce_verts, Subgraph.verts_top, Set.mem_diff, Set.mem_univ, true_and,
      Subgraph.induce_adj, hwnu, not_false_eq_true, and_self, Subgraph.top_adj, M.adj_sub hw.1,
      and_true] at hv' ⊢
    trivial
state_before: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
hMmatch : (M.induce (Subtype.val '' c.supp)).IsMatching
⊢ False
state_after: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
hMmatch : (M.induce (Subtype.val '' c.supp)).IsMatching
⊢ Even (Nat.card ↑c.supp)
tactic: apply Nat.odd_iff_not_even.mp codd
state_before: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
hMmatch : (M.induce (Subtype.val '' c.supp)).IsMatching
⊢ Even (Nat.card ↑c.supp)
state_after: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
hMmatch : (M.induce (Subtype.val '' c.supp)).IsMatching
this : Fintype ↑(M.induce (Subtype.val '' c.supp)).verts
⊢ Even (Nat.card ↑c.supp)
tactic: haveI : Fintype ↑(Subgraph.induce M (Subtype.val '' supp c)).verts := Fintype.ofFinite _
state_before: V : Type u_1
G G' : SimpleGraph V
M M' : G.Subgraph
v w : V
inst✝¹ : Fintype V
inst✝ : DecidableRel G.Adj
u : Set V
c : (⊤.deleteVerts u).coe.ConnectedComponent
hM : M.IsPerfectMatching
codd : Odd (Nat.card ↑c.supp)
h : ∀ w ∈ u, ∀ (v : ↑(⊤.deleteVerts u).verts), M.Adj (↑v) w → v ∉ c.supp
hMmatch : (M.induce (Subtype.val '' c.supp)).IsMatching
this : Fintype ↑(M.induce (Subtype.val '' c.supp)).verts
⊢ Even (Nat.card ↑c.supp)
state_after: no goals
tactic: classical
  have hMeven := Subgraph.IsMatching.even_card hMmatch
  haveI : Fintype (c.supp) := Fintype.ofFinite _
  simp only [Subgraph.induce_verts, Subgraph.verts_top, Set.toFinset_image,
    Nat.card_eq_fintype_card, Set.toFinset_image,
    Finset.card_image_of_injective _ (Subtype.val_injective), Set.toFinset_card] at hMeven ⊢
  exact hMeven