Theorem: List.perm_iff_count
File: Mathlib/Data/List/Perm.lean

tactic: induction' l₁ with a l₁ IH generalizing l₂
state_before: α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
inst✝ : DecidableEq α
l₁ l₂ : List α
H : ∀ (a : α), count a l₁ = count a l₂
⊢ l₁ ~ l₂

tactic: cases' l₂ with b l₂
state_before: case nil
α : Type uu
β : Type vv
l₁✝ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁ = count a l₂✝
l₂ : List α
H : ∀ (a : α), count a [] = count a l₂
⊢ [] ~ l₂

tactic: specialize H b
state_before: case nil.cons
α : Type uu
β : Type vv
l₁✝ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁ = count a l₂✝
b : α
l₂ : List α
H : ∀ (a : α), count a [] = count a (b :: l₂)
⊢ [] ~ b :: l₂

tactic: simp at H
state_before: case nil.cons
α : Type uu
β : Type vv
l₁✝ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁ = count a l₂✝
b : α
l₂ : List α
H : count b [] = count b (b :: l₂)
⊢ [] ~ b :: l₂

tactic: contradiction
state_before: case nil.cons
α : Type uu
β : Type vv
l₁✝ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁ = count a l₂✝
b : α
l₂ : List α
H : 0 = count b l₂ + 1
⊢ [] ~ b :: l₂

tactic: rfl
state_before: case nil.nil
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
inst✝ : DecidableEq α
l₁ l₂ : List α
H✝ : ∀ (a : α), count a l₁ = count a l₂
H : ∀ (a : α), count a [] = count a []
⊢ [] ~ []

tactic: have : a ∈ l₂ := count_pos.1 (by rw [← H]; simp)
state_before: case cons
α : Type uu
β : Type vv
l₁✝¹ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁✝ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁✝ = count a l₂✝
a : α
l₁ : List α
IH : ∀ {l₂ : List α}, (∀ (a : α), count a l₁ = count a l₂) → l₁ ~ l₂
l₂ : List α
H : ∀ (a_1 : α), count a_1 (a :: l₁) = count a_1 l₂
⊢ a :: l₁ ~ l₂

tactic: refine' ((IH fun b => _).cons a).trans (perm_cons_erase this).symm
state_before: case cons
α : Type uu
β : Type vv
l₁✝¹ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁✝ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁✝ = count a l₂✝
a : α
l₁ : List α
IH : ∀ {l₂ : List α}, (∀ (a : α), count a l₁ = count a l₂) → l₁ ~ l₂
l₂ : List α
H : ∀ (a_1 : α), count a_1 (a :: l₁) = count a_1 l₂
this : a ∈ l₂
⊢ a :: l₁ ~ l₂

tactic: specialize H b
state_before: case cons
α : Type uu
β : Type vv
l₁✝¹ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁✝ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁✝ = count a l₂✝
a : α
l₁ : List α
IH : ∀ {l₂ : List α}, (∀ (a : α), count a l₁ = count a l₂) → l₁ ~ l₂
l₂ : List α
H : ∀ (a_1 : α), count a_1 (a :: l₁) = count a_1 l₂
this : a ∈ l₂
b : α
⊢ count b l₁ = count b (List.erase l₂ a)

tactic: rw [(perm_cons_erase this).count_eq] at H
state_before: case cons
α : Type uu
β : Type vv
l₁✝¹ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁✝ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁✝ = count a l₂✝
a : α
l₁ : List α
IH : ∀ {l₂ : List α}, (∀ (a : α), count a l₁ = count a l₂) → l₁ ~ l₂
l₂ : List α
this : a ∈ l₂
b : α
H : count b (a :: l₁) = count b l₂
⊢ count b l₁ = count b (List.erase l₂ a)

tactic: by_cases h : b = a <;> simpa [h] using H
state_before: case cons
α : Type uu
β : Type vv
l₁✝¹ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁✝ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁✝ = count a l₂✝
a : α
l₁ : List α
IH : ∀ {l₂ : List α}, (∀ (a : α), count a l₁ = count a l₂) → l₁ ~ l₂
l₂ : List α
this : a ∈ l₂
b : α
H : count b (a :: l₁) = count b (a :: List.erase l₂ a)
⊢ count b l₁ = count b (List.erase l₂ a)

tactic: rw [← H]
state_before: α : Type uu
β : Type vv
l₁✝¹ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁✝ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁✝ = count a l₂✝
a : α
l₁ : List α
IH : ∀ {l₂ : List α}, (∀ (a : α), count a l₁ = count a l₂) → l₁ ~ l₂
l₂ : List α
H : ∀ (a_1 : α), count a_1 (a :: l₁) = count a_1 l₂
⊢ 0 < count a l₂

tactic: simp
state_before: α : Type uu
β : Type vv
l₁✝¹ l₂✝¹ : List α
inst✝ : DecidableEq α
l₁✝ l₂✝ : List α
H✝ : ∀ (a : α), count a l₁✝ = count a l₂✝
a : α
l₁ : List α
IH : ∀ {l₂ : List α}, (∀ (a : α), count a l₁ = count a l₂) → l₁ ~ l₂
l₂ : List α
H : ∀ (a_1 : α), count a_1 (a :: l₁) = count a_1 l₂
⊢ 0 < count a (a :: l₁)