File: Mathlib/Logic/Equiv/List.lean

full_name: Encodable.encodeList
code: /-- Explicit encoding function for `List α` -/
def encodeList : List α → ℕ
  
goal: List α → ℕ

full_name: Encodable.decodeList
code: /-- Explicit decoding function for `List α` -/
def decodeList : ℕ → Option (List α)
  
goal: ℕ → Option (List α)

full_name: List.encodable
code: /-- If `α` is encodable, then so is `List α`. This uses the `pair` and `unpair` functions from
`Data.Nat.Pairing`. -/
instance _root_.List.encodable : Encodable (List α) 
goal: Encodable (List α)

full_name: List.countable
code: instance _root_.List.countable {α : Type*} [Countable α] : Countable (List α) 
goal: Countable (List α)

full_name: Encodable.encode_list_nil
code: @[simp]
theorem encode_list_nil : encode (@nil α) = 0 
goal: Encodable.encode [] = 0

full_name: Encodable.encode_list_cons
code: @[simp]
theorem encode_list_cons (a : α) (l : List α) :
    encode (a :: l) = succ (pair (encode a) (encode l)) 
goal: Encodable.encode (a :: l) = (Nat.pair (Encodable.encode a) (Encodable.encode l)).succ

full_name: Encodable.decode_list_zero
code: @[simp]
theorem decode_list_zero : decode (α := List α) 0 = some [] 
goal: Encodable.decode 0 = some []

full_name: Encodable.decode_list_succ
code: @[simp, nolint unusedHavesSuffices] -- Porting note: false positive
theorem decode_list_succ (v : ℕ) :
    decode (α := List α) (succ v) =
      (· :: ·) <$> decode (α := α) v.unpair.1 <*> decode (α := List α) v.unpair.2 
goal: Encodable.decode v.succ =
  Seq.seq ((fun x x_1 => x :: x_1) <$> Encodable.decode (Nat.unpair v).1) fun x => Encodable.decode (Nat.unpair v).2

full_name: Encodable.length_le_encode
code: theorem length_le_encode : ∀ l : List α, length l ≤ encode l
  
goal: l.length ≤ Encodable.encode l

full_name: _private.Mathlib.Logic.Equiv.List.0.Encodable.enle
code: private def enle : α → α → Prop 
goal: α → α → Prop

full_name: _private.Mathlib.Logic.Equiv.List.0.Encodable.enle.isLinearOrder
code: private theorem enle.isLinearOrder : IsLinearOrder α enle 
goal: IsLinearOrder α Encodable.enle

full_name: _private.Mathlib.Logic.Equiv.List.0.Encodable.decidable_enle
code: private def decidable_enle (a b : α) : Decidable (enle a b) 
goal: Decidable (Encodable.enle a b)

full_name: Encodable.encodeMultiset
code: /-- Explicit encoding function for `Multiset α` -/
def encodeMultiset (s : Multiset α) : ℕ 
goal: ℕ

full_name: Encodable.decodeMultiset
code: /-- Explicit decoding function for `Multiset α` -/
def decodeMultiset (n : ℕ) : Option (Multiset α) 
goal: Option (Multiset α)

full_name: Multiset.encodable
code: /-- If `α` is encodable, then so is `Multiset α`. -/
instance _root_.Multiset.encodable : Encodable (Multiset α) 
goal: Encodable (Multiset α)

full_name: Multiset.countable
code: /-- If `α` is countable, then so is `Multiset α`. -/
instance _root_.Multiset.countable {α : Type*} [Countable α] : Countable (Multiset α) 
goal: Countable (Multiset α)

full_name: Encodable.encodableOfList
code: /-- A listable type with decidable equality is encodable. -/
def encodableOfList [DecidableEq α] (l : List α) (H : ∀ x, x ∈ l) : Encodable α 
goal: Encodable α

full_name: Fintype.truncEncodable
code: /-- A finite type is encodable. Because the encoding is not unique, we wrap it in `Trunc` to
preserve computability. -/
def _root_.Fintype.truncEncodable (α : Type*) [DecidableEq α] [Fintype α] : Trunc (Encodable α) 
goal: Trunc (Encodable α)

full_name: Fintype.toEncodable
code: /-- A noncomputable way to arbitrarily choose an ordering on a finite type.
It is not made into a global instance, since it involves an arbitrary choice.
This can be locally made into an instance with `attribute [local instance] Fintype.toEncodable`. -/
noncomputable def _root_.Fintype.toEncodable (α : Type*) [Fintype α] : Encodable α 
goal: Encodable α

full_name: Vector.encodable
code: /-- If `α` is encodable, then so is `Vector α n`. -/
instance _root_.Vector.encodable [Encodable α] {n} : Encodable (Vector α n) 
goal: Encodable (Mathlib.Vector α n)

full_name: Vector.countable
code: /-- If `α` is countable, then so is `Vector α n`. -/
instance _root_.Vector.countable [Countable α] {n} : Countable (Vector α n) 
goal: Countable (Mathlib.Vector α n)

full_name: Encodable.finArrow
code: /-- If `α` is encodable, then so is `Fin n → α`. -/
instance finArrow [Encodable α] {n} : Encodable (Fin n → α) 
goal: Encodable (Fin n → α)

full_name: Encodable.finPi
code: instance finPi (n) (π : Fin n → Type*) [∀ i, Encodable (π i)] : Encodable (∀ i, π i) 
goal: Encodable ((i : Fin n) → π i)

full_name: Finset.encodable
code: /-- If `α` is encodable, then so is `Finset α`. -/
instance _root_.Finset.encodable [Encodable α] : Encodable (Finset α) 
goal: Encodable (Finset α)

full_name: Finset.countable
code: /-- If `α` is countable, then so is `Finset α`. -/
instance _root_.Finset.countable [Countable α] : Countable (Finset α) 
goal: Countable (Finset α)

full_name: Encodable.fintypeArrow
code: /-- When `α` is finite and `β` is encodable, `α → β` is encodable too. Because the encoding is not
unique, we wrap it in `Trunc` to preserve computability. -/
def fintypeArrow (α : Type*) (β : Type*) [DecidableEq α] [Fintype α] [Encodable β] :
    Trunc (Encodable (α → β)) 
goal: Trunc (Encodable (α → β))

full_name: Encodable.fintypePi
code: /-- When `α` is finite and all `π a` are encodable, `Π a, π a` is encodable too. Because the
encoding is not unique, we wrap it in `Trunc` to preserve computability. -/
def fintypePi (α : Type*) (π : α → Type*) [DecidableEq α] [Fintype α] [∀ a, Encodable (π a)] :
    Trunc (Encodable (∀ a, π a)) 
goal: Trunc (Encodable ((a : α) → π a))

full_name: Encodable.sortedUniv
code: /-- The elements of a `Fintype` as a sorted list. -/
def sortedUniv (α) [Fintype α] [Encodable α] : List α 
goal: List α

full_name: Encodable.mem_sortedUniv
code: @[simp]
theorem mem_sortedUniv {α} [Fintype α] [Encodable α] (x : α) : x ∈ sortedUniv α 
goal: x ∈ Encodable.sortedUniv α

full_name: Encodable.length_sortedUniv
code: @[simp]
theorem length_sortedUniv (α) [Fintype α] [Encodable α] : (sortedUniv α).length = Fintype.card α 
goal: (Encodable.sortedUniv α).length = Fintype.card α

full_name: Encodable.sortedUniv_nodup
code: @[simp]
theorem sortedUniv_nodup (α) [Fintype α] [Encodable α] : (sortedUniv α).Nodup 
goal: (Encodable.sortedUniv α).Nodup

full_name: Encodable.sortedUniv_toFinset
code: @[simp]
theorem sortedUniv_toFinset (α) [Fintype α] [Encodable α] [DecidableEq α] :
    (sortedUniv α).toFinset = Finset.univ 
goal: (Encodable.sortedUniv α).toFinset = Finset.univ

full_name: Encodable.fintypeEquivFin
code: /-- An encodable `Fintype` is equivalent to the same size `Fin`. -/
def fintypeEquivFin {α} [Fintype α] [Encodable α] : α ≃ Fin (Fintype.card α) 
goal: α ≃ Fin (Fintype.card α)

full_name: Encodable.fintypeArrowOfEncodable
code: /-- If `α` and `β` are encodable and `α` is a fintype, then `α → β` is encodable as well. -/
instance fintypeArrowOfEncodable {α β : Type*} [Encodable α] [Fintype α] [Encodable β] :
    Encodable (α → β) 
goal: Encodable (α → β)

full_name: Denumerable.denumerable_list_aux
code: @[nolint unusedHavesSuffices] -- Porting note: false positive
theorem denumerable_list_aux : ∀ n : ℕ, ∃ a ∈ @decodeList α _ n, encodeList a = n
  
goal: ∃ a ∈ Encodable.decodeList n, Encodable.encodeList a = n

full_name: Denumerable.denumerableList
code: /-- If `α` is denumerable, then so is `List α`. -/
instance denumerableList : Denumerable (List α) 
goal: Denumerable (List α)

full_name: Denumerable.list_ofNat_zero
code: @[simp]
theorem list_ofNat_zero : ofNat (List α) 0 = [] 
goal: Denumerable.ofNat (List α) 0 = []

full_name: Denumerable.list_ofNat_succ
code: @[simp, nolint unusedHavesSuffices] -- Porting note: false positive
theorem list_ofNat_succ (v : ℕ) :
    ofNat (List α) (succ v) = ofNat α v.unpair.1 :: ofNat (List α) v.unpair.2 
goal: Denumerable.ofNat (List α) v.succ = Denumerable.ofNat α (Nat.unpair v).1 :: Denumerable.ofNat (List α) (Nat.unpair v).2

full_name: Denumerable.lower
code: /-- Outputs the list of differences of the input list, that is
`lower [a₁, a₂, ...] n = [a₁ - n, a₂ - a₁, ...]` -/
def lower : List ℕ → ℕ → List ℕ
  
goal: List ℕ → ℕ → List ℕ

full_name: Denumerable.raise
code: /-- Outputs the list of partial sums of the input list, that is
`raise [a₁, a₂, ...] n = [n + a₁, n + a₁ + a₂, ...]` -/
def raise : List ℕ → ℕ → List ℕ
  
goal: List ℕ → ℕ → List ℕ

full_name: Denumerable.lower_raise
code: theorem lower_raise : ∀ l n, lower (raise l n) n = l
  
goal: Denumerable.lower (Denumerable.raise l n) n = l

full_name: Denumerable.raise_lower
code: theorem raise_lower : ∀ {l n}, List.Sorted (· ≤ ·) (n :: l) → raise (lower l n) n = l
  
goal: List.Sorted (fun x x_1 => x ≤ x_1) (n :: l) → Denumerable.raise (Denumerable.lower l n) n = l

full_name: Denumerable.raise_chain
code: theorem raise_chain : ∀ l n, List.Chain (· ≤ ·) n (raise l n)
  
goal: List.Chain (fun x x_1 => x ≤ x_1) n (Denumerable.raise l n)

full_name: Denumerable.raise_sorted
code: /-- `raise l n` is a non-decreasing sequence. -/
theorem raise_sorted : ∀ l n, List.Sorted (· ≤ ·) (raise l n)
  
goal: List.Sorted (fun x x_1 => x ≤ x_1) (Denumerable.raise l n)

full_name: Denumerable.multiset
code: /-- If `α` is denumerable, then so is `Multiset α`. Warning: this is *not* the same encoding as used
in `Multiset.encodable`. -/
instance multiset : Denumerable (Multiset α) 
goal: Denumerable (Multiset α)

full_name: Denumerable.lower'
code: /-- Outputs the list of differences minus one of the input list, that is
`lower' [a₁, a₂, a₃, ...] n = [a₁ - n, a₂ - a₁ - 1, a₃ - a₂ - 1, ...]`. -/
def lower' : List ℕ → ℕ → List ℕ
  
goal: List ℕ → ℕ → List ℕ

full_name: Denumerable.raise'
code: /-- Outputs the list of partial sums plus one of the input list, that is
`raise [a₁, a₂, a₃, ...] n = [n + a₁, n + a₁ + a₂ + 1, n + a₁ + a₂ + a₃ + 2, ...]`. Adding one each
time ensures the elements are distinct. -/
def raise' : List ℕ → ℕ → List ℕ
  
goal: List ℕ → ℕ → List ℕ

full_name: Denumerable.lower_raise'
code: theorem lower_raise' : ∀ l n, lower' (raise' l n) n = l
  
goal: Denumerable.lower' (Denumerable.raise' l n) n = l

full_name: Denumerable.raise_lower'
code: theorem raise_lower' : ∀ {l n}, (∀ m ∈ l, n ≤ m) → List.Sorted (· < ·) l → raise' (lower' l n) n = l
  
goal: (∀ m ∈ l, n ≤ m) → List.Sorted (fun x x_1 => x < x_1) l → Denumerable.raise' (Denumerable.lower' l n) n = l

full_name: Denumerable.raise'_chain
code: theorem raise'_chain : ∀ (l) {m n}, m < n → List.Chain (· < ·) m (raise' l n)
  
goal: m < n → List.Chain (fun x x_1 => x < x_1) m (Denumerable.raise' l n)

full_name: Denumerable.raise'_sorted
code: /-- `raise' l n` is a strictly increasing sequence. -/
theorem raise'_sorted : ∀ l n, List.Sorted (· < ·) (raise' l n)
  
goal: List.Sorted (fun x x_1 => x < x_1) (Denumerable.raise' l n)

full_name: Denumerable.raise'Finset
code: /-- Makes `raise' l n` into a finset. Elements are distinct thanks to `raise'_sorted`. -/
def raise'Finset (l : List ℕ) (n : ℕ) : Finset ℕ 
goal: Finset ℕ

full_name: Denumerable.finset
code: /-- If `α` is denumerable, then so is `Finset α`. Warning: this is *not* the same encoding as used
in `Finset.encodable`. -/
instance finset : Denumerable (Finset α) 
goal: Denumerable (Finset α)

full_name: Equiv.listUnitEquiv
code: /-- The type lists on unit is canonically equivalent to the natural numbers. -/
def listUnitEquiv : List Unit ≃ ℕ 
goal: List Unit ≃ ℕ

full_name: Equiv.listNatEquivNat
code: /-- `List ℕ` is equivalent to `ℕ`. -/
def listNatEquivNat : List ℕ ≃ ℕ 
goal: List ℕ ≃ ℕ

full_name: Equiv.listEquivSelfOfEquivNat
code: /-- If `α` is equivalent to `ℕ`, then `List α` is equivalent to `α`. -/
def listEquivSelfOfEquivNat {α : Type*} (e : α ≃ ℕ) : List α ≃ α 
goal: List α ≃ α