File: Mathlib/GroupTheory/Perm/List.lean

full_name: List.formPerm
code: /-- A list `l : List α` can be interpreted as an `Equiv.Perm α` where each element in the list
is permuted to the next one, defined as `formPerm`. When we have that `Nodup l`,
we prove that `Equiv.Perm.support (formPerm l) = l.toFinset`, and that
`formPerm l` is rotationally invariant, in `formPerm_rotate`.
-/
def formPerm : Equiv.Perm α 
goal: Equiv.Perm α

full_name: List.formPerm_nil
code: @[simp]
theorem formPerm_nil : formPerm ([] : List α) = 1 
goal: [].formPerm = 1

full_name: List.formPerm_singleton
code: @[simp]
theorem formPerm_singleton (x : α) : formPerm [x] = 1 
goal: [x].formPerm = 1

full_name: List.formPerm_cons_cons
code: @[simp]
theorem formPerm_cons_cons (x y : α) (l : List α) :
    formPerm (x :: y :: l) = swap x y * formPerm (y :: l) 
goal: (x :: y :: l).formPerm = Equiv.swap x y * (y :: l).formPerm

full_name: List.formPerm_pair
code: theorem formPerm_pair (x y : α) : formPerm [x, y] = swap x y 
goal: [x, y].formPerm = Equiv.swap x y

full_name: List.mem_or_mem_of_zipWith_swap_prod_ne
code: theorem mem_or_mem_of_zipWith_swap_prod_ne : ∀ {l l' : List α} {x : α},
    (zipWith swap l l').prod x ≠ x → x ∈ l ∨ x ∈ l'
  
goal: (List.zipWith Equiv.swap l l').prod x ≠ x → x ∈ l ∨ x ∈ l'

full_name: List.zipWith_swap_prod_support'
code: theorem zipWith_swap_prod_support' (l l' : List α) :
    { x | (zipWith swap l l').prod x ≠ x } ≤ l.toFinset ⊔ l'.toFinset 
goal: {x | (List.zipWith Equiv.swap l l').prod x ≠ x} ≤ ↑(l.toFinset ⊔ l'.toFinset)

full_name: List.zipWith_swap_prod_support
code: theorem zipWith_swap_prod_support [Fintype α] (l l' : List α) :
    (zipWith swap l l').prod.support ≤ l.toFinset ⊔ l'.toFinset 
goal: (List.zipWith Equiv.swap l l').prod.support ≤ l.toFinset ⊔ l'.toFinset

full_name: List.support_formPerm_le'
code: theorem support_formPerm_le' : { x | formPerm l x ≠ x } ≤ l.toFinset 
goal: {x | l.formPerm x ≠ x} ≤ ↑l.toFinset

full_name: List.support_formPerm_le
code: theorem support_formPerm_le [Fintype α] : support (formPerm l) ≤ l.toFinset 
goal: l.formPerm.support ≤ l.toFinset

full_name: List.mem_of_formPerm_apply_ne
code: theorem mem_of_formPerm_apply_ne (h : l.formPerm x ≠ x) : x ∈ l 
goal: x ∈ l

full_name: List.formPerm_apply_of_not_mem
code: theorem formPerm_apply_of_not_mem (h : x ∉ l) : formPerm l x = x 
goal: l.formPerm x = x

full_name: List.formPerm_apply_mem_of_mem
code: theorem formPerm_apply_mem_of_mem (h : x ∈ l) : formPerm l x ∈ l 
goal: l.formPerm x ∈ l

full_name: List.mem_of_formPerm_apply_mem
code: theorem mem_of_formPerm_apply_mem (h : l.formPerm x ∈ l) : x ∈ l 
goal: x ∈ l

full_name: List.formPerm_mem_iff_mem
code: @[simp]
theorem formPerm_mem_iff_mem : l.formPerm x ∈ l ↔ x ∈ l 
goal: l.formPerm x ∈ l ↔ x ∈ l

full_name: List.formPerm_cons_concat_apply_last
code: @[simp]
theorem formPerm_cons_concat_apply_last (x y : α) (xs : List α) :
    formPerm (x :: (xs ++ [y])) y = x 
goal: (x :: (xs ++ [y])).formPerm y = x

full_name: List.formPerm_apply_getLast
code: @[simp]
theorem formPerm_apply_getLast (x : α) (xs : List α) :
    formPerm (x :: xs) ((x :: xs).getLast (cons_ne_nil x xs)) = x 
goal: (x :: xs).formPerm ((x :: xs).getLast ⋯) = x

full_name: List.formPerm_apply_getElem_length
code: @[simp]
theorem formPerm_apply_getElem_length (x : α) (xs : List α) :
    formPerm (x :: xs) ((x :: xs)[xs.length]) = x 
goal: (x :: xs).formPerm (x :: xs)[xs.length] = x

full_name: List.formPerm_apply_get_length
code: theorem formPerm_apply_get_length (x : α) (xs : List α) :
    formPerm (x :: xs) ((x :: xs).get (Fin.mk xs.length (by simp))) = x 
goal: (x :: xs).formPerm ((x :: xs).get ⟨xs.length, ⋯⟩) = x

full_name: List.formPerm_apply_nthLe_length
code: @[simp, deprecated formPerm_apply_get_length (since := "2024-05-30")]
theorem formPerm_apply_nthLe_length (x : α) (xs : List α) :
    formPerm (x :: xs) ((x :: xs).nthLe xs.length (by simp)) = x 
goal: (x :: xs).formPerm ((x :: xs).nthLe xs.length ⋯) = x

full_name: List.formPerm_apply_head
code: theorem formPerm_apply_head (x y : α) (xs : List α) (h : Nodup (x :: y :: xs)) :
    formPerm (x :: y :: xs) x = y 
goal: (x :: y :: xs).formPerm x = y

full_name: List.formPerm_apply_getElem_zero
code: theorem formPerm_apply_getElem_zero (l : List α) (h : Nodup l) (hl : 1 < l.length) :
    formPerm l l[0] = l[1] 
goal: l.formPerm l[0] = l[1]

full_name: List.formPerm_apply_get_zero
code: theorem formPerm_apply_get_zero (l : List α) (h : Nodup l) (hl : 1 < l.length) :
    formPerm l (l.get (Fin.mk 0 (by omega))) = l.get (Fin.mk 1 hl) 
goal: l.formPerm (l.get ⟨0, ⋯⟩) = l.get ⟨1, hl⟩

full_name: List.formPerm_apply_nthLe_zero
code: @[deprecated formPerm_apply_get_zero (since := "2024-05-30")]
theorem formPerm_apply_nthLe_zero (l : List α) (h : Nodup l) (hl : 1 < l.length) :
    formPerm l (l.nthLe 0 (by omega)) = l.nthLe 1 hl 
goal: l.formPerm (l.nthLe 0 ⋯) = l.nthLe 1 hl

full_name: List.formPerm_eq_head_iff_eq_getLast
code: theorem formPerm_eq_head_iff_eq_getLast (x y : α) :
    formPerm (y :: l) x = y ↔ x = getLast (y :: l) (cons_ne_nil _ _) 
goal: (y :: l).formPerm x = y ↔ x = (y :: l).getLast ⋯

full_name: List.formPerm_apply_lt_getElem
code: theorem formPerm_apply_lt_getElem (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n + 1 < xs.length) :
    formPerm xs (xs[n]'((Nat.lt_succ_self n).trans hn)) = xs[n + 1] 
goal: xs.formPerm xs[n] = xs[n + 1]

full_name: List.formPerm_apply_lt_get
code: theorem formPerm_apply_lt_get (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n + 1 < xs.length) :
    formPerm xs (xs.get (Fin.mk n ((Nat.lt_succ_self n).trans hn))) =
      xs.get (Fin.mk (n + 1) hn) 
goal: xs.formPerm (xs.get ⟨n, ⋯⟩) = xs.get ⟨n + 1, hn⟩

full_name: List.formPerm_apply_lt
code: @[deprecated formPerm_apply_lt_get (since := "2024-05-30")]
theorem formPerm_apply_lt (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n + 1 < xs.length) :
    formPerm xs (xs.nthLe n ((Nat.lt_succ_self n).trans hn)) = xs.nthLe (n + 1) hn 
goal: xs.formPerm (xs.nthLe n ⋯) = xs.nthLe (n + 1) hn

full_name: List.formPerm_apply_getElem
code: theorem formPerm_apply_getElem (xs : List α) (w : Nodup xs) (i : Nat) (h : i < xs.length) :
    formPerm xs xs[i] =
      xs[(i + 1) % xs.length]'(Nat.mod_lt _ (i.zero_le.trans_lt h)) 
goal: xs.formPerm xs[i] = xs[(i + 1) % xs.length]

full_name: List.formPerm_apply_get
code: theorem formPerm_apply_get (xs : List α) (h : Nodup xs) (i : Fin xs.length) :
    formPerm xs (xs.get i) =
      xs.get ⟨((i.val + 1) % xs.length), (Nat.mod_lt _ (i.val.zero_le.trans_lt i.isLt))⟩ 
goal: xs.formPerm (xs.get i) = xs.get ⟨(↑i + 1) % xs.length, ⋯⟩

full_name: List.formPerm_apply_nthLe
code: @[deprecated formPerm_apply_get (since := "2024-04-23")]
theorem formPerm_apply_nthLe (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n < xs.length) :
    formPerm xs (xs.nthLe n hn) =
      xs.nthLe ((n + 1) % xs.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) 
goal: xs.formPerm (xs.nthLe n hn) = xs.nthLe ((n + 1) % xs.length) ⋯

full_name: List.support_formPerm_of_nodup'
code: theorem support_formPerm_of_nodup' (l : List α) (h : Nodup l) (h' : ∀ x : α, l ≠ [x]) :
    { x | formPerm l x ≠ x } = l.toFinset 
goal: {x | l.formPerm x ≠ x} = ↑l.toFinset

full_name: List.support_formPerm_of_nodup
code: theorem support_formPerm_of_nodup [Fintype α] (l : List α) (h : Nodup l) (h' : ∀ x : α, l ≠ [x]) :
    support (formPerm l) = l.toFinset 
goal: l.formPerm.support = l.toFinset

full_name: List.formPerm_rotate_one
code: theorem formPerm_rotate_one (l : List α) (h : Nodup l) : formPerm (l.rotate 1) = formPerm l 
goal: (l.rotate 1).formPerm = l.formPerm

full_name: List.formPerm_rotate
code: theorem formPerm_rotate (l : List α) (h : Nodup l) (n : ℕ) :
    formPerm (l.rotate n) = formPerm l 
goal: (l.rotate n).formPerm = l.formPerm

full_name: List.formPerm_eq_of_isRotated
code: theorem formPerm_eq_of_isRotated {l l' : List α} (hd : Nodup l) (h : l ~r l') :
    formPerm l = formPerm l' 
goal: l.formPerm = l'.formPerm

full_name: List.formPerm_append_pair
code: theorem formPerm_append_pair : ∀ (l : List α) (a b : α),
    formPerm (l ++ [a, b]) = formPerm (l ++ [a]) * swap a b
  
goal: (l ++ [a, b]).formPerm = (l ++ [a]).formPerm * Equiv.swap a b

full_name: List.formPerm_reverse
code: theorem formPerm_reverse : ∀ l : List α, formPerm l.reverse = (formPerm l)⁻¹
  
goal: l.reverse.formPerm = l.formPerm⁻¹

full_name: List.formPerm_pow_apply_getElem
code: theorem formPerm_pow_apply_getElem (l : List α) (w : Nodup l) (n : ℕ) (i : Nat) (h : i < l.length) :
    (formPerm l ^ n) l[i] =
      l[(i + n) % l.length]'(Nat.mod_lt _ (i.zero_le.trans_lt h)) 
goal: (l.formPerm ^ n) l[i] = l[(i + n) % l.length]

full_name: List.formPerm_pow_apply_get
code: theorem formPerm_pow_apply_get (l : List α) (h : Nodup l) (n : ℕ) (i : Fin l.length) :
    (formPerm l ^ n) (l.get i) =
      l.get ⟨((i.val + n) % l.length), (Nat.mod_lt _ (i.val.zero_le.trans_lt i.isLt))⟩ 
goal: (l.formPerm ^ n) (l.get i) = l.get ⟨(↑i + n) % l.length, ⋯⟩

full_name: List.formPerm_pow_apply_nthLe
code: @[deprecated formPerm_pow_apply_get (since := "2024-04-23")]
theorem formPerm_pow_apply_nthLe (l : List α) (h : Nodup l) (n k : ℕ) (hk : k < l.length) :
    (formPerm l ^ n) (l.nthLe k hk) =
      l.nthLe ((k + n) % l.length) (Nat.mod_lt _ (k.zero_le.trans_lt hk)) 
goal: (l.formPerm ^ n) (l.nthLe k hk) = l.nthLe ((k + n) % l.length) ⋯

full_name: List.formPerm_pow_apply_head
code: theorem formPerm_pow_apply_head (x : α) (l : List α) (h : Nodup (x :: l)) (n : ℕ) :
    (formPerm (x :: l) ^ n) x =
      (x :: l).get ⟨(n % (x :: l).length), (Nat.mod_lt _ (Nat.zero_lt_succ _))⟩ 
goal: ((x :: l).formPerm ^ n) x = (x :: l).get ⟨n % (x :: l).length, ⋯⟩

full_name: List.formPerm_ext_iff
code: theorem formPerm_ext_iff {x y x' y' : α} {l l' : List α} (hd : Nodup (x :: y :: l))
    (hd' : Nodup (x' :: y' :: l')) :
    formPerm (x :: y :: l) = formPerm (x' :: y' :: l') ↔ (x :: y :: l) ~r (x' :: y' :: l') 
goal: (x :: y :: l).formPerm = (x' :: y' :: l').formPerm ↔ (x :: y :: l) ~r (x' :: y' :: l')

full_name: List.formPerm_apply_mem_eq_self_iff
code: theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x = x ↔ length l ≤ 1 
goal: l.formPerm x = x ↔ l.length ≤ 1

full_name: List.formPerm_apply_mem_ne_self_iff
code: theorem formPerm_apply_mem_ne_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
    formPerm l x ≠ x ↔ 2 ≤ l.length 
goal: l.formPerm x ≠ x ↔ 2 ≤ l.length

full_name: List.mem_of_formPerm_ne_self
code: theorem mem_of_formPerm_ne_self (l : List α) (x : α) (h : formPerm l x ≠ x) : x ∈ l 
goal: x ∈ l

full_name: List.formPerm_eq_self_of_not_mem
code: theorem formPerm_eq_self_of_not_mem (l : List α) (x : α) (h : x ∉ l) : formPerm l x = x 
goal: l.formPerm x = x

full_name: List.formPerm_eq_one_iff
code: theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 
goal: l.formPerm = 1 ↔ l.length ≤ 1

full_name: List.formPerm_eq_formPerm_iff
code: 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 
goal: l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1

full_name: List.form_perm_zpow_apply_mem_imp_mem
code: theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) :
    (formPerm l ^ n) x ∈ l 
goal: (l.formPerm ^ n) x ∈ l

full_name: List.formPerm_pow_length_eq_one_of_nodup
code: theorem formPerm_pow_length_eq_one_of_nodup (hl : Nodup l) : formPerm l ^ length l = 1 
goal: l.formPerm ^ l.length = 1