The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V31. Set theory

Mathlib.SetTheory.Lists

83 declarations. Mathlib docs · Source

A computable model of ZFA without infinity

In this file we define finite hereditary lists. This is useful for calculations in naive set theory.

We distinguish two kinds of ZFA lists:

  • Atoms. Directly correspond to an element of the original type.
  • Proper ZFA lists. Can be thought of (but are not implemented) as a list of ZFA lists (not necessarily proper).

For example, Lists ℕ contains stuff like 23, [], [37], [1, [[2], 3], 4].

Implementation notes

As we want to be able to append both atoms and proper ZFA lists to proper ZFA lists, it's handy that atoms and proper ZFA lists belong to the same type, even though atoms of α could be modelled as α directly. But we don't want to be able to append anything to atoms.

This calls for a two-step definition of ZFA lists:

  • First, define ZFA prelists as atoms and proper ZFA prelists. Those proper ZFA prelists are defined by inductive appending of (not necessarily proper) ZFA lists.
  • Second, define ZFA lists by rubbing out the distinction between atoms and proper lists.

Main declarations

  • Lists' α false: Atoms as ZFA prelists. Basically a copy of α.
  • Lists' α true: Proper ZFA prelists. Defined inductively from the empty ZFA prelist (Lists'.nil) and from appending a ZFA prelist to a proper ZFA prelist (Lists'.cons a l).
  • Lists α: ZFA lists. Sum of the atoms and proper ZFA prelists.
  • Finsets α: ZFA sets. Defined as Lists quotiented by Lists.Equiv, the extensional equivalence.

theorem Lists'.toList.match_1.congr_eq_2 E1 #

∀ {α : Type u_1} (motive : (x : Bool) → Lists' α x → Sort u_2) (x : Bool) (x_1 : Lists' α x)
  (h_1 : (a : α) → motive false (Lists'.atom a)) (h_2 : Unit → motive true Lists'.nil)
  (h_3 : (b : Bool) → (a : Lists' α b) → (l : Lists' α true) → motive true (a.cons' l)),
  x = true →
    x_1 ≍ Lists'.nil →
      (match x, x_1 with
        | .(false), Lists'.atom a => h_1 a
        | .(true), Lists'.nil => h_2 ()
        | .(true), a.cons' l => h_3 b a l) ≍
        h_2 ()

theorem Lists.toList.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : Lists α → Sort u_2) (x : Lists α) (h_1 : (fst : Bool) → (l : Lists' α fst) → motive ⟨fst, l⟩)
  (fst : Bool) (l : Lists' α fst),
  x = ⟨fst, l⟩ →
    (match x with
      | ⟨fst, l⟩ => h_1 fst l) ≍
      h_1 fst l

theorem Lists'.toList.match_1.congr_eq_3 E1 #

∀ {α : Type u_1} (motive : (x : Bool) → Lists' α x → Sort u_2) (x : Bool) (x_1 : Lists' α x)
  (h_1 : (a : α) → motive false (Lists'.atom a)) (h_2 : Unit → motive true Lists'.nil)
  (h_3 : (b : Bool) → (a : Lists' α b) → (l : Lists' α true) → motive true (a.cons' l)) (b : Bool) (a : Lists' α b)
  (l : Lists' α true),
  x = true →
    x_1 ≍ a.cons' l →
      (match x, x_1 with
        | .(false), Lists'.atom a => h_1 a
        | .(true), Lists'.nil => h_2 ()
        | .(true), a.cons' l => h_3 b a l) ≍
        h_3 b a l

theorem Lists'.brecOn.eq E1 #

∀ {α : Type u} {motive : (a : Bool) → Lists' α a → Sort u_1} {a : Bool} (t : Lists' α a)
  (F_1 : (a : Bool) → (t : Lists' α a) → Lists'.below t → motive a t),
  Lists'.brecOn t F_1 = F_1 a t (Lists'.brecOn.go t F_1).2

theorem Lists'.cons'.inj E1 #

∀ {α : Type u} {b : Bool} {a : Lists' α b} {a_1 : Lists' α true} {b_1 : Bool} {a_2 : Lists' α b_1}
  {a_3 : Lists' α true}, a.cons' a_1 = a_2.cons' a_3 → b = b_1 ∧ a ≍ a_2 ∧ a_1 = a_3

theorem Lists'.cons'.injEq E0 #

∀ {α : Type u} {b : Bool} (a : Lists' α b) (a_1 : Lists' α true) (b_1 : Bool) (a_2 : Lists' α b_1)
  (a_3 : Lists' α true), (a.cons' a_1 = a_2.cons' a_3) = (b = b_1 ∧ a ≍ a_2 ∧ a_1 = a_3)

theorem Lists'.cons.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : Lists α → Lists' α true → Sort u_2) (x : Lists α) (x_1 : Lists' α true)
  (h_1 : (fst : Bool) → (a : Lists' α fst) → (l : Lists' α true) → motive ⟨fst, a⟩ l) (fst : Bool) (a : Lists' α fst)
  (l : Lists' α true),
  x = ⟨fst, a⟩ →
    x_1 = l →
      (match x, x_1 with
        | ⟨fst, a⟩, l => h_1 fst a l) ≍
        h_1 fst a l

theorem Lists'.atom.injEq E0 #

∀ {α : Type u} (a a_1 : α), (Lists'.atom a = Lists'.atom a_1) = (a = a_1)

def Lists'.ctorIdx E1 #

{α : Type u} → {a : Bool} → Lists' α a → ℕ

abbrev Lists'.ctorElimType E1 #

{α : Type u} →
  {motive : (a : Bool) → Lists' α a → Sort u_1} → ℕ → Sort (max 1 u_1 (imax (u + 1) u_1) (imax (u + 1) (u + 1) u_1))

abbrev Lists'.brecOn.go E1 #

{α : Type u} →
  {motive : (a : Bool) → Lists' α a → Sort u_1} →
    {a : Bool} →
      (t : Lists' α a) → ((a : Bool) → (t : Lists' α a) → Lists'.below t → motive a t) → motive a t ×' Lists'.below t

theorem Lists'.atom.inj E1 #

∀ {α : Type u} {a a_1 : α}, Lists'.atom a = Lists'.atom a_1 → a = a_1

theorem Lists'.ofList.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : List (Lists α) → Sort u_2) (x : List (Lists α)) (h_1 : Unit → motive [])
  (h_2 : (a : Lists α) → (l : List (Lists α)) → motive (a :: l)),
  x = [] →
    (match x with
      | [] => h_1 ()
      | a :: l => h_2 a l) ≍
      h_1 ()

ctor Lists.Equiv.below.antisymm E0 #

∀ {α : Type u_1} {motive_1 : (a a_1 : Lists α) → a.Equiv a_1 → Prop}
  {motive_2 : (a a_1 : Lists' α true) → a.Subset a_1 → Prop} {l₁ l₂ : Lists' α true} (a : l₁.Subset l₂)
  (a_1 : l₂.Subset l₁), a.below → motive_2 l₁ l₂ a → a_1.below → motive_2 l₂ l₁ a_1 → ⋯.below

ctor Lists'.Subset.below.cons E0 #

∀ {α : Type u_1} {motive_1 : (a a_1 : Lists α) → a.Equiv a_1 → Prop}
  {motive_2 : (a a_1 : Lists' α true) → a.Subset a_1 → Prop} {a a' : Lists α} {l l' : Lists' α true} (a_1 : a.Equiv a')
  (a_2 : a' ∈ l'.toList) (a_3 : l.Subset l'), a_1.below → motive_1 a a' a_1 → a_3.below → motive_2 l l' a_3 → ⋯.below

theorem Lists'.ofList.match_1.congr_eq_2 E1 #

∀ {α : Type u_1} (motive : List (Lists α) → Sort u_2) (x : List (Lists α)) (h_1 : Unit → motive [])
  (h_2 : (a : Lists α) → (l : List (Lists α)) → motive (a :: l)) (a : Lists α) (l : List (Lists α)),
  x = a :: l →
    (match x with
      | [] => h_1 ()
      | a :: l => h_2 a l) ≍
      h_2 a l

theorem Lists'.toList.match_1.congr_eq_1 E1 #

∀ {α : Type u_1} (motive : (x : Bool) → Lists' α x → Sort u_2) (x : Bool) (x_1 : Lists' α x)
  (h_1 : (a : α) → motive false (Lists'.atom a)) (h_2 : Unit → motive true Lists'.nil)
  (h_3 : (b : Bool) → (a : Lists' α b) → (l : Lists' α true) → motive true (a.cons' l)) (a : α),
  x = false →
    x_1 ≍ Lists'.atom a →
      (match x, x_1 with
        | .(false), Lists'.atom a => h_1 a
        | .(true), Lists'.nil => h_2 ()
        | .(true), a.cons' l => h_3 b a l) ≍
        h_1 a

ctor Lists'.Subset.below.nil E0 #

∀ {α : Type u_1} {motive_1 : (a a_1 : Lists α) → a.Equiv a_1 → Prop}
  {motive_2 : (a a_1 : Lists' α true) → a.Subset a_1 → Prop} {l : Lists' α true}, ⋯.below

ctor Lists.Equiv.below.refl E0 #

∀ {α : Type u_1} {motive_1 : (a a_1 : Lists α) → a.Equiv a_1 → Prop}
  {motive_2 : (a a_1 : Lists' α true) → a.Subset a_1 → Prop} (l : Lists α), ⋯.below

inductive Lists' E1 #

Type u → Bool → Type u

Prelists, helper type to define Lists. Lists' α false are the "atoms", a copy of α. Lists' α true are the "proper" ZFA prelists, inductively defined from the empty ZFA prelist and from appending a ZFA prelist to a proper ZFA prelist. It is made so that you can't append anything to an atom while having only one appending function for appending both atoms and proper ZFA prelists to a proper ZFA prelist.

ctor Lists'.atom E0 #

{α : Type u} → α → Lists' α false

ctor Lists'.nil E3 #

{α : Type u} → Lists' α true

ctor Lists'.cons' E0 #

{α : Type u} → {b : Bool} → Lists' α b → Lists' α true → Lists' α true

def instDecidableEqLists'.decEq E1 #

{α : Type u_2} → {a : Bool} → [DecidableEq α] → (x x_1 : Lists' α a) → Decidable (x = x_1)

instance instDecidableEqLists' E0 #

{α : Type u_2} → {a : Bool} → [DecidableEq α] → DecidableEq (Lists' α a)

def Lists E3 #

Type u_2 → Type (max 0 u_2)

Hereditarily finite list, aka ZFA list. A ZFA list is either an "atom" (b = false), corresponding to an element of α, or a "proper" ZFA list, inductively defined from the empty ZFA list and from appending a ZFA list to a proper ZFA list.

instance Lists'.instInhabited E0 #

{α : Type u_1} → [Inhabited α] → (b : Bool) → Inhabited (Lists' α b)

def Lists'.cons E1 #

{α : Type u_1} → Lists α → Lists' α true → Lists' α true

Appending a ZFA list to a proper ZFA prelist.

def Lists'.toList E1 #

{α : Type u_1} → {b : Bool} → Lists' α b → List (Lists α)

Converts a ZFA prelist to a List of ZFA lists. Atoms are sent to [].

theorem Lists'.toList_cons E0 #

∀ {α : Type u_1} (a : Lists α) (l : Lists' α true), (Lists'.cons a l).toList = a :: l.toList

def Lists'.ofList E1 #

{α : Type u_1} → List (Lists α) → Lists' α true

Converts a List of ZFA lists to a proper ZFA prelist.

theorem Lists'.to_ofList E0 #

∀ {α : Type u_1} (l : List (Lists α)), (Lists'.ofList l).toList = l

theorem Lists'.of_toList E0 #

∀ {α : Type u_1} (l : Lists' α true), Lists'.ofList l.toList = l

def Lists'.recOfList E1 #

{α : Type u_1} →
  {motive : Lists' α true → Sort u_2} →
    ((l : List (Lists α)) → motive (Lists'.ofList l)) → (l : Lists' α true) → motive l

Recursion/induction principle for Lists'.ofList.

inductive Lists.Equiv E3 #

{α : Type u_1} → Lists α → Lists α → Prop

Equivalence of ZFA lists. Defined inductively.

ctor Lists.Equiv.refl E0 #

∀ {α : Type u_1} (l : Lists α), l.Equiv l

ctor Lists.Equiv.antisymm E0 #

∀ {α : Type u_1} {l₁ l₂ : Lists' α true}, l₁.Subset l₂ → l₂.Subset l₁ → Lists.Equiv ⟨true, l₁⟩ ⟨true, l₂⟩

inductive Lists'.Subset E1 #

{α : Type u_1} → Lists' α true → Lists' α true → Prop

Subset relation for ZFA lists. Defined inductively.

ctor Lists'.Subset.nil E0 #

∀ {α : Type u_1} {l : Lists' α true}, Lists'.nil.Subset l

ctor Lists'.Subset.cons E0 #

∀ {α : Type u_1} {a a' : Lists α} {l l' : Lists' α true},
  a.Equiv a' → a' ∈ l'.toList → l.Subset l' → (Lists'.cons a l).Subset l'

instance Lists'.instHasSubsetTrue E0 #

{α : Type u_1} → HasSubset (Lists' α true)

instance Lists'.instMembershipLists E0 #

{α : Type u_1} → {b : Bool} → Membership (Lists α) (Lists' α b)

ZFA prelist membership. A ZFA list is in a ZFA prelist if some element of this ZFA prelist is equivalent as a ZFA list to this ZFA list.

theorem Lists'.mem_def E0 #

∀ {α : Type u_1} {b : Bool} {a : Lists α} {l : Lists' α b}, a ∈ l ↔ ∃ a' ∈ l.toList, a.Equiv a'

theorem Lists'.mem_cons E0 #

∀ {α : Type u_1} {a y : Lists α} {l : Lists' α true}, a ∈ Lists'.cons y l ↔ a.Equiv y ∨ a ∈ l

theorem Lists'.cons_subset E1 #

∀ {α : Type u_1} {a : Lists α} {l₁ l₂ : Lists' α true}, Lists'.cons a l₁ ⊆ l₂ ↔ a ∈ l₂ ∧ l₁ ⊆ l₂

theorem Lists'.ofList_subset E1 #

∀ {α : Type u_1} {l₁ l₂ : List (Lists α)}, l₁ ⊆ l₂ → Lists'.ofList l₁ ⊆ Lists'.ofList l₂

theorem Lists'.Subset.refl E1 #

∀ {α : Type u_1} {l : Lists' α true}, l ⊆ l

theorem Lists'.subset_nil E1 #

∀ {α : Type u_1} {l : Lists' α true}, l ⊆ Lists'.nil → l = Lists'.nil

theorem Lists'.mem_of_subset' E0 #

∀ {α : Type u_1} {a : Lists α} {l₁ l₂ : Lists' α true}, l₁ ⊆ l₂ → a ∈ l₁.toList → a ∈ l₂

theorem Lists'.subset_def E0 #

∀ {α : Type u_1} {l₁ l₂ : Lists' α true}, l₁ ⊆ l₂ ↔ ∀ a ∈ l₁.toList, a ∈ l₂

def Lists.atom E1 #

{α : Type u_1} → α → Lists α

Sends a : α to the corresponding atom in Lists α.

def Lists.of' E1 #

{α : Type u_1} → Lists' α true → Lists α

Converts a proper ZFA prelist to a ZFA list.

def Lists.toList E1 #

{α : Type u_1} → Lists α → List (Lists α)

Converts a ZFA list to a List of ZFA lists. Atoms are sent to [].

def Lists.IsList E1 #

{α : Type u_1} → Lists α → Prop

Predicate stating that a ZFA list is proper.

def Lists.ofList E1 #

{α : Type u_1} → List (Lists α) → Lists α

Converts a List of ZFA lists to a ZFA list.

theorem Lists.isList_toList E1 #

∀ {α : Type u_1} (l : List (Lists α)), (Lists.ofList l).IsList

theorem Lists.to_ofList E1 #

∀ {α : Type u_1} (l : List (Lists α)), (Lists.ofList l).toList = l

theorem Lists.of_toList E1 #

∀ {α : Type u_1} {l : Lists α}, l.IsList → Lists.ofList l.toList = l

instance Lists.instInhabited E0 #

{α : Type u_1} → Inhabited (Lists α)

instance Lists.instDecidableEq E0 #

{α : Type u_1} → [DecidableEq α] → DecidableEq (Lists α)

instance Lists.instSizeOf E0 #

{α : Type u_1} → [SizeOf α] → SizeOf (Lists α)

def Lists.inductionMut E1 #

{α : Type u_1} →
  (C : Lists α → Sort u_2) →
    (D : Lists' α true → Sort u_3) →
      ((a : α) → C (Lists.atom a)) →
        ((l : Lists' α true) → D l → C (Lists.of' l)) →
          D Lists'.nil →
            ((a : Lists α) → (l : Lists' α true) → C a → D l → D (Lists'.cons a l)) →
              ((l : Lists α) → C l) ×' ((l : Lists' α true) → D l)

A recursion principle for pairs of ZFA lists and proper ZFA prelists.

def Lists.mem E1 #

{α : Type u_1} → Lists α → Lists α → Prop

Membership of ZFA list. A ZFA list belongs to a proper ZFA list if it belongs to the latter as a proper ZFA prelist. An atom has no members.

instance Lists.instMembership E0 #

{α : Type u_1} → Membership (Lists α) (Lists α)

theorem Lists.isList_of_mem E1 #

∀ {α : Type u_1} {a l : Lists α}, a ∈ l → l.IsList

theorem Lists.Equiv.antisymm_iff E0 #

∀ {α : Type u_1} {l₁ l₂ : Lists' α true}, (Lists.of' l₁).Equiv (Lists.of' l₂) ↔ l₁ ⊆ l₂ ∧ l₂ ⊆ l₁

theorem Lists.equiv_atom E1 #

∀ {α : Type u_1} {a : α} {l : Lists α}, (Lists.atom a).Equiv l ↔ Lists.atom a = l

theorem Lists.Equiv.symm E1 #

∀ {α : Type u_1} {l₁ l₂ : Lists α}, l₁.Equiv l₂ → l₂.Equiv l₁

theorem Lists.Equiv.trans E1 #

∀ {α : Type u_1} {l₁ l₂ l₃ : Lists α}, l₁.Equiv l₂ → l₂.Equiv l₃ → l₁.Equiv l₃

instance Lists.instSetoidLists E0 #

{α : Type u_1} → Setoid (Lists α)

theorem Lists.sizeof_pos E1 #

∀ {α : Type u_1} {b : Bool} (l : Lists' α b), 0 < sizeOf l

theorem Lists.lt_sizeof_cons' E1 #

∀ {α : Type u_1} {b : Bool} (a : Lists' α b) (l : Lists' α true), sizeOf ⟨b, a⟩ < sizeOf (a.cons' l)

instance Lists.Equiv.decidable E0 #

{α : Type u_1} → [DecidableEq α] → (l₁ l₂ : Lists α) → Decidable (l₁.Equiv l₂)

instance Lists.Subset.decidable E0 #

{α : Type u_1} → [DecidableEq α] → (l₁ l₂ : Lists' α true) → Decidable (l₁ ⊆ l₂)

instance Lists.mem.decidable E0 #

{α : Type u_1} → [DecidableEq α] → (a : Lists α) → (l : Lists' α true) → Decidable (a ∈ l)

instance Lists.instDecidableRelEquiv E0 #

{α : Type u_1} → [DecidableEq α] → DecidableRel fun x1 x2 ↦ x1 ≈ x2

Copy over the decidability to the Setoid instance.

theorem Lists'.mem_equiv_left E0 #

∀ {α : Type u_1} {l : Lists' α true} {a a' : Lists α}, a.Equiv a' → (a ∈ l ↔ a' ∈ l)

theorem Lists'.mem_of_subset E0 #

∀ {α : Type u_1} {a : Lists α} {l₁ l₂ : Lists' α true}, l₁ ⊆ l₂ → a ∈ l₁ → a ∈ l₂

theorem Lists'.Subset.trans E1 #

∀ {α : Type u_1} {l₁ l₂ l₃ : Lists' α true}, l₁ ⊆ l₂ → l₂ ⊆ l₃ → l₁ ⊆ l₃

def Finsets E1 #

Type u_2 → Type u_2

Finsets are defined via equivalence classes of Lists

instance Finsets.instEmptyCollection E0 #

{α : Type u_1} → EmptyCollection (Finsets α)

instance Finsets.instInhabited E0 #

{α : Type u_1} → Inhabited (Finsets α)

instance Finsets.instDecidableEq E0 #

{α : Type u_1} → [DecidableEq α] → DecidableEq (Finsets α)