Theorem: SimpleGraph.odd_card_odd_degree_vertices_ne
File: Mathlib/Combinatorics/SimpleGraph/DegreeSum.lean

tactic: rcases G.even_card_odd_degree_vertices with ⟨k, hg⟩
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
⊢ Odd (card (filter (fun w => w ≠ v ∧ Odd (degree G w)) univ))

tactic: have hk : 0 < k := by
  have hh : (filter (fun v : V => Odd (G.degree v)) univ).Nonempty := by
    use v
    simp only [true_and_iff, mem_filter, mem_univ]
    exact h
  rwa [← card_pos, hg, ← two_mul, zero_lt_mul_left] at hh
  exact zero_lt_two
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
⊢ Odd (card (filter (fun w => w ≠ v ∧ Odd (degree G w)) univ))

tactic: have hc : (fun w : V => w ≠ v ∧ Odd (G.degree w)) = fun w : V => Odd (G.degree w) ∧ w ≠ v := by
  ext w
  rw [and_comm]
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
⊢ Odd (card (filter (fun w => w ≠ v ∧ Odd (degree G w)) univ))

tactic: simp only [hc, filter_congr]
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
hc : (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v
⊢ Odd (card (filter (fun w => w ≠ v ∧ Odd (degree G w)) univ))

tactic: rw [← filter_filter, filter_ne', card_erase_of_mem]
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
hc : (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v
⊢ Odd (card (filter (fun w => Odd (degree G w) ∧ w ≠ v) univ))

tactic: have hh : (filter (fun v : V => Odd (G.degree v)) univ).Nonempty := by
  use v
  simp only [true_and_iff, mem_filter, mem_univ]
  exact h
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
⊢ 0 < k

tactic: rwa [← card_pos, hg, ← two_mul, zero_lt_mul_left] at hh
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hh : Finset.Nonempty (filter (fun v => Odd (degree G v)) univ)
⊢ 0 < k

tactic: exact zero_lt_two
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hh : 0 < 2 * k
⊢ 0 < 2

tactic: use v
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
⊢ Finset.Nonempty (filter (fun v => Odd (degree G v)) univ)

tactic: simp only [true_and_iff, mem_filter, mem_univ]
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
⊢ v ∈ filter (fun v => Odd (degree G v)) univ

tactic: exact h
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
⊢ Odd (degree G v)

tactic: ext w
state_before: V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
⊢ (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v

tactic: rw [and_comm]
state_before: case h.a
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
w : V
⊢ w ≠ v ∧ Odd (degree G w) ↔ Odd (degree G w) ∧ w ≠ v

tactic: refine' ⟨k - 1, tsub_eq_of_eq_add <| hg.trans _⟩
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
hc : (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v
⊢ Odd (card (filter (fun w => Odd (degree G w)) univ) - 1)

tactic: rw [add_assoc, one_add_one_eq_two, ← Nat.mul_succ, ← two_mul]
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
hc : (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v
⊢ k + k = 2 * (k - 1) + 1 + 1

tactic: congr
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
hc : (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v
⊢ 2 * k = 2 * Nat.succ (k - 1)

tactic: exact (tsub_add_cancel_of_le <| Nat.succ_le_iff.2 hk).symm
state_before: case intro.e_a
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
hc : (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v
⊢ k = Nat.succ (k - 1)

tactic: simpa only [true_and_iff, mem_filter, mem_univ]
state_before: case intro
V : Type u
G : SimpleGraph V
inst✝² : Fintype V
inst✝¹ : DecidableEq V
inst✝ : DecidableRel G.Adj
v : V
h : Odd (degree G v)
k : ℕ
hg : card (filter (fun v => Odd (degree G v)) univ) = k + k
hk : 0 < k
hc : (fun w => w ≠ v ∧ Odd (degree G w)) = fun w => Odd (degree G w) ∧ w ≠ v
⊢ v ∈ filter (fun w => Odd (degree G w)) univ