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 / V33. Data structures and computation

Mathlib.Data.PFunctor.Univariate.Basic

47 declarations. Mathlib docs · Source

theorem PFunctor.mk.injEq E0 #

∀ (A : Type uA) (B : A → Type uB) (A_1 : Type uA) (B_1 : A_1 → Type uB),
  ({ A := A, B := B } = { A := A_1, B := B_1 }) = (A = A_1 ∧ B ≍ B_1)

theorem PFunctor.mk.inj E1 #

∀ {A : Type uA} {B : A → Type uB} {A_1 : Type uA} {B_1 : A_1 → Type uB},
  { A := A, B := B } = { A := A_1, B := B_1 } → A = A_1 ∧ B ≍ B_1

def PFunctor.ctorIdx E1 #

PFunctor.{uA, uB} → ℕ

structure PFunctor E1 #

Type (max (uA + 1) (uB + 1))

A polynomial functor P is given by a type A and a family B of types over A. P maps any type α to a new type P α, which is defined as the sigma type Σ x, P.B x → α.

An element of P α is a pair ⟨a, f⟩, where a is an element of a type A and f : B a → α. Think of a as the shape of the object and f as an index to the relevant elements of α.

ctor PFunctor.mk E0 #

(A : Type uA) → (A → Type uB) → PFunctor.{uA, uB}

abbrev PFunctor.A E1 #

PFunctor.{uA, uB} → Type uA

The head type

abbrev PFunctor.B E1 #

(self : PFunctor.{uA, uB}) → self.A → Type uB

The child family of types

instance PFunctor.instInhabited E0 #

Inhabited PFunctor.{u_2, u_1}

def PFunctor.Obj E1 #

PFunctor.{uA, uB} → Type v → Type (max v uA uB)

Applying P to an object of Type

instance PFunctor.instCoeFunForallType E0 #

CoeFun PFunctor.{uA, uB} fun x ↦ Type v → Type (max v uA uB)

def PFunctor.Obj.mk E1 #

{P : PFunctor.{uA, uB}} → {α : Type v₁} → (a : P.A) → (P.B a → α) → ↑P α

Make an element of P α from a "shape" a : P.A and a family of elements f : P.B a → α.

Important: You should use PFunctor.Obj.mk instead of the anonymous constructor ⟨_, _⟩ to avoid abuse of the definitional equality between P α and Σ x : P.A, P.B x → α.

def PFunctor.Obj.rec E1 #

{P : PFunctor.{uA, uB}} →
  {α : Type v₁} →
    {motive : ↑P α → Sort u_1} → ((a : P.A) → (f : P.B a → α) → motive (PFunctor.Obj.mk a f)) → (t : ↑P α) → motive t

To prove a theorem about t : P α it suffices to prove it for P.Obj.mk a f for all possible values of a and f.

theorem PFunctor.Obj.rec_mk E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type v₁} {motive : ↑P α → Sort u_1}
  {mk : (a : P.A) → (b : P.B a → α) → motive (PFunctor.Obj.mk a b)} (a : P.A) (b : P.B a → α),
  PFunctor.Obj.rec mk (PFunctor.Obj.mk a b) = mk a b

def PFunctor.Obj.fst E1 #

{P : PFunctor.{uA, uB}} → {α : Type v₁} → ↑P α → P.A

Extract the "shape" of a x : P α as x.fst : P.A.

def PFunctor.Obj.snd E1 #

{P : PFunctor.{uA, uB}} → {α : Type v₁} → (x : ↑P α) → P.B x.fst → α

Extract the underlying value of type α associated to an object x : P α at an index i : P.B x.fst.

theorem PFunctor.Obj.fst_mk E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type v₁} (a : P.A) (f : P.B a → α), (PFunctor.Obj.mk a f).fst = a

theorem PFunctor.Obj.snd_mk E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type v₁} (a : P.A) (f : P.B a → α), (PFunctor.Obj.mk a f).snd = f

theorem PFunctor.Obj.eta E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type v₁} (x : ↑P α), PFunctor.Obj.mk x.fst x.snd = x

def PFunctor.map E1 #

(P : PFunctor.{uA, uB}) → {α : Type v₁} → {β : Type v₂} → (α → β) → ↑P α → ↑P β

Applying P to a morphism of Type

instance PFunctor.Obj.inhabited E0 #

(P : PFunctor.{uA, uB}) → {α : Type v₁} → [Inhabited P.A] → [Inhabited α] → Inhabited (↑P α)

instance PFunctor.instFunctorObj E0 #

(P : PFunctor.{uA, uB}) → Functor ↑P

theorem PFunctor.map_eq_map E0 #

∀ (P : PFunctor.{uA, uB}) {α β : Type v} (f : α → β) (x : ↑P α), f <$> x = P.map f x

We prefer PFunctor.map to Functor.map because it is universe-polymorphic.

theorem PFunctor.map_eq E0 #

∀ (P : PFunctor.{uA, uB}) {α : Type v₁} {β : Type v₂} (f : α → β) (a : P.A) (g : P.B a → α),
  P.map f (PFunctor.Obj.mk a g) = PFunctor.Obj.mk a (f ∘ g)

theorem PFunctor.id_map E0 #

∀ (P : PFunctor.{uA, uB}) {α : Type v₁} (x : ↑P α), P.map id x = x

theorem PFunctor.map_map E0 #

∀ (P : PFunctor.{uA, uB}) {α : Type v₁} {β : Type v₂} {γ : Type v₃} (f : α → β) (g : β → γ) (x : ↑P α),
  P.map g (P.map f x) = P.map (g ∘ f) x

theorem PFunctor.map_id E0 #

∀ (P : PFunctor.{uA, uB}) (α : Type v₁), P.map id = id

theorem PFunctor.map_comp_map E0 #

∀ (P : PFunctor.{uA, uB}) {α : Type v₁} {β : Type v₂} {γ : Type v₃} (f : α → β) (g : β → γ),
  P.map g ∘ P.map f = P.map (g ∘ f)

instance PFunctor.instLawfulFunctorObj E0 #

∀ (P : PFunctor.{uA, uB}), LawfulFunctor ↑P

def PFunctor.W E1 #

PFunctor.{uA, uB} → Type (max uA uB)

Re-export existing definition of W-types and adapt it to a packaged definition of polynomial functor.

def PFunctor.W.head E1 #

{P : PFunctor.{uA, uB}} → P.W → P.A

The root element of a W tree

def PFunctor.W.children E1 #

{P : PFunctor.{uA, uB}} → (x : P.W) → P.B x.head → P.W

The children of the root of a W tree

def PFunctor.W.dest E1 #

{P : PFunctor.{uA, uB}} → P.W → ↑P P.W

The destructor for W-types

def PFunctor.W.mk E1 #

{P : PFunctor.{uA, uB}} → ↑P P.W → P.W

The constructor for W-types

theorem PFunctor.W.dest_mk E0 #

∀ {P : PFunctor.{uA, uB}} (p : ↑P P.W), (PFunctor.W.mk p).dest = p

theorem PFunctor.W.mk_dest E0 #

∀ {P : PFunctor.{uA, uB}} (p : P.W), PFunctor.W.mk p.dest = p

def PFunctor.Idx E1 #

PFunctor.{uA, uB} → Type (max uA uB)

Idx identifies a location inside the application of a polynomial functor. For F : PFunctor, x : F α and i : F.Idx, i can designate one part of x or is invalid, if i.1 ≠ x.1.

instance PFunctor.Idx.inhabited E0 #

(P : PFunctor.{uA, uB}) → [inst : Inhabited P.A] → [Inhabited (P.B default)] → Inhabited P.Idx

def PFunctor.Obj.iget E1 #

{P : PFunctor.{uA, uB}} → [DecidableEq P.A] → {α : Type u_1} → [Inhabited α] → ↑P α → P.Idx → α

x.iget i takes the component of x designated by i if any is or returns a default value

theorem PFunctor.fst_map E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type v₁} {β : Type v₂} (x : ↑P α) (f : α → β), (P.map f x).fst = x.fst

theorem PFunctor.iget_map E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type v₁} {β : Type v₂} [inst : DecidableEq P.A] [inst_1 : Inhabited α]
  [inst_2 : Inhabited β] (x : ↑P α) (f : α → β) (i : P.Idx), i.fst = x.fst → (P.map f x).iget i = f (x.iget i)

def PFunctor.comp E1 #

PFunctor.{uA₂, uB₂} → PFunctor.{uA₁, uB₁} → PFunctor.{max uA₁ uA₂ uB₂, max uB₁ uB₂}

Composition for polynomial functors

def PFunctor.comp.mk E1 #

(P₂ : PFunctor.{uA₂, uB₂}) → (P₁ : PFunctor.{uA₁, uB₁}) → {α : Type v} → ↑P₂ (↑P₁ α) → ↑(P₂.comp P₁) α

Constructor for composition

def PFunctor.comp.get E1 #

(P₂ : PFunctor.{uA₂, uB₂}) → (P₁ : PFunctor.{uA₁, uB₁}) → {α : Type v} → ↑(P₂.comp P₁) α → ↑P₂ (↑P₁ α)

Destructor for composition

theorem PFunctor.liftp_iff E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type u} (p : α → Prop) (x : ↑P α),
  Functor.Liftp p x ↔ ∃ a f, x = PFunctor.Obj.mk a f ∧ ∀ (i : P.B a), p (f i)

theorem PFunctor.liftp_iff' E1 #

∀ {P : PFunctor.{uA, uB}} {α : Type u} (p : α → Prop) (a : P.A) (f : P.B a → α),
  Functor.Liftp p (PFunctor.Obj.mk a f) ↔ ∀ (i : P.B a), p (f i)

theorem PFunctor.liftr_iff E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type u} (r : α → α → Prop) (x y : ↑P α),
  Functor.Liftr r x y ↔ ∃ a f₀ f₁, x = PFunctor.Obj.mk a f₀ ∧ y = PFunctor.Obj.mk a f₁ ∧ ∀ (i : P.B a), r (f₀ i) (f₁ i)

theorem PFunctor.supp_eq E0 #

∀ {P : PFunctor.{uA, uB}} {α : Type u} (a : P.A) (f : P.B a → α), Functor.supp (PFunctor.Obj.mk a f) = f '' Set.univ