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

tactic: show ∀ (ts is l : List α), l ∈ permutationsAux ts is → l ~ ts ++ is
state_before: α : Type uu
β : Type vv
l₁ l₂ : List α
⊢ ∀ {ts is l : List α}, l ∈ permutationsAux ts is → l ~ ts ++ is

tactic: refine' permutationsAux.rec (by simp) _
state_before: α : Type uu
β : Type vv
l₁ l₂ : List α
⊢ ∀ (ts is l : List α), l ∈ permutationsAux ts is → l ~ ts ++ is

tactic: introv IH1 IH2 m
state_before: α : Type uu
β : Type vv
l₁ l₂ : List α
⊢ ∀ (t : α) (ts is : List α),
    (∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is) →
      (∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []) →
        ∀ (l : List α), l ∈ permutationsAux (t :: ts) is → l ~ t :: ts ++ is

tactic: rw [permutationsAux_cons, permutations, mem_foldr_permutationsAux2] at m
state_before: α : Type uu
β : Type vv
l₁ l₂ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l : List α
m : l ∈ permutationsAux (t :: ts) is
⊢ l ~ t :: ts ++ is

tactic: rcases m with (m | ⟨l₁, l₂, m, _, e⟩)
state_before: α : Type uu
β : Type vv
l₁ l₂ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l : List α
m :
  l ∈ permutationsAux ts (t :: is) ∨ ∃ l₁ l₂, l₁ ++ l₂ ∈ is :: permutationsAux is [] ∧ l₂ ≠ [] ∧ l = l₁ ++ t :: l₂ ++ ts
⊢ l ~ t :: ts ++ is

tactic: simp
state_before: α : Type uu
β : Type vv
l₁ l₂ : List α
⊢ ∀ (is l : List α), l ∈ permutationsAux [] is → l ~ [] ++ is

tactic: exact (IH1 _ m).trans perm_middle
state_before: case inl
α : Type uu
β : Type vv
l₁ l₂ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l : List α
m : l ∈ permutationsAux ts (t :: is)
⊢ l ~ t :: ts ++ is

tactic: subst e
state_before: case inr.intro.intro.intro.intro
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l l₁ l₂ : List α
m : l₁ ++ l₂ ∈ is :: permutationsAux is []
left✝ : l₂ ≠ []
e : l = l₁ ++ t :: l₂ ++ ts
⊢ l ~ t :: ts ++ is

tactic: exact ((perm_middle.trans (p.cons _)).append_right _).trans (perm_append_comm.cons _)
state_before: case inr.intro.intro.intro.intro
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l₁ l₂ : List α
m : l₁ ++ l₂ ∈ is :: permutationsAux is []
left✝ : l₂ ≠ []
p : l₁ ++ l₂ ~ is
⊢ l₁ ++ t :: l₂ ++ ts ~ t :: ts ++ is

tactic: simp [permutations] at m
state_before: α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l₁ l₂ : List α
m : l₁ ++ l₂ ∈ is :: permutationsAux is []
left✝ : l₂ ≠ []
⊢ l₁ ++ l₂ ~ is

tactic: cases' m with e m
state_before: α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l₁ l₂ : List α
left✝ : l₂ ≠ []
m : l₁ ++ l₂ = is ∨ l₁ ++ l₂ ∈ permutationsAux is []
⊢ l₁ ++ l₂ ~ is

tactic: exact is.append_nil ▸ IH2 _ m
state_before: case inr
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l₁ l₂ : List α
left✝ : l₂ ≠ []
m : l₁ ++ l₂ ∈ permutationsAux is []
⊢ l₁ ++ l₂ ~ is

tactic: simp [e]
state_before: case inl
α : Type uu
β : Type vv
l₁✝ l₂✝ : List α
t : α
ts is : List α
IH1 : ∀ (l : List α), l ∈ permutationsAux ts (t :: is) → l ~ ts ++ t :: is
IH2 : ∀ (l : List α), l ∈ permutationsAux is [] → l ~ is ++ []
l₁ l₂ : List α
left✝ : l₂ ≠ []
e : l₁ ++ l₂ = is
⊢ l₁ ++ l₂ ~ is