l3lab/ntp-mathlib huggingface dataset:
set_option linter.deprecated false in
theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x = x ↔ length l ≤ 1 := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  rw [formPerm_apply_nthLe _ hl, hl.nthLe_inj_iff]
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
⊢ (k + 1) % length l = k ↔ length l ≤ 1

Next tactic:
cases hn : l.length
set_option linter.deprecated false in
theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x = x ↔ length l ≤ 1 := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  rw [formPerm_apply_nthLe _ hl, hl.nthLe_inj_iff]
  cases hn : l.length
  · 

Proof state:
case intro.intro.zero
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
hn : length l = Nat.zero
⊢ (k + 1) % Nat.zero = k ↔ Nat.zero ≤ 1

Next tactic:
exact absurd k.zero_le (hk.trans_le hn.le).not_le
set_option linter.deprecated false in
theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x = x ↔ length l ≤ 1 := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  rw [formPerm_apply_nthLe _ hl, hl.nthLe_inj_iff]
  cases hn : l.length
  · exact absurd k.zero_le (hk.trans_le hn.le).not_le
  · 

Proof state:
case intro.intro.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
n✝ : ℕ
hn : length l = Nat.succ n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1

Next tactic:
rw [hn] at hk
set_option linter.deprecated false in
theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x = x ↔ length l ≤ 1 := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  rw [formPerm_apply_nthLe _ hl, hl.nthLe_inj_iff]
  cases hn : l.length
  · exact absurd k.zero_le (hk.trans_le hn.le).not_le
  · rw [hn] at hk
    

Proof state:
case intro.intro.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk✝ : k < length l
hx : nthLe l k hk✝ ∈ l
n✝ : ℕ
hk : k < Nat.succ n✝
hn : length l = Nat.succ n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1

Next tactic:
rcases (Nat.le_of_lt_succ hk).eq_or_lt with hk' | hk'
set_option linter.deprecated false in
theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x = x ↔ length l ≤ 1 := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  rw [formPerm_apply_nthLe _ hl, hl.nthLe_inj_iff]
  cases hn : l.length
  · exact absurd k.zero_le (hk.trans_le hn.le).not_le
  · rw [hn] at hk
    rcases (Nat.le_of_lt_succ hk).eq_or_lt with hk' | hk'
    · 

Proof state:
case intro.intro.succ.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk✝ : k < length l
hx : nthLe l k hk✝ ∈ l
n✝ : ℕ
hk : k < Nat.succ n✝
hn : length l = Nat.succ n✝
hk' : k = n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1

Next tactic:
simp [← hk', Nat.succ_le_succ_iff, eq_comm]
set_option linter.deprecated false in
theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x = x ↔ length l ≤ 1 := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  rw [formPerm_apply_nthLe _ hl, hl.nthLe_inj_iff]
  cases hn : l.length
  · exact absurd k.zero_le (hk.trans_le hn.le).not_le
  · rw [hn] at hk
    rcases (Nat.le_of_lt_succ hk).eq_or_lt with hk' | hk'
    · simp [← hk', Nat.succ_le_succ_iff, eq_comm]
    · 

Proof state:
case intro.intro.succ.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk✝ : k < length l
hx : nthLe l k hk✝ ∈ l
n✝ : ℕ
hk : k < Nat.succ n✝
hn : length l = Nat.succ n✝
hk' : k < n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1

Next tactic:
simpa [Nat.mod_eq_of_lt (Nat.succ_lt_succ hk'), Nat.succ_lt_succ_iff] using
        k.zero_le.trans_lt hk'
theorem formPerm_apply_mem_ne_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x ≠ x ↔ 2 ≤ l.length := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : x ∈ l
⊢ (formPerm l) x ≠ x ↔ 2 ≤ length l

Next tactic:
rw [Ne.def, formPerm_apply_mem_eq_self_iff _ hl x hx, not_le]
theorem formPerm_apply_mem_ne_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x ≠ x ↔ 2 ≤ l.length := by
  rw [Ne.def, formPerm_apply_mem_eq_self_iff _ hl x hx, not_le]
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : x ∈ l
⊢ 1 < length l ↔ 2 ≤ length l

Next tactic:
exact ⟨Nat.succ_le_of_lt, Nat.lt_of_succ_le⟩
theorem mem_of_formPerm_ne_self (l : List α) (x : α) (h : formPerm l x ≠ x) : x ∈ l := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : (formPerm l) x ≠ x
⊢ x ∈ l

Next tactic:
suffices x ∈ { y | formPerm l y ≠ y } by
    rw [← mem_toFinset]
    exact support_formPerm_le' _ this
theorem mem_of_formPerm_ne_self (l : List α) (x : α) (h : formPerm l x ≠ x) : x ∈ l := by
  suffices x ∈ { y | formPerm l y ≠ y } by
    

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : (formPerm l) x ≠ x
this : x ∈ {y | (formPerm l) y ≠ y}
⊢ x ∈ l

Next tactic:
rw [← mem_toFinset]
theorem mem_of_formPerm_ne_self (l : List α) (x : α) (h : formPerm l x ≠ x) : x ∈ l := by
  suffices x ∈ { y | formPerm l y ≠ y } by
    rw [← mem_toFinset]
    

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : (formPerm l) x ≠ x
this : x ∈ {y | (formPerm l) y ≠ y}
⊢ x ∈ toFinset l

Next tactic:
exact support_formPerm_le' _ this
theorem mem_of_formPerm_ne_self (l : List α) (x : α) (h : formPerm l x ≠ x) : x ∈ l := by
  suffices x ∈ { y | formPerm l y ≠ y } by
    rw [← mem_toFinset]
    exact support_formPerm_le' _ this
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : (formPerm l) x ≠ x
⊢ x ∈ {y | (formPerm l) y ≠ y}

Next tactic:
simpa using h
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
⊢ formPerm l = 1 ↔ length l ≤ 1

Next tactic:
cases' l with hd tl
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  cases' l with hd tl
  · 

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x : α
hl : Nodup []
⊢ formPerm [] = 1 ↔ length [] ≤ 1

Next tactic:
simp
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  cases' l with hd tl
  · simp
  · 

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ formPerm (hd :: tl) = 1 ↔ length (hd :: tl) ≤ 1

Next tactic:
rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)]
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  cases' l with hd tl
  · simp
  · rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)]
    

Proof state:
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ formPerm (hd :: tl) = 1 ↔ (formPerm (hd :: tl)) hd = hd

Next tactic:
constructor
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  cases' l with hd tl
  · simp
  · rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)]
    constructor
    · 

Proof state:
case cons.mp
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ formPerm (hd :: tl) = 1 → (formPerm (hd :: tl)) hd = hd

Next tactic:
simp (config := { contextual := true })
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  cases' l with hd tl
  · simp
  · rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)]
    constructor
    · simp (config := { contextual := true })
    · 

Proof state:
case cons.mpr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ (formPerm (hd :: tl)) hd = hd → formPerm (hd :: tl) = 1

Next tactic:
intro h
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  cases' l with hd tl
  · simp
  · rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)]
    constructor
    · simp (config := { contextual := true })
    · intro h
      

Proof state:
case cons.mpr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
h : (formPerm (hd :: tl)) hd = hd
⊢ formPerm (hd :: tl) = 1

Next tactic:
simp only [(hd :: tl).formPerm_apply_mem_eq_self_iff hl hd (mem_cons_self hd tl),
        add_le_iff_nonpos_left, length, nonpos_iff_eq_zero, length_eq_zero] at h
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
  cases' l with hd tl
  · simp
  · rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)]
    constructor
    · simp (config := { contextual := true })
    · intro h
      simp only [(hd :: tl).formPerm_apply_mem_eq_self_iff hl hd (mem_cons_self hd tl),
        add_le_iff_nonpos_left, length, nonpos_iff_eq_zero, length_eq_zero] at h
      

Proof state:
case cons.mpr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
h : tl = []
⊢ formPerm (hd :: tl) = 1

Next tactic:
simp [h]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l l' : List α
hl : Nodup l
hl' : Nodup l'
⊢ formPerm l = formPerm l' ↔ l ~r l' ∨ length l ≤ 1 ∧ length l' ≤ 1

Next tactic:
rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · 

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
⊢ formPerm [] = formPerm l' ↔ [] ~r l' ∨ length [] ≤ 1 ∧ length l' ≤ 1

Next tactic:
suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
this : length l' ≤ 1 ↔ l' = [] ∨ length l' ≤ 1
⊢ formPerm [] = formPerm l' ↔ [] ~r l' ∨ length [] ≤ 1 ∧ length l' ≤ 1

Next tactic:
simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
⊢ length l' ≤ 1 ↔ l' = [] ∨ length l' ≤ 1

Next tactic:
refine' ⟨fun h => Or.inr h, _⟩
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    

Proof state:
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
⊢ l' = [] ∨ length l' ≤ 1 → length l' ≤ 1

Next tactic:
rintro (rfl | h)
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · 

Proof state:
case nil.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl hl' : Nodup []
⊢ length [] ≤ 1

Next tactic:
simp
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · 

Proof state:
case nil.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
h : length l' ≤ 1
⊢ length l' ≤ 1

Next tactic:
exact h
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · 

Proof state:
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
⊢ formPerm [x] = formPerm l' ↔ [x] ~r l' ∨ length [x] ≤ 1 ∧ length l' ≤ 1

Next tactic:
suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
this : length l' ≤ 1 ↔ [x] ~r l' ∨ length l' ≤ 1
⊢ formPerm [x] = formPerm l' ↔ [x] ~r l' ∨ length [x] ≤ 1 ∧ length l' ≤ 1

Next tactic:
simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    

Proof state:
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
⊢ length l' ≤ 1 ↔ [x] ~r l' ∨ length l' ≤ 1

Next tactic:
refine' ⟨fun h => Or.inr h, _⟩
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    refine' ⟨fun h => Or.inr h, _⟩
    

Proof state:
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
⊢ [x] ~r l' ∨ length l' ≤ 1 → length l' ≤ 1

Next tactic:
rintro (h | h)
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (h | h)
    · 

Proof state:
case cons.nil.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
h : [x] ~r l'
⊢ length l' ≤ 1

Next tactic:
simp [← h.perm.length_eq]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (h | h)
    · simp [← h.perm.length_eq]
    · 

Proof state:
case cons.nil.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
h : length l' ≤ 1
⊢ length l' ≤ 1

Next tactic:
exact h
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (h | h)
    · simp [← h.perm.length_eq]
    · exact h
  · 

Proof state:
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l' : List α
hl' : Nodup l'
x y : α
l : List α
hl : Nodup (x :: y :: l)
⊢ formPerm (x :: y :: l) = formPerm l' ↔ (x :: y :: l) ~r l' ∨ length (x :: y :: l) ≤ 1 ∧ length l' ≤ 1

Next tactic:
rcases l' with (_ | ⟨x', _ | ⟨y', l'⟩⟩)
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (h | h)
    · simp [← h.perm.length_eq]
    · exact h
  · rcases l' with (_ | ⟨x', _ | ⟨y', l'⟩⟩)
    · 

Proof state:
case cons.cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
hl : Nodup (x :: y :: l)
hl' : Nodup []
⊢ formPerm (x :: y :: l) = formPerm [] ↔ (x :: y :: l) ~r [] ∨ length (x :: y :: l) ≤ 1 ∧ length [] ≤ 1

Next tactic:
simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (h | h)
    · simp [← h.perm.length_eq]
    · exact h
  · rcases l' with (_ | ⟨x', _ | ⟨y', l'⟩⟩)
    · simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
    · 

Proof state:
case cons.cons.cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
hl : Nodup (x :: y :: l)
x' : α
hl' : Nodup [x']
⊢ formPerm (x :: y :: l) = formPerm [x'] ↔ (x :: y :: l) ~r [x'] ∨ length (x :: y :: l) ≤ 1 ∧ length [x'] ≤ 1

Next tactic:
simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
    l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
  rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
  · suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (rfl | h)
    · simp
    · exact h
  · suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
      simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
    refine' ⟨fun h => Or.inr h, _⟩
    rintro (h | h)
    · simp [← h.perm.length_eq]
    · exact h
  · rcases l' with (_ | ⟨x', _ | ⟨y', l'⟩⟩)
    · simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
    · simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
    · 

Proof state:
case cons.cons.cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
hl : Nodup (x :: y :: l)
x' y' : α
l' : List α
hl' : Nodup (x' :: y' :: l')
⊢ formPerm (x :: y :: l) = formPerm (x' :: y' :: l') ↔
    (x :: y :: l) ~r (x' :: y' :: l') ∨ length (x :: y :: l) ≤ 1 ∧ length (x' :: y' :: l') ≤ 1

Next tactic:
simp [-formPerm_cons_cons, formPerm_ext_iff hl hl', Nat.succ_le_succ_iff]
theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) :
    (formPerm l ^ n) x ∈ l := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
⊢ (formPerm l ^ n) x ∈ l

Next tactic:
by_cases h : (l.formPerm ^ n) x = x
theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) :
    (formPerm l ^ n) x ∈ l := by
  by_cases h : (l.formPerm ^ n) x = x
  · 

Proof state:
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h : (formPerm l ^ n) x = x
⊢ (formPerm l ^ n) x ∈ l

Next tactic:
simpa [h] using hx
theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) :
    (formPerm l ^ n) x ∈ l := by
  by_cases h : (l.formPerm ^ n) x = x
  · simpa [h] using hx
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h : ¬(formPerm l ^ n) x = x
⊢ (formPerm l ^ n) x ∈ l

Next tactic:
have h : x ∈ { x | (l.formPerm ^ n) x ≠ x } := h
theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) :
    (formPerm l ^ n) x ∈ l := by
  by_cases h : (l.formPerm ^ n) x = x
  · simpa [h] using hx
  · have h : x ∈ { x | (l.formPerm ^ n) x ≠ x } := h
    

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h✝ : ¬(formPerm l ^ n) x = x
h : x ∈ {x | (formPerm l ^ n) x ≠ x}
⊢ (formPerm l ^ n) x ∈ l

Next tactic:
rw [← set_support_apply_mem] at h
theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) :
    (formPerm l ^ n) x ∈ l := by
  by_cases h : (l.formPerm ^ n) x = x
  · simpa [h] using hx
  · have h : x ∈ { x | (l.formPerm ^ n) x ≠ x } := h
    rw [← set_support_apply_mem] at h
    

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h✝ : ¬(formPerm l ^ n) x = x
h : (formPerm l ^ n) x ∈ {x | (formPerm l ^ n) x ≠ x}
⊢ (formPerm l ^ n) x ∈ l

Next tactic:
replace h := set_support_zpow_subset _ _ h