l3lab/ntp-mathlib huggingface dataset:
theorem card_le_card_cons (a : α) (as : List α) : card as ≤ card (a :: as) := by
  cases Decidable.em (a ∈ as) with
  | inl h => simp [h, Nat.le_refl]
  

Proof state:
case inr
α : Type u_1
β : Sort ?u.14075
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a : α
as : List α
h : ¬a ∈ as
⊢ card as ≤ card (a :: as)

Next tactic:
| inr h => simp [h, Nat.le_succ]
theorem card_le_card_cons (a : α) (as : List α) : card as ≤ card (a :: as) := by
  cases Decidable.em (a ∈ as) with
  | inl h => simp [h, Nat.le_refl]
  | inr h => 

Proof state:
case inr
α : Type u_1
β : Sort ?u.14075
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a : α
as : List α
h : ¬a ∈ as
⊢ card as ≤ card (a :: as)

Next tactic:
simp [h, Nat.le_succ]
@[simp] theorem card_insert_of_mem {a : α} {as : List α} (h : a ∈ as) :
    card (as.insert a) = card as := by 

Proof state:
α : Type u_1
β : Sort ?u.16383
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a : α
as : List α
h : a ∈ as
⊢ card (List.insert a as) = card as

Next tactic:
simp [h]
@[simp] theorem card_insert_of_not_mem {a : α} {as : List α} (h : a ∉ as) :
    card (as.insert a) = card as + 1 := by 

Proof state:
α : Type u_1
β : Sort ?u.17101
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a : α
as : List α
h : ¬a ∈ as
⊢ card (List.insert a as) = card as + 1

Next tactic:
simp [h]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    

Proof state:
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
⊢ card (a' :: as) = card (remove a (a' :: as)) + 1

Next tactic:
cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        | inr h'' =>
          have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
          simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    

Proof state:
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
x✝ : a = a' ∨ ¬a = a'
⊢ card (a' :: as) = card (remove a (a' :: as)) + 1

Next tactic:
cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        | inr h'' =>
          have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
          simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    

Proof state:
case inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
⊢ card (a' :: as) = card (remove a (a' :: as)) + 1

Next tactic:
| inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      

Proof state:
case inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
⊢ card (a' :: as) = card (remove a (a' :: as)) + 1

Next tactic:
simp only [remove, if_pos h']
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      

Proof state:
case inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      

Proof state:
case inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
x✝ : a ∈ as ∨ ¬a ∈ as
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      

Proof state:
case inl.inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
h'' : a ∈ as
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
| inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        

Proof state:
case inl.inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
h'' : a ∈ as
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
have h₃ : a' ∈ as := h' ▸ h''
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        

Proof state:
case inl.inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
h'' : a ∈ as
h₃ : a' ∈ as
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
simp [card_remove_of_mem h'', h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      

Proof state:
case inl.inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
h'' : ¬a ∈ as
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
| inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        

Proof state:
case inl.inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
h'' : ¬a ∈ as
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
have h₃ : a' ∉ as := h' ▸ h''
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        

Proof state:
case inl.inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : a = a'
h'' : ¬a ∈ as
h₃ : ¬a' ∈ as
⊢ card (a' :: as) = card (remove a as) + 1

Next tactic:
simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    

Proof state:
case inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
⊢ card (a' :: as) = card (remove a (a' :: as)) + 1

Next tactic:
| inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        | inr h'' =>
          have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
          simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        

Proof state:
case inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
⊢ card (a' :: as) = card (remove a (a' :: as)) + 1

Next tactic:
have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        

Proof state:
case inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
⊢ card (a' :: as) = card (remove a (a' :: as)) + 1

Next tactic:
simp only [remove, h', ite_false]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        

Proof state:
case inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        | inr h'' =>
          have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
          simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        

Proof state:
case inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
x✝ : a' ∈ as ∨ ¬a' ∈ as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        | inr h'' =>
          have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
          simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        

Proof state:
case inr.inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : a' ∈ as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
| inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          

Proof state:
case inr.inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : a' ∈ as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by 

Proof state:
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : a' ∈ as
⊢ a' ∈ remove a as

Next tactic:
rw [mem_remove_iff]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; 

Proof state:
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : a' ∈ as
⊢ a' ∈ as ∧ a' ≠ a

Next tactic:
exact ⟨h'', Ne.symm h'⟩
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          

Proof state:
case inr.inl
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : a' ∈ as
this : a' ∈ remove a as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        

Proof state:
case inr.inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : ¬a' ∈ as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
| inr h'' =>
          have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
          simp [h'', this, card_remove_of_mem h₃]
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        | inr h'' =>
          

Proof state:
case inr.inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : ¬a' ∈ as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
theorem card_remove_of_mem {a : α} : ∀ {as : List α}, a ∈ as → card as = card (remove a as) + 1
  | [], h => False.elim (not_mem_nil _ h)
  | (a' :: as), h => by
    cases Decidable.em (a = a') with
    | inl h' =>
      simp only [remove, if_pos h']
      cases Decidable.em (a ∈ as) with
      | inl h'' =>
        have h₃ : a' ∈ as := h' ▸ h''
        simp [card_remove_of_mem h'', h₃]
      | inr h'' =>
        have h₃ : a' ∉ as := h' ▸ h''
        simp [card_cons_of_not_mem h₃, remove_eq_of_not_mem h'']
    | inr h' =>
        have h₃ : a ∈ as := (mem_cons.1 h).resolve_left h'
        simp only [remove, h', ite_false]
        cases Decidable.em (a' ∈ as) with
        | inl h'' =>
          have : a' ∈ remove a as := by rw [mem_remove_iff]; exact ⟨h'', Ne.symm h'⟩
          simp [h'', this, card_remove_of_mem h₃]
        | inr h'' =>
          have : a' ∉ remove a as := fun h ↦ h'' (mem_of_mem_remove h)
          

Proof state:
case inr.inr
α : Type u_1
β : Sort ?u.18767
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
a a' : α
as : List α
h : a ∈ a' :: as
h' : ¬a = a'
h₃ : a ∈ as
h'' : ¬a' ∈ as
this : ¬a' ∈ remove a as
⊢ card (a' :: as) = card (a' :: remove a as) + 1

Next tactic:
simp [h'', this, card_remove_of_mem h₃]