Theorem: List.count_erase
File: .lake/packages/batteries/Batteries/Data/List/Count.lean

tactic: simp
state_before: α : Type u_1
inst✝ : DecidableEq α
a b : α
⊢ count a ([].erase b) = count a [] - if a = b then 1 else 0
state_after: no goals

tactic: rw [erase_cons]
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
⊢ count a ((c :: l).erase b) = count a (c :: l) - if a = b then 1 else 0
state_after: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0

tactic: if hc : c = b then
  have hc_beq := (beq_iff_eq _ _).mpr hc
  rw [if_pos hc_beq, hc, count_cons, Nat.add_sub_cancel]
else
  have hc_beq := beq_false_of_ne hc
  simp only [hc_beq, if_false, count_cons, count_cons, count_erase a b l]
  if ha : a = b then
    rw [← ha, eq_comm] at hc
    rw [if_pos ha, if_neg hc, Nat.add_zero, Nat.add_zero]
  else
    rw [if_neg ha, Nat.sub_zero, Nat.sub_zero]
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0
state_after: no goals

tactic: have hc_beq := (beq_iff_eq _ _).mpr hc
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : c = b
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0
state_after: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : c = b
hc_beq : (c == b) = true
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0

tactic: rw [if_pos hc_beq, hc, count_cons, Nat.add_sub_cancel]
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : c = b
hc_beq : (c == b) = true
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0
state_after: no goals

tactic: have hc_beq := beq_false_of_ne hc
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬c = b
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0
state_after: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬c = b
hc_beq : (c == b) = false
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0

tactic: simp only [hc_beq, if_false, count_cons, count_cons, count_erase a b l]
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬c = b
hc_beq : (c == b) = false
⊢ count a (if (c == b) = true then l else c :: l.erase b) = count a (c :: l) - if a = b then 1 else 0
state_after: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬c = b
hc_beq : (c == b) = false
⊢ ((count a l - if a = b then 1 else 0) + if a = c then 1 else 0) =
    (count a l + if a = c then 1 else 0) - if a = b then 1 else 0

tactic: if ha : a = b then
  rw [← ha, eq_comm] at hc
  rw [if_pos ha, if_neg hc, Nat.add_zero, Nat.add_zero]
else
  rw [if_neg ha, Nat.sub_zero, Nat.sub_zero]
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬c = b
hc_beq : (c == b) = false
⊢ ((count a l - if a = b then 1 else 0) + if a = c then 1 else 0) =
    (count a l + if a = c then 1 else 0) - if a = b then 1 else 0
state_after: no goals

tactic: rw [← ha, eq_comm] at hc
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬c = b
hc_beq : (c == b) = false
ha : a = b
⊢ ((count a l - if a = b then 1 else 0) + if a = c then 1 else 0) =
    (count a l + if a = c then 1 else 0) - if a = b then 1 else 0
state_after: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬a = c
hc_beq : (c == b) = false
ha : a = b
⊢ ((count a l - if a = b then 1 else 0) + if a = c then 1 else 0) =
    (count a l + if a = c then 1 else 0) - if a = b then 1 else 0

tactic: rw [if_pos ha, if_neg hc, Nat.add_zero, Nat.add_zero]
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬a = c
hc_beq : (c == b) = false
ha : a = b
⊢ ((count a l - if a = b then 1 else 0) + if a = c then 1 else 0) =
    (count a l + if a = c then 1 else 0) - if a = b then 1 else 0
state_after: no goals

tactic: rw [if_neg ha, Nat.sub_zero, Nat.sub_zero]
state_before: α : Type u_1
inst✝ : DecidableEq α
a b c : α
l : List α
hc : ¬c = b
hc_beq : (c == b) = false
ha : ¬a = b
⊢ ((count a l - if a = b then 1 else 0) + if a = c then 1 else 0) =
    (count a l + if a = c then 1 else 0) - if a = b then 1 else 0
state_after: no goals