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

Proof steps:
state_before: α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
⊢ ∀ {ts is l : List α}, l ~ is ++ ts → (∃ is', ∃ (_ : is' ~ is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux is
state_after: α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
⊢ ∀ (ts is l : List α), l ~ is ++ ts → (∃ is', ∃ (_ : is' ~ is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux is
tactic: show ∀ (ts is l : List α),
      l ~ is ++ ts → (∃ (is' : _) (_ : is' ~ is), l = is' ++ ts) ∨ l ∈ permutationsAux ts is
state_before: α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
⊢ ∀ (ts is l : List α), l ~ is ++ ts → (∃ is', ∃ (_ : is' ~ is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux is
state_after: α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
⊢ ∀ (t : α) (ts is : List α),
    (∀ (l : List α),
        l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)) →
      (∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []) →
        ∀ (l : List α),
          l ~ is ++ t :: ts → (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨ l ∈ (t :: ts).permutationsAux is
tactic: refine permutationsAux.rec (by simp) ?_
state_before: α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
⊢ ∀ (t : α) (ts is : List α),
    (∀ (l : List α),
        l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)) →
      (∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []) →
        ∀ (l : List α),
          l ~ is ++ t :: ts → (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨ l ∈ (t :: ts).permutationsAux is
state_after: α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a t : α
ts is : List α
IH1 :
  ∀ (l : List α), l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)
IH2 : ∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []
l : List α
p : l ~ is ++ t :: ts
⊢ (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨ l ∈ (t :: ts).permutationsAux is
tactic: intro t ts is IH1 IH2 l p
state_before: α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a t : α
ts is : List α
IH1 :
  ∀ (l : List α), l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)
IH2 : ∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []
l : List α
p : l ~ is ++ t :: ts
⊢ (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨ l ∈ (t :: ts).permutationsAux is
state_after: α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a t : α
ts is : List α
IH1 :
  ∀ (l : List α), l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)
IH2 : ∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []
l : List α
p : l ~ is ++ t :: ts
⊢ (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨
    l ∈ ts.permutationsAux (t :: is) ∨ ∃ l₁ l₂, l₁ ++ l₂ ∈ is.permutations ∧ l₂ ≠ [] ∧ l = l₁ ++ t :: l₂ ++ ts
tactic: rw [permutationsAux_cons, mem_foldr_permutationsAux2]
state_before: α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a t : α
ts is : List α
IH1 :
  ∀ (l : List α), l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)
IH2 : ∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []
l : List α
p : l ~ is ++ t :: ts
⊢ (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨
    l ∈ ts.permutationsAux (t :: is) ∨ ∃ l₁ l₂, l₁ ++ l₂ ∈ is.permutations ∧ l₂ ≠ [] ∧ l = l₁ ++ t :: l₂ ++ ts
state_after: case inl.intro.intro
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a t : α
ts is : List α
IH1 :
  ∀ (l : List α), l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)
IH2 : ∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []
l : List α
p : l ~ is ++ t :: ts
is' : List α
p' : is' ~ t :: is
e : l = is' ++ ts
⊢ (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨
    l ∈ ts.permutationsAux (t :: is) ∨ ∃ l₁ l₂, l₁ ++ l₂ ∈ is.permutations ∧ l₂ ≠ [] ∧ l = l₁ ++ t :: l₂ ++ ts

case inr
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a t : α
ts is : List α
IH1 :
  ∀ (l : List α), l ~ t :: is ++ ts → (∃ is', ∃ (_ : is' ~ t :: is), l = is' ++ ts) ∨ l ∈ ts.permutationsAux (t :: is)
IH2 : ∀ (l : List α), l ~ [] ++ is → (∃ is', ∃ (_ : is' ~ []), l = is' ++ is) ∨ l ∈ is.permutationsAux []
l : List α
p : l ~ is ++ t :: ts
m : l ∈ ts.permutationsAux (t :: is)
⊢ (∃ is', ∃ (_ : is' ~ is), l = is' ++ t :: ts) ∨
    l ∈ ts.permutationsAux (t :: is) ∨ ∃ l₁ l₂, l₁ ++ l₂ ∈ is.permutations ∧ l₂ ≠ [] ∧ l = l₁ ++ t :: l₂ ++ ts
tactic: rcases IH1 _ (p.trans perm_middle) with (⟨is', p', e⟩ | m)