l3lab/ntp-mathlib huggingface dataset:
instance (priority := 100) LinearOrderedAddCommGroup.topologicalAddGroup : TopologicalAddGroup G
    where
  continuous_add := by
    refine' continuous_iff_continuousAt.2 _
    rintro ⟨a, b⟩
    refine' LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 => _
    rcases dense_or_discrete 0 ε with (⟨δ, δ0, δε⟩ | ⟨_h₁, h₂⟩)
    · -- If there exists `δ ∈ (0, ε)`, then we choose `δ`-nhd of `a` and `(ε-δ)`-nhd of `b`
      filter_upwards [(eventually_abs_sub_lt a δ0).prod_nhds
          (eventually_abs_sub_lt b (sub_pos.2 δε))]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < δ, hy : |y - b| < ε - δ⟩
      rw [add_sub_add_comm]
      calc
        |x - a + (y - b)| ≤ |x - a| + |y - b| := abs_add _ _
        _ < δ + (ε - δ) := add_lt_add hx hy
        _ = ε := add_sub_cancel'_right _ _
    · -- Otherwise `ε`-nhd of each point `a` is `{a}`
      

Proof state:
case mk.inr.intro
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f g : α → G
a b ε : G
ε0 : ε > 0
_h₁ : ∀ (a : G), 0 < a → ε ≤ a
h₂ : ∀ a < ε, a ≤ 0
⊢ ∀ᶠ (b_1 : G × G) in 𝓝 (a, b), |b_1.1 + b_1.2 - (fun p => p.1 + p.2) (a, b)| < ε

Next tactic:
have hε : ∀ {x y}, |x - y| < ε → x = y := by
        intro x y h
        simpa [sub_eq_zero] using h₂ _ h
instance (priority := 100) LinearOrderedAddCommGroup.topologicalAddGroup : TopologicalAddGroup G
    where
  continuous_add := by
    refine' continuous_iff_continuousAt.2 _
    rintro ⟨a, b⟩
    refine' LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 => _
    rcases dense_or_discrete 0 ε with (⟨δ, δ0, δε⟩ | ⟨_h₁, h₂⟩)
    · -- If there exists `δ ∈ (0, ε)`, then we choose `δ`-nhd of `a` and `(ε-δ)`-nhd of `b`
      filter_upwards [(eventually_abs_sub_lt a δ0).prod_nhds
          (eventually_abs_sub_lt b (sub_pos.2 δε))]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < δ, hy : |y - b| < ε - δ⟩
      rw [add_sub_add_comm]
      calc
        |x - a + (y - b)| ≤ |x - a| + |y - b| := abs_add _ _
        _ < δ + (ε - δ) := add_lt_add hx hy
        _ = ε := add_sub_cancel'_right _ _
    · -- Otherwise `ε`-nhd of each point `a` is `{a}`
      have hε : ∀ {x y}, |x - y| < ε → x = y := by
        

Proof state:
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f g : α → G
a b ε : G
ε0 : ε > 0
_h₁ : ∀ (a : G), 0 < a → ε ≤ a
h₂ : ∀ a < ε, a ≤ 0
⊢ ∀ {x y : G}, |x - y| < ε → x = y

Next tactic:
intro x y h
instance (priority := 100) LinearOrderedAddCommGroup.topologicalAddGroup : TopologicalAddGroup G
    where
  continuous_add := by
    refine' continuous_iff_continuousAt.2 _
    rintro ⟨a, b⟩
    refine' LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 => _
    rcases dense_or_discrete 0 ε with (⟨δ, δ0, δε⟩ | ⟨_h₁, h₂⟩)
    · -- If there exists `δ ∈ (0, ε)`, then we choose `δ`-nhd of `a` and `(ε-δ)`-nhd of `b`
      filter_upwards [(eventually_abs_sub_lt a δ0).prod_nhds
          (eventually_abs_sub_lt b (sub_pos.2 δε))]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < δ, hy : |y - b| < ε - δ⟩
      rw [add_sub_add_comm]
      calc
        |x - a + (y - b)| ≤ |x - a| + |y - b| := abs_add _ _
        _ < δ + (ε - δ) := add_lt_add hx hy
        _ = ε := add_sub_cancel'_right _ _
    · -- Otherwise `ε`-nhd of each point `a` is `{a}`
      have hε : ∀ {x y}, |x - y| < ε → x = y := by
        intro x y h
        

Proof state:
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f g : α → G
a b ε : G
ε0 : ε > 0
_h₁ : ∀ (a : G), 0 < a → ε ≤ a
h₂ : ∀ a < ε, a ≤ 0
x y : G
h : |x - y| < ε
⊢ x = y

Next tactic:
simpa [sub_eq_zero] using h₂ _ h
instance (priority := 100) LinearOrderedAddCommGroup.topologicalAddGroup : TopologicalAddGroup G
    where
  continuous_add := by
    refine' continuous_iff_continuousAt.2 _
    rintro ⟨a, b⟩
    refine' LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 => _
    rcases dense_or_discrete 0 ε with (⟨δ, δ0, δε⟩ | ⟨_h₁, h₂⟩)
    · -- If there exists `δ ∈ (0, ε)`, then we choose `δ`-nhd of `a` and `(ε-δ)`-nhd of `b`
      filter_upwards [(eventually_abs_sub_lt a δ0).prod_nhds
          (eventually_abs_sub_lt b (sub_pos.2 δε))]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < δ, hy : |y - b| < ε - δ⟩
      rw [add_sub_add_comm]
      calc
        |x - a + (y - b)| ≤ |x - a| + |y - b| := abs_add _ _
        _ < δ + (ε - δ) := add_lt_add hx hy
        _ = ε := add_sub_cancel'_right _ _
    · -- Otherwise `ε`-nhd of each point `a` is `{a}`
      have hε : ∀ {x y}, |x - y| < ε → x = y := by
        intro x y h
        simpa [sub_eq_zero] using h₂ _ h
      

Proof state:
case mk.inr.intro
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f g : α → G
a b ε : G
ε0 : ε > 0
_h₁ : ∀ (a : G), 0 < a → ε ≤ a
h₂ : ∀ a < ε, a ≤ 0
hε : ∀ {x y : G}, |x - y| < ε → x = y
⊢ ∀ᶠ (b_1 : G × G) in 𝓝 (a, b), |b_1.1 + b_1.2 - (fun p => p.1 + p.2) (a, b)| < ε

Next tactic:
filter_upwards [(eventually_abs_sub_lt a ε0).prod_nhds (eventually_abs_sub_lt b ε0)]
instance (priority := 100) LinearOrderedAddCommGroup.topologicalAddGroup : TopologicalAddGroup G
    where
  continuous_add := by
    refine' continuous_iff_continuousAt.2 _
    rintro ⟨a, b⟩
    refine' LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 => _
    rcases dense_or_discrete 0 ε with (⟨δ, δ0, δε⟩ | ⟨_h₁, h₂⟩)
    · -- If there exists `δ ∈ (0, ε)`, then we choose `δ`-nhd of `a` and `(ε-δ)`-nhd of `b`
      filter_upwards [(eventually_abs_sub_lt a δ0).prod_nhds
          (eventually_abs_sub_lt b (sub_pos.2 δε))]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < δ, hy : |y - b| < ε - δ⟩
      rw [add_sub_add_comm]
      calc
        |x - a + (y - b)| ≤ |x - a| + |y - b| := abs_add _ _
        _ < δ + (ε - δ) := add_lt_add hx hy
        _ = ε := add_sub_cancel'_right _ _
    · -- Otherwise `ε`-nhd of each point `a` is `{a}`
      have hε : ∀ {x y}, |x - y| < ε → x = y := by
        intro x y h
        simpa [sub_eq_zero] using h₂ _ h
      filter_upwards [(eventually_abs_sub_lt a ε0).prod_nhds (eventually_abs_sub_lt b ε0)]
      

Proof state:
case h
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f g : α → G
a b ε : G
ε0 : ε > 0
_h₁ : ∀ (a : G), 0 < a → ε ≤ a
h₂ : ∀ a < ε, a ≤ 0
hε : ∀ {x y : G}, |x - y| < ε → x = y
⊢ ∀ (a_1 : G × G), |a_1.1 - a| < ε ∧ |a_1.2 - b| < ε → |a_1.1 + a_1.2 - (a + b)| < ε

Next tactic:
rintro ⟨x, y⟩ ⟨hx : |x - a| < ε, hy : |y - b| < ε⟩
instance (priority := 100) LinearOrderedAddCommGroup.topologicalAddGroup : TopologicalAddGroup G
    where
  continuous_add := by
    refine' continuous_iff_continuousAt.2 _
    rintro ⟨a, b⟩
    refine' LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 => _
    rcases dense_or_discrete 0 ε with (⟨δ, δ0, δε⟩ | ⟨_h₁, h₂⟩)
    · -- If there exists `δ ∈ (0, ε)`, then we choose `δ`-nhd of `a` and `(ε-δ)`-nhd of `b`
      filter_upwards [(eventually_abs_sub_lt a δ0).prod_nhds
          (eventually_abs_sub_lt b (sub_pos.2 δε))]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < δ, hy : |y - b| < ε - δ⟩
      rw [add_sub_add_comm]
      calc
        |x - a + (y - b)| ≤ |x - a| + |y - b| := abs_add _ _
        _ < δ + (ε - δ) := add_lt_add hx hy
        _ = ε := add_sub_cancel'_right _ _
    · -- Otherwise `ε`-nhd of each point `a` is `{a}`
      have hε : ∀ {x y}, |x - y| < ε → x = y := by
        intro x y h
        simpa [sub_eq_zero] using h₂ _ h
      filter_upwards [(eventually_abs_sub_lt a ε0).prod_nhds (eventually_abs_sub_lt b ε0)]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < ε, hy : |y - b| < ε⟩
      

Proof state:
case h.mk.intro
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f g : α → G
a b ε : G
ε0 : ε > 0
_h₁ : ∀ (a : G), 0 < a → ε ≤ a
h₂ : ∀ a < ε, a ≤ 0
hε : ∀ {x y : G}, |x - y| < ε → x = y
x y : G
hx : |x - a| < ε
hy : |y - b| < ε
⊢ |(x, y).1 + (x, y).2 - (a + b)| < ε

Next tactic:
simpa [hε hx, hε hy]
instance (priority := 100) LinearOrderedAddCommGroup.topologicalAddGroup : TopologicalAddGroup G
    where
  continuous_add := by
    refine' continuous_iff_continuousAt.2 _
    rintro ⟨a, b⟩
    refine' LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 => _
    rcases dense_or_discrete 0 ε with (⟨δ, δ0, δε⟩ | ⟨_h₁, h₂⟩)
    · -- If there exists `δ ∈ (0, ε)`, then we choose `δ`-nhd of `a` and `(ε-δ)`-nhd of `b`
      filter_upwards [(eventually_abs_sub_lt a δ0).prod_nhds
          (eventually_abs_sub_lt b (sub_pos.2 δε))]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < δ, hy : |y - b| < ε - δ⟩
      rw [add_sub_add_comm]
      calc
        |x - a + (y - b)| ≤ |x - a| + |y - b| := abs_add _ _
        _ < δ + (ε - δ) := add_lt_add hx hy
        _ = ε := add_sub_cancel'_right _ _
    · -- Otherwise `ε`-nhd of each point `a` is `{a}`
      have hε : ∀ {x y}, |x - y| < ε → x = y := by
        intro x y h
        simpa [sub_eq_zero] using h₂ _ h
      filter_upwards [(eventually_abs_sub_lt a ε0).prod_nhds (eventually_abs_sub_lt b ε0)]
      rintro ⟨x, y⟩ ⟨hx : |x - a| < ε, hy : |y - b| < ε⟩
      simpa [hε hx, hε hy]
  continuous_neg :=
    continuous_iff_continuousAt.2 fun a =>
      LinearOrderedAddCommGroup.tendsto_nhds.2 fun ε ε0 =>
        (eventually_abs_sub_lt a ε0).mono fun x hx => by 

Proof state:
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f g : α → G
a ε : G
ε0 : ε > 0
x : G
hx : |x - a| < ε
⊢ |-x - (fun a => -a) a| < ε

Next tactic:
rwa [neg_sub_neg, abs_sub_comm]
theorem tendsto_zero_iff_abs_tendsto_zero (f : α → G) :
    Tendsto f l (𝓝 0) ↔ Tendsto (abs ∘ f) l (𝓝 0) := by
  

Proof state:
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f✝ g f : α → G
⊢ Tendsto f l (𝓝 0) ↔ Tendsto (abs ∘ f) l (𝓝 0)

Next tactic:
refine' ⟨fun h => (abs_zero : |(0 : G)| = 0) ▸ h.abs, fun h => _⟩
theorem tendsto_zero_iff_abs_tendsto_zero (f : α → G) :
    Tendsto f l (𝓝 0) ↔ Tendsto (abs ∘ f) l (𝓝 0) := by
  refine' ⟨fun h => (abs_zero : |(0 : G)| = 0) ▸ h.abs, fun h => _⟩
  

Proof state:
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f✝ g f : α → G
h : Tendsto (abs ∘ f) l (𝓝 0)
⊢ Tendsto f l (𝓝 0)

Next tactic:
have : Tendsto (fun a => -|f a|) l (𝓝 0) := (neg_zero : -(0 : G) = 0) ▸ h.neg
theorem tendsto_zero_iff_abs_tendsto_zero (f : α → G) :
    Tendsto f l (𝓝 0) ↔ Tendsto (abs ∘ f) l (𝓝 0) := by
  refine' ⟨fun h => (abs_zero : |(0 : G)| = 0) ▸ h.abs, fun h => _⟩
  have : Tendsto (fun a => -|f a|) l (𝓝 0) := (neg_zero : -(0 : G) = 0) ▸ h.neg
  

Proof state:
α : Type u_1
G : Type u_2
inst✝² : TopologicalSpace G
inst✝¹ : LinearOrderedAddCommGroup G
inst✝ : OrderTopology G
l : Filter α
f✝ g f : α → G
h : Tendsto (abs ∘ f) l (𝓝 0)
this : Tendsto (fun a => -|f a|) l (𝓝 0)
⊢ Tendsto f l (𝓝 0)

Next tactic:
exact
    tendsto_of_tendsto_of_tendsto_of_le_of_le this h (fun x => neg_abs_le_self <| f x) fun x =>
      le_abs_self <| f x
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  

Proof state:
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u v : V
p : Walk G u v
ht : IsTrail p
x : V
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ u ≠ v → x ≠ u ∧ x ≠ v

Next tactic:
induction' p with u u v w huv p ih
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · 

Proof state:
case nil
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v x u : V
ht : IsTrail Walk.nil
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges Walk.nil)) ↔ u ≠ u → x ≠ u ∧ x ≠ u

Next tactic:
simp
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · 

Proof state:
case cons
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v✝ x u v w : V
huv : Adj G u v
p : Walk G v w
ih : IsTrail p → (Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w)
ht : IsTrail (cons huv p)
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges (cons huv p))) ↔ u ≠ w → x ≠ u ∧ x ≠ w

Next tactic:
rw [cons_isTrail_iff] at ht
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    

Proof state:
case cons
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v✝ x u v w : V
huv : Adj G u v
p : Walk G v w
ih : IsTrail p → (Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w)
ht : IsTrail p ∧ ⟦(u, v)⟧ ∉ edges p
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges (cons huv p))) ↔ u ≠ w → x ≠ u ∧ x ≠ w

Next tactic:
specialize ih ht.1
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    

Proof state:
case cons
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v✝ x u v w : V
huv : Adj G u v
p : Walk G v w
ht : IsTrail p ∧ ⟦(u, v)⟧ ∉ edges p
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges (cons huv p))) ↔ u ≠ w → x ≠ u ∧ x ≠ w

Next tactic:
simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    

Proof state:
case cons
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v✝ x u v w : V
huv : Adj G u v
p : Walk G v w
ht : IsTrail p ∧ ⟦(u, v)⟧ ∉ edges p
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges p) + if decide (x = u ∨ x = v) = true then 1 else 0) ↔
    ¬u = w → ¬x = u ∧ ¬x = w

Next tactic:
split_ifs with h
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · 

Proof state:
case pos
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v✝ x u v w : V
huv : Adj G u v
p : Walk G v w
ht : IsTrail p ∧ ⟦(u, v)⟧ ∉ edges p
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w
h : decide (x = u ∨ x = v) = true
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges p) + 1) ↔ ¬u = w → ¬x = u ∧ ¬x = w

Next tactic:
rw [decide_eq_true_eq] at h
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      

Proof state:
case pos
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v✝ x u v w : V
huv : Adj G u v
p : Walk G v w
ht : IsTrail p ∧ ⟦(u, v)⟧ ∉ edges p
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w
h : x = u ∨ x = v
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges p) + 1) ↔ ¬u = w → ¬x = u ∧ ¬x = w

Next tactic:
obtain (rfl | rfl) := h
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      obtain (rfl | rfl) := h
      · 

Proof state:
case pos.inl
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u v✝ x v w : V
p : Walk G v w
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w
huv : Adj G x v
ht : IsTrail p ∧ ⟦(x, v)⟧ ∉ edges p
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges p) + 1) ↔ ¬x = w → ¬x = x ∧ ¬x = w

Next tactic:
rw [Nat.even_add_one, ih]
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      obtain (rfl | rfl) := h
      · rw [Nat.even_add_one, ih]
        

Proof state:
case pos.inl
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u v✝ x v w : V
p : Walk G v w
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w
huv : Adj G x v
ht : IsTrail p ∧ ⟦(x, v)⟧ ∉ edges p
⊢ ¬(v ≠ w → x ≠ v ∧ x ≠ w) ↔ ¬x = w → ¬x = x ∧ ¬x = w

Next tactic:
simp only [huv.ne, imp_false, Ne.def, not_false_iff, true_and_iff, not_forall,
          Classical.not_not, exists_prop, eq_self_iff_true, not_true, false_and_iff,
          and_iff_right_iff_imp]
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      obtain (rfl | rfl) := h
      · rw [Nat.even_add_one, ih]
        simp only [huv.ne, imp_false, Ne.def, not_false_iff, true_and_iff, not_forall,
          Classical.not_not, exists_prop, eq_self_iff_true, not_true, false_and_iff,
          and_iff_right_iff_imp]
        

Proof state:
case pos.inl
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u v✝ x v w : V
p : Walk G v w
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ v ≠ w → x ≠ v ∧ x ≠ w
huv : Adj G x v
ht : IsTrail p ∧ ⟦(x, v)⟧ ∉ edges p
⊢ x = w → ¬v = w

Next tactic:
rintro rfl rfl
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      obtain (rfl | rfl) := h
      · rw [Nat.even_add_one, ih]
        simp only [huv.ne, imp_false, Ne.def, not_false_iff, true_and_iff, not_forall,
          Classical.not_not, exists_prop, eq_self_iff_true, not_true, false_and_iff,
          and_iff_right_iff_imp]
        rintro rfl rfl
        

Proof state:
case pos.inl
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u v✝ v : V
huv : Adj G v v
p : Walk G v v
ih : Even (List.countP (fun e => decide (v ∈ e)) (edges p)) ↔ v ≠ v → v ≠ v ∧ v ≠ v
ht : IsTrail p ∧ ⟦(v, v)⟧ ∉ edges p
⊢ False

Next tactic:
exact G.loopless _ huv
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      obtain (rfl | rfl) := h
      · rw [Nat.even_add_one, ih]
        simp only [huv.ne, imp_false, Ne.def, not_false_iff, true_and_iff, not_forall,
          Classical.not_not, exists_prop, eq_self_iff_true, not_true, false_and_iff,
          and_iff_right_iff_imp]
        rintro rfl rfl
        exact G.loopless _ huv
      · 

Proof state:
case pos.inr
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v x u w : V
huv : Adj G u x
p : Walk G x w
ht : IsTrail p ∧ ⟦(u, x)⟧ ∉ edges p
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ x ≠ w → x ≠ x ∧ x ≠ w
⊢ Even (List.countP (fun e => decide (x ∈ e)) (edges p) + 1) ↔ ¬u = w → ¬x = u ∧ ¬x = w

Next tactic:
rw [Nat.even_add_one, ih, ← not_iff_not]
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      obtain (rfl | rfl) := h
      · rw [Nat.even_add_one, ih]
        simp only [huv.ne, imp_false, Ne.def, not_false_iff, true_and_iff, not_forall,
          Classical.not_not, exists_prop, eq_self_iff_true, not_true, false_and_iff,
          and_iff_right_iff_imp]
        rintro rfl rfl
        exact G.loopless _ huv
      · rw [Nat.even_add_one, ih, ← not_iff_not]
        

Proof state:
case pos.inr
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v x u w : V
huv : Adj G u x
p : Walk G x w
ht : IsTrail p ∧ ⟦(u, x)⟧ ∉ edges p
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ x ≠ w → x ≠ x ∧ x ≠ w
⊢ ¬¬(x ≠ w → x ≠ x ∧ x ≠ w) ↔ ¬(¬u = w → ¬x = u ∧ ¬x = w)

Next tactic:
simp only [huv.ne.symm, Ne.def, eq_self_iff_true, not_true, false_and_iff, not_forall,
          not_false_iff, exists_prop, and_true_iff, Classical.not_not, true_and_iff, iff_and_self]
theorem IsTrail.even_countP_edges_iff {u v : V} {p : G.Walk u v} (ht : p.IsTrail) (x : V) :
    Even (p.edges.countP fun e => x ∈ e) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by
  induction' p with u u v w huv p ih
  · simp
  · rw [cons_isTrail_iff] at ht
    specialize ih ht.1
    simp only [List.countP_cons, Ne.def, edges_cons, Sym2.mem_iff]
    split_ifs with h
    · rw [decide_eq_true_eq] at h
      obtain (rfl | rfl) := h
      · rw [Nat.even_add_one, ih]
        simp only [huv.ne, imp_false, Ne.def, not_false_iff, true_and_iff, not_forall,
          Classical.not_not, exists_prop, eq_self_iff_true, not_true, false_and_iff,
          and_iff_right_iff_imp]
        rintro rfl rfl
        exact G.loopless _ huv
      · rw [Nat.even_add_one, ih, ← not_iff_not]
        simp only [huv.ne.symm, Ne.def, eq_self_iff_true, not_true, false_and_iff, not_forall,
          not_false_iff, exists_prop, and_true_iff, Classical.not_not, true_and_iff, iff_and_self]
        

Proof state:
case pos.inr
V : Type u_1
G : SimpleGraph V
inst✝ : DecidableEq V
u✝ v x u w : V
huv : Adj G u x
p : Walk G x w
ht : IsTrail p ∧ ⟦(u, x)⟧ ∉ edges p
ih : Even (List.countP (fun e => decide (x ∈ e)) (edges p)) ↔ x ≠ w → x ≠ x ∧ x ≠ w
⊢ x = w → ¬u = w

Next tactic:
rintro rfl