l3lab/ntp-mathlib huggingface dataset:
set_option linter.deprecated false in
theorem nodup_permutations'Aux_iff {s : List α} {x : α} : Nodup (permutations'Aux x s) ↔ x ∉ s := by
  refine' ⟨fun h => _, nodup_permutations'Aux_of_not_mem _ _⟩
  intro H
  obtain ⟨k, hk, hk'⟩ := nthLe_of_mem H
  rw [nodup_iff_nthLe_inj] at h
  suffices k = k + 1 by simp at this
  refine' h k (k + 1) _ _ _
  · simpa [Nat.lt_succ_iff] using hk.le
  · simpa using hk
  rw [nthLe_permutations'Aux, nthLe_permutations'Aux]
  have hl : length (insertNth k x s) = length (insertNth (k + 1) x s) := by
    rw [length_insertNth _ _ hk.le, length_insertNth _ _ (Nat.succ_le_of_lt hk)]
  refine' ext_nthLe hl fun n hn hn' => _
  rcases lt_trichotomy n k with (H | rfl | H)
  · rw [nthLe_insertNth_of_lt _ _ _ _ H (H.trans hk),
      nthLe_insertNth_of_lt _ _ _ _ (H.trans (Nat.lt_succ_self _))]
  · rw [nthLe_insertNth_self _ _ _ hk.le, nthLe_insertNth_of_lt _ _ _ _ (Nat.lt_succ_self _) hk,
      hk']
  · rcases (Nat.succ_le_of_lt H).eq_or_lt with (rfl | H')
    · rw [nthLe_insertNth_self _ _ _ (Nat.succ_le_of_lt hk)]
      convert hk' using 1
      exact nthLe_insertNth_add_succ _ _ _ 0 _
    · obtain ⟨m, rfl⟩ := Nat.exists_eq_add_of_lt H'
      erw [length_insertNth _ _ hk.le, Nat.succ_lt_succ_iff, Nat.succ_add] at hn
      rw [nthLe_insertNth_add_succ]
      convert nthLe_insertNth_add_succ s x k m.succ (by simpa using hn) using 2
      · simp [Nat.add_succ, Nat.succ_add]
      · 

Proof state:
case h.e'_3.h.e'_3
α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
s : List α
x : α
h :
  ∀ (i j : ℕ) (h₁ : i < length (permutations'Aux x s)) (h₂ : j < length (permutations'Aux x s)),
    nthLe (permutations'Aux x s) i h₁ = nthLe (permutations'Aux x s) j h₂ → i = j
H✝ : x ∈ s
k : ℕ
hk : k < length s
hk' : nthLe s k hk = x
hl : length (insertNth k x s) = length (insertNth (k + 1) x s)
m : ℕ
hn✝ : succ k + m + 1 < length (insertNth k x s)
hn : succ (k + m) < length s
hn' : succ k + m + 1 < length (insertNth (k + 1) x s)
H : k < succ k + m + 1
H' : succ k < succ k + m + 1
⊢ k + 1 + m = k + succ m

Next tactic:
simp [add_left_comm, add_comm]
set_option linter.deprecated false in
theorem nodup_permutations'Aux_iff {s : List α} {x : α} : Nodup (permutations'Aux x s) ↔ x ∉ s := by
  refine' ⟨fun h => _, nodup_permutations'Aux_of_not_mem _ _⟩
  intro H
  obtain ⟨k, hk, hk'⟩ := nthLe_of_mem H
  rw [nodup_iff_nthLe_inj] at h
  suffices k = k + 1 by simp at this
  refine' h k (k + 1) _ _ _
  · simpa [Nat.lt_succ_iff] using hk.le
  · simpa using hk
  rw [nthLe_permutations'Aux, nthLe_permutations'Aux]
  have hl : length (insertNth k x s) = length (insertNth (k + 1) x s) := by
    rw [length_insertNth _ _ hk.le, length_insertNth _ _ (Nat.succ_le_of_lt hk)]
  refine' ext_nthLe hl fun n hn hn' => _
  rcases lt_trichotomy n k with (H | rfl | H)
  · rw [nthLe_insertNth_of_lt _ _ _ _ H (H.trans hk),
      nthLe_insertNth_of_lt _ _ _ _ (H.trans (Nat.lt_succ_self _))]
  · rw [nthLe_insertNth_self _ _ _ hk.le, nthLe_insertNth_of_lt _ _ _ _ (Nat.lt_succ_self _) hk,
      hk']
  · rcases (Nat.succ_le_of_lt H).eq_or_lt with (rfl | H')
    · rw [nthLe_insertNth_self _ _ _ (Nat.succ_le_of_lt hk)]
      convert hk' using 1
      exact nthLe_insertNth_add_succ _ _ _ 0 _
    · obtain ⟨m, rfl⟩ := Nat.exists_eq_add_of_lt H'
      erw [length_insertNth _ _ hk.le, Nat.succ_lt_succ_iff, Nat.succ_add] at hn
      rw [nthLe_insertNth_add_succ]
      convert nthLe_insertNth_add_succ s x k m.succ (by simpa using hn) using 2
      · simp [Nat.add_succ, Nat.succ_add]
      · simp [add_left_comm, add_comm]
      · 

Proof state:
case intro.intro.refine'_3.inr.inr.inr.intro.hk'
α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
s : List α
x : α
h :
  ∀ (i j : ℕ) (h₁ : i < length (permutations'Aux x s)) (h₂ : j < length (permutations'Aux x s)),
    nthLe (permutations'Aux x s) i h₁ = nthLe (permutations'Aux x s) j h₂ → i = j
H✝ : x ∈ s
k : ℕ
hk : k < length s
hk' : nthLe s k hk = x
hl : length (insertNth k x s) = length (insertNth (k + 1) x s)
m : ℕ
hn✝ : succ k + m + 1 < length (insertNth k x s)
hn : succ (k + m) < length s
hn' : succ k + m + 1 < length (insertNth (k + 1) x s)
H : k < succ k + m + 1
H' : succ k < succ k + m + 1
⊢ k + 1 + m < length s

Next tactic:
simpa [Nat.succ_add] using hn
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  

Proof state:
α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
s : List α
hs : Nodup s
⊢ Nodup (permutations s)

Next tactic:
rw [(permutations_perm_permutations' s).nodup_iff]
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  

Proof state:
α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
s : List α
hs : Nodup s
⊢ Nodup (permutations' s)

Next tactic:
induction' hs with x l h h' IH
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · 

Proof state:
case nil
α : Type u_1
β : Type u_2
l l₁ l₂ : List α
a : α
s : List α
⊢ Nodup (permutations' [])

Next tactic:
simp
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · 

Proof state:
case cons
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
⊢ Nodup (permutations' (x :: l))

Next tactic:
rw [permutations']
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    

Proof state:
case cons
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
⊢ Nodup (List.bind (permutations' l) (permutations'Aux x))

Next tactic:
rw [nodup_bind]
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    

Proof state:
case cons
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
⊢ (∀ x_1 ∈ permutations' l, Nodup (permutations'Aux x x_1)) ∧
    Pairwise (fun a b => Disjoint (permutations'Aux x a) (permutations'Aux x b)) (permutations' l)

Next tactic:
constructor
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · 

Proof state:
case cons.left
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
⊢ ∀ x_1 ∈ permutations' l, Nodup (permutations'Aux x x_1)

Next tactic:
intro ys hy
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      

Proof state:
case cons.left
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
ys : List α
hy : ys ∈ permutations' l
⊢ Nodup (permutations'Aux x ys)

Next tactic:
rw [mem_permutations'] at hy
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      

Proof state:
case cons.left
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
ys : List α
hy : ys ~ l
⊢ Nodup (permutations'Aux x ys)

Next tactic:
rw [nodup_permutations'Aux_iff, hy.mem_iff]
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      

Proof state:
case cons.left
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
ys : List α
hy : ys ~ l
⊢ x ∉ l

Next tactic:
exact fun H => h x H rfl
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · 

Proof state:
case cons.right
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
⊢ Pairwise (fun a b => Disjoint (permutations'Aux x a) (permutations'Aux x b)) (permutations' l)

Next tactic:
refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      

Proof state:
case cons.right
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ∈ permutations' l
bs : List α
hb : bs ∈ permutations' l
H : as ≠ bs
⊢ Disjoint (permutations'Aux x as) (permutations'Aux x bs)

Next tactic:
rw [disjoint_iff_ne]
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      

Proof state:
case cons.right
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ∈ permutations' l
bs : List α
hb : bs ∈ permutations' l
H : as ≠ bs
⊢ ∀ a ∈ permutations'Aux x as, ∀ b ∈ permutations'Aux x bs, a ≠ b

Next tactic:
rintro a ha' b hb' rfl
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      

Proof state:
case cons.right
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ∈ permutations' l
bs : List α
hb : bs ∈ permutations' l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
⊢ False

Next tactic:
obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      

Proof state:
case cons.right.intro.mk
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ∈ permutations' l
bs : List α
hb : bs ∈ permutations' l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn : n < length (permutations'Aux x as)
hn' : get (permutations'Aux x as) { val := n, isLt := hn } = a
⊢ False

Next tactic:
obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
      

Proof state:
case cons.right.intro.mk.intro.mk
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ∈ permutations' l
bs : List α
hb : bs ∈ permutations' l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn : n < length (permutations'Aux x as)
hn' : get (permutations'Aux x as) { val := n, isLt := hn } = a
m : ℕ
hm : m < length (permutations'Aux x bs)
hm' : get (permutations'Aux x bs) { val := m, isLt := hm } = a
⊢ False

Next tactic:
rw [mem_permutations'] at ha hb
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
      rw [mem_permutations'] at ha hb
      

Proof state:
case cons.right.intro.mk.intro.mk
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ~ l
bs : List α
hb : bs ~ l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn : n < length (permutations'Aux x as)
hn' : get (permutations'Aux x as) { val := n, isLt := hn } = a
m : ℕ
hm : m < length (permutations'Aux x bs)
hm' : get (permutations'Aux x bs) { val := m, isLt := hm } = a
⊢ False

Next tactic:
have hl : as.length = bs.length := (ha.trans hb.symm).length_eq
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
      rw [mem_permutations'] at ha hb
      have hl : as.length = bs.length := (ha.trans hb.symm).length_eq
      

Proof state:
case cons.right.intro.mk.intro.mk
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ~ l
bs : List α
hb : bs ~ l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn : n < length (permutations'Aux x as)
hn' : get (permutations'Aux x as) { val := n, isLt := hn } = a
m : ℕ
hm : m < length (permutations'Aux x bs)
hm' : get (permutations'Aux x bs) { val := m, isLt := hm } = a
hl : length as = length bs
⊢ False

Next tactic:
simp only [Nat.lt_succ_iff, length_permutations'Aux] at hn hm
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
      rw [mem_permutations'] at ha hb
      have hl : as.length = bs.length := (ha.trans hb.symm).length_eq
      simp only [Nat.lt_succ_iff, length_permutations'Aux] at hn hm
      

Proof state:
case cons.right.intro.mk.intro.mk
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ~ l
bs : List α
hb : bs ~ l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn✝ : n < length (permutations'Aux x as)
hn' : get (permutations'Aux x as) { val := n, isLt := hn✝ } = a
m : ℕ
hm✝ : m < length (permutations'Aux x bs)
hm' : get (permutations'Aux x bs) { val := m, isLt := hm✝ } = a
hl : length as = length bs
hn : n ≤ length as
hm : m ≤ length bs
⊢ False

Next tactic:
rw [← nthLe, nthLe_permutations'Aux] at hn' hm'
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
      rw [mem_permutations'] at ha hb
      have hl : as.length = bs.length := (ha.trans hb.symm).length_eq
      simp only [Nat.lt_succ_iff, length_permutations'Aux] at hn hm
      rw [← nthLe, nthLe_permutations'Aux] at hn' hm'
      

Proof state:
case cons.right.intro.mk.intro.mk
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ~ l
bs : List α
hb : bs ~ l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn✝ : n < length (permutations'Aux x as)
hn' : insertNth n x as = a
m : ℕ
hm✝ : m < length (permutations'Aux x bs)
hm' : insertNth m x bs = a
hl : length as = length bs
hn : n ≤ length as
hm : m ≤ length bs
⊢ False

Next tactic:
have hx :
        nthLe (insertNth n x as) m (by rwa [length_insertNth _ _ hn, Nat.lt_succ_iff, hl]) = x :=
        by simp [hn', ← hm', hm]
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
      rw [mem_permutations'] at ha hb
      have hl : as.length = bs.length := (ha.trans hb.symm).length_eq
      simp only [Nat.lt_succ_iff, length_permutations'Aux] at hn hm
      rw [← nthLe, nthLe_permutations'Aux] at hn' hm'
      have hx :
        nthLe (insertNth n x as) m (by 

Proof state:
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ~ l
bs : List α
hb : bs ~ l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn✝ : n < length (permutations'Aux x as)
hn' : insertNth n x as = a
m : ℕ
hm✝ : m < length (permutations'Aux x bs)
hm' : insertNth m x bs = a
hl : length as = length bs
hn : n ≤ length as
hm : m ≤ length bs
⊢ m < length (insertNth n x as)

Next tactic:
rwa [length_insertNth _ _ hn, Nat.lt_succ_iff, hl]
set_option linter.deprecated false in
theorem nodup_permutations (s : List α) (hs : Nodup s) : Nodup s.permutations := by
  rw [(permutations_perm_permutations' s).nodup_iff]
  induction' hs with x l h h' IH
  · simp
  · rw [permutations']
    rw [nodup_bind]
    constructor
    · intro ys hy
      rw [mem_permutations'] at hy
      rw [nodup_permutations'Aux_iff, hy.mem_iff]
      exact fun H => h x H rfl
    · refine' IH.pairwise_of_forall_ne fun as ha bs hb H => _
      rw [disjoint_iff_ne]
      rintro a ha' b hb' rfl
      obtain ⟨⟨n, hn⟩, hn'⟩ := get_of_mem ha'
      obtain ⟨⟨m, hm⟩, hm'⟩ := get_of_mem hb'
      rw [mem_permutations'] at ha hb
      have hl : as.length = bs.length := (ha.trans hb.symm).length_eq
      simp only [Nat.lt_succ_iff, length_permutations'Aux] at hn hm
      rw [← nthLe, nthLe_permutations'Aux] at hn' hm'
      have hx :
        nthLe (insertNth n x as) m (by rwa [length_insertNth _ _ hn, Nat.lt_succ_iff, hl]) = x :=
        by 

Proof state:
α : Type u_1
β : Type u_2
l✝ l₁ l₂ : List α
a✝ : α
s : List α
x : α
l : List α
h : ∀ a' ∈ l, x ≠ a'
h' : Pairwise (fun x x_1 => x ≠ x_1) l
IH : Nodup (permutations' l)
as : List α
ha : as ~ l
bs : List α
hb : bs ~ l
H : as ≠ bs
a : List α
ha' : a ∈ permutations'Aux x as
hb' : a ∈ permutations'Aux x bs
n : ℕ
hn✝ : n < length (permutations'Aux x as)
hn' : insertNth n x as = a
m : ℕ
hm✝ : m < length (permutations'Aux x bs)
hm' : insertNth m x bs = a
hl : length as = length bs
hn : n ≤ length as
hm : m ≤ length bs
⊢ nthLe (insertNth n x as) m (_ : m < length (insertNth n x as)) = x

Next tactic:
simp [hn', ← hm', hm]