l3lab/ntp-mathlib huggingface dataset:
theorem perm_lookmap (f : α → Option α) {l₁ l₂ : List α}
    (H : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁) (p : l₁ ~ l₂) :
    lookmap f l₁ ~ lookmap f l₂ := by
  induction' p with a l₁ l₂ p IH a b l l₁ l₂ l₃ p₁ _ IH₁ IH₂; · simp
  · cases h : f a
    · simp [h]
      exact IH (pairwise_cons.1 H).2
    · simp [lookmap_cons_some _ _ h, p]
  · cases' h₁ : f a with c <;> cases' h₂ : f b with d
    · simp [h₁, h₂]
      apply swap
    · simp [h₁, lookmap_cons_some _ _ h₂]
      apply swap
    · simp [lookmap_cons_some _ _ h₁, h₂]
      apply swap
    · simp [lookmap_cons_some _ _ h₁, lookmap_cons_some _ _ h₂]
      rcases (pairwise_cons.1 H).1 _ (mem_cons.2 (Or.inl rfl)) _ h₂ _ h₁ with ⟨rfl, rfl⟩
      exact Perm.refl _
  · refine' (IH₁ H).trans (IH₂ ((p₁.pairwise_iff _).1 H))
    

Proof state:
case trans
α : Type u_1
β : Type u_2
l l₁✝¹ l₂✝¹ : List α
a : α
f : α → Option α
l₁✝ l₂✝ l₁ l₂ l₃ : List α
p₁ : l₁ ~ l₂
a✝ : l₂ ~ l₃
IH₁ : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁ → lookmap f l₁ ~ lookmap f l₂
IH₂ : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₂ → lookmap f l₂ ~ lookmap f l₃
H : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁
⊢ ∀ {x y : α}, (∀ c ∈ f x, ∀ d ∈ f y, x = y ∧ c = d) → ∀ c ∈ f y, ∀ d ∈ f x, y = x ∧ c = d

Next tactic:
intro x y h c hc d hd
theorem perm_lookmap (f : α → Option α) {l₁ l₂ : List α}
    (H : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁) (p : l₁ ~ l₂) :
    lookmap f l₁ ~ lookmap f l₂ := by
  induction' p with a l₁ l₂ p IH a b l l₁ l₂ l₃ p₁ _ IH₁ IH₂; · simp
  · cases h : f a
    · simp [h]
      exact IH (pairwise_cons.1 H).2
    · simp [lookmap_cons_some _ _ h, p]
  · cases' h₁ : f a with c <;> cases' h₂ : f b with d
    · simp [h₁, h₂]
      apply swap
    · simp [h₁, lookmap_cons_some _ _ h₂]
      apply swap
    · simp [lookmap_cons_some _ _ h₁, h₂]
      apply swap
    · simp [lookmap_cons_some _ _ h₁, lookmap_cons_some _ _ h₂]
      rcases (pairwise_cons.1 H).1 _ (mem_cons.2 (Or.inl rfl)) _ h₂ _ h₁ with ⟨rfl, rfl⟩
      exact Perm.refl _
  · refine' (IH₁ H).trans (IH₂ ((p₁.pairwise_iff _).1 H))
    intro x y h c hc d hd
    

Proof state:
case trans
α : Type u_1
β : Type u_2
l l₁✝¹ l₂✝¹ : List α
a : α
f : α → Option α
l₁✝ l₂✝ l₁ l₂ l₃ : List α
p₁ : l₁ ~ l₂
a✝ : l₂ ~ l₃
IH₁ : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁ → lookmap f l₁ ~ lookmap f l₂
IH₂ : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₂ → lookmap f l₂ ~ lookmap f l₃
H : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁
x y : α
h : ∀ c ∈ f x, ∀ d ∈ f y, x = y ∧ c = d
c : α
hc : c ∈ f y
d : α
hd : d ∈ f x
⊢ y = x ∧ c = d

Next tactic:
rw [@eq_comm _ y, @eq_comm _ c]
theorem perm_lookmap (f : α → Option α) {l₁ l₂ : List α}
    (H : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁) (p : l₁ ~ l₂) :
    lookmap f l₁ ~ lookmap f l₂ := by
  induction' p with a l₁ l₂ p IH a b l l₁ l₂ l₃ p₁ _ IH₁ IH₂; · simp
  · cases h : f a
    · simp [h]
      exact IH (pairwise_cons.1 H).2
    · simp [lookmap_cons_some _ _ h, p]
  · cases' h₁ : f a with c <;> cases' h₂ : f b with d
    · simp [h₁, h₂]
      apply swap
    · simp [h₁, lookmap_cons_some _ _ h₂]
      apply swap
    · simp [lookmap_cons_some _ _ h₁, h₂]
      apply swap
    · simp [lookmap_cons_some _ _ h₁, lookmap_cons_some _ _ h₂]
      rcases (pairwise_cons.1 H).1 _ (mem_cons.2 (Or.inl rfl)) _ h₂ _ h₁ with ⟨rfl, rfl⟩
      exact Perm.refl _
  · refine' (IH₁ H).trans (IH₂ ((p₁.pairwise_iff _).1 H))
    intro x y h c hc d hd
    rw [@eq_comm _ y, @eq_comm _ c]
    

Proof state:
case trans
α : Type u_1
β : Type u_2
l l₁✝¹ l₂✝¹ : List α
a : α
f : α → Option α
l₁✝ l₂✝ l₁ l₂ l₃ : List α
p₁ : l₁ ~ l₂
a✝ : l₂ ~ l₃
IH₁ : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁ → lookmap f l₁ ~ lookmap f l₂
IH₂ : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₂ → lookmap f l₂ ~ lookmap f l₃
H : Pairwise (fun a b => ∀ c ∈ f a, ∀ d ∈ f b, a = b ∧ c = d) l₁
x y : α
h : ∀ c ∈ f x, ∀ d ∈ f y, x = y ∧ c = d
c : α
hc : c ∈ f y
d : α
hd : d ∈ f x
⊢ x = y ∧ d = c

Next tactic:
apply h d hd c hc
@[deprecated Perm.eraseP]
theorem Perm.erasep (f : α → Prop) [DecidablePred f] {l₁ l₂ : List α}
    (H : Pairwise (fun a b => f a → f b → False) l₁) (p : l₁ ~ l₂) :
    List.eraseP f l₁ ~ List.eraseP f l₂ :=
  p.eraseP f (by 

Proof state:
α : Type u_1
β : Type u_2
l l₁✝ l₂✝ : List α
a : α
f : α → Prop
inst✝ : DecidablePred f
l₁ l₂ : List α
H : Pairwise (fun a b => f a → f b → False) l₁
p : l₁ ~ l₂
⊢ Pairwise (fun a b => decide (f a) = true → decide (f b) = true → False) l₁

Next tactic:
simp [H]
theorem Perm.take_inter {α : Type*} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : xs.take n ~ ys.inter (xs.take n) := by
  

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
⊢ take n xs ~ List.inter ys (take n xs)

Next tactic:
simp only [List.inter]
theorem Perm.take_inter {α : Type*} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : xs.take n ~ ys.inter (xs.take n) := by
  simp only [List.inter]
  

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
⊢ take n xs ~ List.filter (fun x => decide (x ∈ take n xs)) ys

Next tactic:
exact Perm.trans (show xs.take n ~ xs.filter (· ∈ xs.take n) by
      conv_lhs => rw [Nodup.take_eq_filter_mem ((Perm.nodup_iff h).2 h')])
    (Perm.filter _ h)
theorem Perm.take_inter {α : Type*} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : xs.take n ~ ys.inter (xs.take n) := by
  simp only [List.inter]
  exact Perm.trans (show xs.take n ~ xs.filter (· ∈ xs.take n) by
      

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
⊢ take n xs ~ List.filter (fun x => decide (x ∈ take n xs)) xs

Next tactic:
conv_lhs => rw [Nodup.take_eq_filter_mem ((Perm.nodup_iff h).2 h')]
theorem Perm.take_inter {α : Type*} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : xs.take n ~ ys.inter (xs.take n) := by
  simp only [List.inter]
  exact Perm.trans (show xs.take n ~ xs.filter (· ∈ xs.take n) by
      conv_lhs => 

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
| take n xs

Next tactic:
rw [Nodup.take_eq_filter_mem ((Perm.nodup_iff h).2 h')]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
by_cases h'' : n ≤ xs.length
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · 

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
let n' := xs.length - n
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
⊢ n = length xs - n'

Next tactic:
rwa [tsub_tsub_cancel_of_le]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
have h₁ : n' ≤ xs.length := by apply tsub_le_self
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by 

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
⊢ n' ≤ length xs

Next tactic:
apply tsub_le_self
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
⊢ drop n xs = reverse (take n' (reverse xs))

Next tactic:
rw [reverse_take _ h₁, h₀, reverse_reverse]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
h₂ : drop n xs = reverse (take n' (reverse xs))
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
rw [h₂]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
h₂ : drop n xs = reverse (take n' (reverse xs))
⊢ reverse (take n' (reverse xs)) ~ List.inter ys (reverse (take n' (reverse xs)))

Next tactic:
apply (reverse_perm _).trans
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
h₂ : drop n xs = reverse (take n' (reverse xs))
⊢ take n' (reverse xs) ~ List.inter ys (reverse (take n' (reverse xs)))

Next tactic:
rw [inter_reverse]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    

Proof state:
case pos
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
h₂ : drop n xs = reverse (take n' (reverse xs))
⊢ take n' (reverse xs) ~ List.inter ys (take n' (reverse xs))

Next tactic:
apply Perm.take_inter _ _ h'
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    apply Perm.take_inter _ _ h'
    

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
h₂ : drop n xs = reverse (take n' (reverse xs))
⊢ reverse xs ~ ys

Next tactic:
apply (reverse_perm _).trans
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    apply Perm.take_inter _ _ h'
    apply (reverse_perm _).trans; 

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : n ≤ length xs
n' : ℕ := length xs - n
h₀ : n = length xs - n'
h₁ : n' ≤ length xs
h₂ : drop n xs = reverse (take n' (reverse xs))
⊢ xs ~ ys

Next tactic:
assumption
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    apply Perm.take_inter _ _ h'
    apply (reverse_perm _).trans; assumption
  · 

Proof state:
case neg
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : ¬n ≤ length xs
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
have : drop n xs = [] := by
      apply eq_nil_of_length_eq_zero
      rw [length_drop, tsub_eq_zero_iff_le]
      apply le_of_not_ge h''
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    apply Perm.take_inter _ _ h'
    apply (reverse_perm _).trans; assumption
  · have : drop n xs = [] := by
      

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : ¬n ≤ length xs
⊢ drop n xs = []

Next tactic:
apply eq_nil_of_length_eq_zero
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    apply Perm.take_inter _ _ h'
    apply (reverse_perm _).trans; assumption
  · have : drop n xs = [] := by
      apply eq_nil_of_length_eq_zero
      

Proof state:
case x
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : ¬n ≤ length xs
⊢ length (drop n xs) = 0

Next tactic:
rw [length_drop, tsub_eq_zero_iff_le]
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    apply Perm.take_inter _ _ h'
    apply (reverse_perm _).trans; assumption
  · have : drop n xs = [] := by
      apply eq_nil_of_length_eq_zero
      rw [length_drop, tsub_eq_zero_iff_le]
      

Proof state:
case x
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : ¬n ≤ length xs
⊢ length xs ≤ n

Next tactic:
apply le_of_not_ge h''
theorem Perm.drop_inter {α} [DecidableEq α] {xs ys : List α} (n : ℕ) (h : xs ~ ys) (h' : ys.Nodup) :
    xs.drop n ~ ys.inter (xs.drop n) := by
  by_cases h'' : n ≤ xs.length
  · let n' := xs.length - n
    have h₀ : n = xs.length - n' := by
      rwa [tsub_tsub_cancel_of_le]
    have h₁ : n' ≤ xs.length := by apply tsub_le_self
    have h₂ : xs.drop n = (xs.reverse.take n').reverse := by
      rw [reverse_take _ h₁, h₀, reverse_reverse]
    rw [h₂]
    apply (reverse_perm _).trans
    rw [inter_reverse]
    apply Perm.take_inter _ _ h'
    apply (reverse_perm _).trans; assumption
  · have : drop n xs = [] := by
      apply eq_nil_of_length_eq_zero
      rw [length_drop, tsub_eq_zero_iff_le]
      apply le_of_not_ge h''
    

Proof state:
case neg
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n : ℕ
h : xs ~ ys
h' : Nodup ys
h'' : ¬n ≤ length xs
this : drop n xs = []
⊢ drop n xs ~ List.inter ys (drop n xs)

Next tactic:
simp [this, List.inter]
theorem Perm.dropSlice_inter {α} [DecidableEq α] {xs ys : List α} (n m : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : List.dropSlice n m xs ~ ys ∩ List.dropSlice n m xs := by
  

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n m : ℕ
h : xs ~ ys
h' : Nodup ys
⊢ dropSlice n m xs ~ ys ∩ dropSlice n m xs

Next tactic:
simp only [dropSlice_eq]
theorem Perm.dropSlice_inter {α} [DecidableEq α] {xs ys : List α} (n m : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : List.dropSlice n m xs ~ ys ∩ List.dropSlice n m xs := by
  simp only [dropSlice_eq]
  

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n m : ℕ
h : xs ~ ys
h' : Nodup ys
⊢ take n xs ++ drop (n + m) xs ~ ys ∩ (take n xs ++ drop (n + m) xs)

Next tactic:
have : n ≤ n + m := Nat.le_add_right _ _
theorem Perm.dropSlice_inter {α} [DecidableEq α] {xs ys : List α} (n m : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : List.dropSlice n m xs ~ ys ∩ List.dropSlice n m xs := by
  simp only [dropSlice_eq]
  have : n ≤ n + m := Nat.le_add_right _ _
  

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n m : ℕ
h : xs ~ ys
h' : Nodup ys
this : n ≤ n + m
⊢ take n xs ++ drop (n + m) xs ~ ys ∩ (take n xs ++ drop (n + m) xs)

Next tactic:
have h₂ := h.nodup_iff.2 h'
theorem Perm.dropSlice_inter {α} [DecidableEq α] {xs ys : List α} (n m : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : List.dropSlice n m xs ~ ys ∩ List.dropSlice n m xs := by
  simp only [dropSlice_eq]
  have : n ≤ n + m := Nat.le_add_right _ _
  have h₂ := h.nodup_iff.2 h'
  

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n m : ℕ
h : xs ~ ys
h' : Nodup ys
this : n ≤ n + m
h₂ : Nodup xs
⊢ take n xs ++ drop (n + m) xs ~ ys ∩ (take n xs ++ drop (n + m) xs)

Next tactic:
apply Perm.trans _ (Perm.inter_append _).symm
theorem Perm.dropSlice_inter {α} [DecidableEq α] {xs ys : List α} (n m : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : List.dropSlice n m xs ~ ys ∩ List.dropSlice n m xs := by
  simp only [dropSlice_eq]
  have : n ≤ n + m := Nat.le_add_right _ _
  have h₂ := h.nodup_iff.2 h'
  apply Perm.trans _ (Perm.inter_append _).symm
  · 

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n m : ℕ
h : xs ~ ys
h' : Nodup ys
this : n ≤ n + m
h₂ : Nodup xs
⊢ take n xs ++ drop (n + m) xs ~ ys ∩ take n xs ++ ys ∩ drop (n + m) xs

Next tactic:
exact Perm.append (Perm.take_inter _ h h') (Perm.drop_inter _ h h')
theorem Perm.dropSlice_inter {α} [DecidableEq α] {xs ys : List α} (n m : ℕ) (h : xs ~ ys)
    (h' : ys.Nodup) : List.dropSlice n m xs ~ ys ∩ List.dropSlice n m xs := by
  simp only [dropSlice_eq]
  have : n ≤ n + m := Nat.le_add_right _ _
  have h₂ := h.nodup_iff.2 h'
  apply Perm.trans _ (Perm.inter_append _).symm
  · exact Perm.append (Perm.take_inter _ h h') (Perm.drop_inter _ h h')
  · 

Proof state:
α✝ : Type u_1
β : Type u_2
l l₁ l₂ : List α✝
a : α✝
α : Type u_3
inst✝ : DecidableEq α
xs ys : List α
n m : ℕ
h : xs ~ ys
h' : Nodup ys
this : n ≤ n + m
h₂ : Nodup xs
⊢ Disjoint (take n xs) (drop (n + m) xs)

Next tactic:
exact disjoint_take_drop h₂ this