Theorem: List.Nodup.perm_iff_eq_of_sublist
File: .lake/packages/batteries/Batteries/Data/List/Perm.lean

tactic: refine ⟨fun h => ?_, fun h => by rw [h]⟩
state_before: α : Type u_1
l₁ l₂ l : List α
d : l.Nodup
s₁ : l₁ <+ l
s₂ : l₂ <+ l
⊢ l₁ ~ l₂ ↔ l₁ = l₂
state_after: α : Type u_1
l₁ l₂ l : List α
d : l.Nodup
s₁ : l₁ <+ l
s₂ : l₂ <+ l
h : l₁ ~ l₂
⊢ l₁ = l₂

tactic: induction s₂ generalizing l₁ with simp [Nodup] at d
| slnil => exact h.eq_nil
| cons a s₂ IH =>
  match s₁ with
  | .cons _ s₁ => exact IH d.2 s₁ h
  | .cons₂ _ s₁ =>
    have := Subperm.subset ⟨_, h.symm, s₂⟩ (.head _)
    exact (d.1 _ this rfl).elim
| cons₂ a _ IH =>
  match s₁ with
  | .cons _ s₁ =>
    have := Subperm.subset ⟨_, h, s₁⟩ (.head _)
    exact (d.1 _ this rfl).elim
  | .cons₂ _ s₁ => rw [IH d.2 s₁ h.cons_inv]
state_before: α : Type u_1
l₁ l₂ l : List α
d : l.Nodup
s₁ : l₁ <+ l
s₂ : l₂ <+ l
h : l₁ ~ l₂
⊢ l₁ = l₂
state_after: no goals

tactic: rw [h]
state_before: α : Type u_1
l₁ l₂ l : List α
d : l.Nodup
s₁ : l₁ <+ l
s₂ : l₂ <+ l
h : l₁ = l₂
⊢ l₁ ~ l₂
state_after: no goals

tactic: exact h.eq_nil
state_before: case slnil
α : Type u_1
l₂ l l₁ : List α
s₁ : l₁ <+ []
h : l₁ ~ []
d : True
⊢ l₁ = []
state_after: no goals

tactic: match s₁ with
| .cons _ s₁ => exact IH d.2 s₁ h
| .cons₂ _ s₁ =>
  have := Subperm.subset ⟨_, h.symm, s₂⟩ (.head _)
  exact (d.1 _ this rfl).elim
state_before: case cons
α : Type u_1
l₂ l l₁✝ l₂✝ : List α
a : α
s₂ : l₁✝ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝ → l₁ = l₁✝
l₁ : List α
s₁ : l₁ <+ a :: l₂✝
h : l₁ ~ l₁✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
⊢ l₁ = l₁✝
state_after: no goals

tactic: exact IH d.2 s₁ h
state_before: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
s₂ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁✝ : List α
s₁✝ : l₁✝ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁ : List α
s₁ : l₁ <+ l₂✝
h : l₁ ~ l₁✝¹
⊢ l₁ = l₁✝¹
state_after: no goals

tactic: have := Subperm.subset ⟨_, h.symm, s₂⟩ (.head _)
state_before: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
s₂ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁ : List α
s₁✝ : l₁ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁✝ : List α
s₁ : l₁✝ <+ l₂✝
h : a :: l₁✝ ~ l₁✝¹
⊢ a :: l₁✝ = l₁✝¹
state_after: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
s₂ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁ : List α
s₁✝ : l₁ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁✝ : List α
s₁ : l₁✝ <+ l₂✝
h : a :: l₁✝ ~ l₁✝¹
this : a ∈ l₂✝
⊢ a :: l₁✝ = l₁✝¹

tactic: exact (d.1 _ this rfl).elim
state_before: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
s₂ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁ : List α
s₁✝ : l₁ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁✝ : List α
s₁ : l₁✝ <+ l₂✝
h : a :: l₁✝ ~ l₁✝¹
this : a ∈ l₂✝
⊢ a :: l₁✝ = l₁✝¹
state_after: no goals

tactic: match s₁ with
| .cons _ s₁ =>
  have := Subperm.subset ⟨_, h, s₁⟩ (.head _)
  exact (d.1 _ this rfl).elim
| .cons₂ _ s₁ => rw [IH d.2 s₁ h.cons_inv]
state_before: case cons₂
α : Type u_1
l₂ l l₁✝ l₂✝ : List α
a : α
a✝ : l₁✝ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝ → l₁ = l₁✝
l₁ : List α
s₁ : l₁ <+ a :: l₂✝
h : l₁ ~ a :: l₁✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
⊢ l₁ = a :: l₁✝
state_after: no goals

tactic: have := Subperm.subset ⟨_, h, s₁⟩ (.head _)
state_before: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
a✝ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁✝ : List α
s₁✝ : l₁✝ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁ : List α
s₁ : l₁ <+ l₂✝
h : l₁ ~ a :: l₁✝¹
⊢ l₁ = a :: l₁✝¹
state_after: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
a✝ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁✝ : List α
s₁✝ : l₁✝ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁ : List α
s₁ : l₁ <+ l₂✝
h : l₁ ~ a :: l₁✝¹
this : a ∈ l₂✝
⊢ l₁ = a :: l₁✝¹

tactic: exact (d.1 _ this rfl).elim
state_before: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
a✝ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁✝ : List α
s₁✝ : l₁✝ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁ : List α
s₁ : l₁ <+ l₂✝
h : l₁ ~ a :: l₁✝¹
this : a ∈ l₂✝
⊢ l₁ = a :: l₁✝¹
state_after: no goals

tactic: rw [IH d.2 s₁ h.cons_inv]
state_before: α : Type u_1
l₂ l l₁✝¹ l₂✝ : List α
a : α
a✝ : l₁✝¹ <+ l₂✝
IH : ∀ {l₁ : List α}, l₂✝.Nodup → l₁ <+ l₂✝ → l₁ ~ l₁✝¹ → l₁ = l₁✝¹
l₁ : List α
s₁✝ : l₁ <+ a :: l₂✝
d : (∀ (a' : α), a' ∈ l₂✝ → ¬a = a') ∧ Pairwise (fun x x_1 => ¬x = x_1) l₂✝
l₁✝ : List α
s₁ : l₁✝ <+ l₂✝
h : a :: l₁✝ ~ a :: l₁✝¹
⊢ a :: l₁✝ = a :: l₁✝¹
state_after: no goals