Theorem: List.revzip_sublists
File: Mathlib/Data/List/Sublists.lean

tactic: rw [revzip]
state_before: α : Type u
β : Type v
γ : Type w
l : List α
⊢ ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ revzip (sublists l) → l₁ ++ l₂ ~ l

tactic: induction' l using List.reverseRecOn with l' a ih
state_before: α : Type u
β : Type v
γ : Type w
l : List α
⊢ ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l) (reverse (sublists l)) → l₁ ++ l₂ ~ l

tactic: . intro l₁ l₂ h
  simp at h
  simp [h]
state_before: case H0
α : Type u
β : Type v
γ : Type w
⊢ ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists []) (reverse (sublists [])) → l₁ ++ l₂ ~ []

case H1
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
⊢ ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists (l' ++ [a])) (reverse (sublists (l' ++ [a]))) → l₁ ++ l₂ ~ l' ++ [a]

tactic: intro l₁ l₂ h
state_before: case H0
α : Type u
β : Type v
γ : Type w
⊢ ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists []) (reverse (sublists [])) → l₁ ++ l₂ ~ []

tactic: simp at h
state_before: case H0
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
h : (l₁, l₂) ∈ zip (sublists []) (reverse (sublists []))
⊢ l₁ ++ l₂ ~ []

tactic: simp [h]
state_before: case H0
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
h : l₁ = [] ∧ l₂ = []
⊢ l₁ ++ l₂ ~ []

tactic: intro l₁ l₂ h
state_before: case H1
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
⊢ ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists (l' ++ [a])) (reverse (sublists (l' ++ [a]))) → l₁ ++ l₂ ~ l' ++ [a]

tactic: rw [sublists_concat, reverse_append, zip_append, ← map_reverse, zip_map_right,
  zip_map_left] at * <;> [skip; simp]
state_before: case H1
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁ l₂ : List α
h : (l₁, l₂) ∈ zip (sublists (l' ++ [a])) (reverse (sublists (l' ++ [a])))
⊢ l₁ ++ l₂ ~ l' ++ [a]

tactic: simp only [Prod.mk.inj_iff, mem_map, mem_append, Prod.map_mk, Prod.exists] at h
state_before: case H1
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁ l₂ : List α
h :
  (l₁, l₂) ∈
    map (Prod.map id fun x => x ++ [a]) (zip (sublists l') (reverse (sublists l'))) ++
      map (Prod.map (fun x => x ++ [a]) id) (zip (sublists l') (reverse (sublists l')))
⊢ l₁ ++ l₂ ~ l' ++ [a]

tactic: rcases h with (⟨l₁, l₂', h, rfl, rfl⟩ | ⟨l₁', l₂, h, rfl, rfl⟩)
state_before: case H1
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁ l₂ : List α
h :
  (∃ a_1 b, (a_1, b) ∈ zip (sublists l') (reverse (sublists l')) ∧ id a_1 = l₁ ∧ b ++ [a] = l₂) ∨
    ∃ a_1 b, (a_1, b) ∈ zip (sublists l') (reverse (sublists l')) ∧ a_1 ++ [a] = l₁ ∧ id b = l₂
⊢ l₁ ++ l₂ ~ l' ++ [a]

tactic: rw [← append_assoc]
state_before: case H1.inl.intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁ l₂' : List α
h : (l₁, l₂') ∈ zip (sublists l') (reverse (sublists l'))
⊢ id l₁ ++ (l₂' ++ [a]) ~ l' ++ [a]

tactic: exact (ih _ _ h).append_right _
state_before: case H1.inl.intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁ l₂' : List α
h : (l₁, l₂') ∈ zip (sublists l') (reverse (sublists l'))
⊢ id l₁ ++ l₂' ++ [a] ~ l' ++ [a]

tactic: rw [append_assoc]
state_before: case H1.inr.intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁' l₂ : List α
h : (l₁', l₂) ∈ zip (sublists l') (reverse (sublists l'))
⊢ l₁' ++ [a] ++ id l₂ ~ l' ++ [a]

tactic: apply (perm_append_comm.append_left _).trans
state_before: case H1.inr.intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁' l₂ : List α
h : (l₁', l₂) ∈ zip (sublists l') (reverse (sublists l'))
⊢ l₁' ++ ([a] ++ id l₂) ~ l' ++ [a]

tactic: rw [← append_assoc]
state_before: case H1.inr.intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁' l₂ : List α
h : (l₁', l₂) ∈ zip (sublists l') (reverse (sublists l'))
⊢ l₁' ++ (id l₂ ++ [a]) ~ l' ++ [a]

tactic: exact (ih _ _ h).append_right _
state_before: case H1.inr.intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
l' : List α
a : α
ih : ∀ (l₁ l₂ : List α), (l₁, l₂) ∈ zip (sublists l') (reverse (sublists l')) → l₁ ++ l₂ ~ l'
l₁' l₂ : List α
h : (l₁', l₂) ∈ zip (sublists l') (reverse (sublists l'))
⊢ l₁' ++ id l₂ ++ [a] ~ l' ++ [a]