Theorem: List.count_permutations'Aux_self
File: Mathlib/Data/List/Perm.lean

tactic: induction' l with y l IH generalizing x
state_before: α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
l : List α
x : α
⊢ count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
state_after: case nil
α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
x : α
⊢ count [x] (permutations'Aux x []) = (takeWhile (fun x_1 => decide (x = x_1)) []).length + 1

case cons
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
⊢ count (x :: y :: l) (permutations'Aux x (y :: l)) = (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1

tactic: simp [takeWhile, count]
state_before: case nil
α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
x : α
⊢ count [x] (permutations'Aux x []) = (takeWhile (fun x_1 => decide (x = x_1)) []).length + 1
state_after: no goals

tactic: rw [permutations'Aux, DecEq_eq, count_cons_self]
state_before: case cons
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
⊢ count (x :: y :: l) (permutations'Aux x (y :: l)) = (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1
state_after: case cons
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1

tactic: by_cases hx : x = y
state_before: case cons
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1
state_after: case pos
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
hx : x = y
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1

case neg
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
hx : ¬x = y
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1

tactic: subst hx
state_before: case pos
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
hx : x = y
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1
state_after: case pos
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
⊢ count (x :: x :: l) (map (cons x) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (x :: l)).length + 1

tactic: simpa [takeWhile, Nat.succ_inj', DecEq_eq] using IH _
state_before: case pos
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
⊢ count (x :: x :: l) (map (cons x) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (x :: l)).length + 1
state_after: no goals

tactic: rw [takeWhile]
state_before: case neg
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
hx : ¬x = y
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (takeWhile (fun x_1 => decide (x = x_1)) (y :: l)).length + 1
state_after: case neg
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
hx : ¬x = y
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (match decide (x = y) with
        | true => y :: takeWhile (fun x_1 => decide (x = x_1)) l
        | false => []).length +
      1

tactic: simp only [mem_map, cons.injEq, Ne.symm hx, false_and, and_false, exists_false,
  not_false_iff, count_eq_zero_of_not_mem, Nat.zero_add, hx, decide_False, length_nil]
state_before: case neg
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
inst✝ : DecidableEq α
y : α
l : List α
IH : ∀ (x : α), count (x :: l) (permutations'Aux x l) = (takeWhile (fun x_1 => decide (x = x_1)) l).length + 1
x : α
hx : ¬x = y
⊢ count (x :: y :: l) (map (cons y) (permutations'Aux x l)) + 1 =
    (match decide (x = y) with
        | true => y :: takeWhile (fun x_1 => decide (x = x_1)) l
        | false => []).length +
      1
state_after: no goals