The areas / V33. Data structures and computation
Mathlib.Data.QPF.Univariate.Basic
70 declarations. Mathlib docs · Source
Quotients of Polynomial Functors
We assume the following:
P: a polynomial functorW: its W-typeM: its M-typeF: a functor
We define:
q:QPFdata, representingFas a quotient ofP
The main goal is to construct:
Fix: the initial algebra with structure mapF Fix → Fix.Cofix: the final coalgebra with structure mapCofix → F Cofix
We also show that the composition of qpfs is a qpf, and that the quotient of a qpf is a qpf.
The present theory focuses on the univariate case for qpfs
References
- [Jeremy Avigad, Mario M. Carneiro and Simon Hudon, Data Types as Quotients of Polynomial Functors][avigad-carneiro-hudon2019]
ctor QPF.Wequiv.below.trans E0 #
∀ {F : Type u → Type v} [q : QPF F] {motive : (a a_1 : (QPF.P F).W) → QPF.Wequiv a a_1 → Prop} (u v w : (QPF.P F).W)
(a : QPF.Wequiv u v) (a_1 : QPF.Wequiv v w),
QPF.Wequiv.below a → motive u v a → QPF.Wequiv.below a_1 → motive v w a_1 → QPF.Wequiv.below ⋯
ctor QPF.Wequiv.below.ind E0 #
∀ {F : Type u → Type v} [q : QPF F] {motive : (a a_1 : (QPF.P F).W) → QPF.Wequiv a a_1 → Prop} (a : (QPF.P F).A)
(f f' : (QPF.P F).B a → (QPF.P F).W) (a_1 : ∀ (x : (QPF.P F).B a), QPF.Wequiv (f x) (f' x)),
(∀ (x : (QPF.P F).B a), QPF.Wequiv.below ⋯) → (∀ (x : (QPF.P F).B a), motive (f x) (f' x) ⋯) → QPF.Wequiv.below ⋯
def QPF.ctorIdx E1 #
{F : Type u → Type v} → QPF F → ℕ
ctor QPF.Wequiv.below.abs E0 #
∀ {F : Type u → Type v} [q : QPF F] {motive : (a a_1 : (QPF.P F).W) → QPF.Wequiv a a_1 → Prop} (a : (QPF.P F).A)
(f : (QPF.P F).B a → (QPF.P F).W) (a' : (QPF.P F).A) (f' : (QPF.P F).B a' → (QPF.P F).W)
(a_1 : QPF.abs (PFunctor.Obj.mk a f) = QPF.abs (PFunctor.Obj.mk a' f')), QPF.Wequiv.below ⋯
class QPF E1 #
(Type u → Type v) → Type (max (max (u + 1) (u' + 1)) v)
Quotients of polynomial functors.
Roughly speaking, saying that F is a quotient of a polynomial functor means that for each α,
elements of F α are represented by pairs ⟨a, f⟩, where a is the shape of the object and
f indexes the relevant elements of α, in a suitably natural manner.
ctor QPF.mk E0 #
{F : Type u → Type v} →
[toFunctor : Functor F] →
(P : PFunctor.{u, u'}) →
(abs : {α : Type u} → ↑P α → F α) →
(repr : {α : Type u} → F α → ↑P α) →
(∀ {α : Type u} (x : F α), abs (repr x) = x) →
(∀ {α β : Type u} (f : α → β) (p : ↑P α), abs (P.map f p) = f <$> abs p) → QPF F
instance QPF.toFunctor E0 #
{F : Type u → Type v} → [self : QPF F] → Functor F
abbrev QPF.P E1 #
(F : Type u → Type v) → [self : QPF F] → PFunctor.{u, u'}
abbrev QPF.abs E1 #
{F : Type u → Type v} → [self : QPF F] → {α : Type u} → ↑(QPF.P F) α → F α
abbrev QPF.repr E1 #
{F : Type u → Type v} → [self : QPF F] → {α : Type u} → F α → ↑(QPF.P F) α
theorem QPF.abs_repr E1 #
∀ {F : Type u → Type v} [self : QPF F] {α : Type u} (x : F α), QPF.abs (QPF.repr x) = x
theorem QPF.abs_map E1 #
∀ {F : Type u → Type v} [self : QPF F] {α β : Type u} (f : α → β) (p : ↑(QPF.P F) α),
QPF.abs ((QPF.P F).map f p) = f <$> QPF.abs p
theorem QPF.id_map E1 #
∀ {F : Type u → Type v} [q : QPF F] {α : Type u} (x : F α), id <$> x = x
theorem QPF.comp_map E1 #
∀ {F : Type u → Type v} [q : QPF F] {α β γ : Type u} (f : α → β) (g : β → γ) (x : F α), (g ∘ f) <$> x = g <$> f <$> x
theorem QPF.lawfulFunctor E1 #
∀ {F : Type u → Type v} [q : QPF F],
(∀ (α β : Type u), Functor.mapConst = Functor.map ∘ Function.const β) → LawfulFunctor F
theorem QPF.liftp_iff E0 #
∀ {F : Type u → Type v} [q : QPF F] {α : Type u} (p : α → Prop) (x : F α),
Functor.Liftp p x ↔ ∃ a f, x = QPF.abs (PFunctor.Obj.mk a f) ∧ ∀ (i : (QPF.P F).B a), p (f i)
theorem QPF.liftp_iff' E1 #
∀ {F : Type u → Type v} [q : QPF F] {α : Type u} (p : α → Prop) (x : F α),
Functor.Liftp p x ↔ ∃ u, QPF.abs u = x ∧ ∀ (i : (QPF.P F).B u.fst), p (u.snd i)
theorem QPF.liftr_iff E0 #
∀ {F : Type u → Type v} [q : QPF F] {α : Type u} (r : α → α → Prop) (x y : F α),
Functor.Liftr r x y ↔
∃ a f₀ f₁,
x = QPF.abs (PFunctor.Obj.mk a f₀) ∧ y = QPF.abs (PFunctor.Obj.mk a f₁) ∧ ∀ (i : (QPF.P F).B a), r (f₀ i) (f₁ i)
def QPF.recF E1 #
{F : Type u → Type v} → [q : QPF F] → {α : Type u} → (F α → α) → (QPF.P F).W → α
does recursion on q.P.W using g : F α → α rather than g : P α → α
theorem QPF.recF_eq E0 #
∀ {F : Type u → Type v} [q : QPF F] {α : Type u} (g : F α → α) (x : (QPF.P F).W),
QPF.recF g x = g (QPF.abs ((QPF.P F).map (QPF.recF g) x.dest))
theorem QPF.recF_eq' E1 #
∀ {F : Type u → Type v} [q : QPF F] {α : Type u} (g : F α → α) (a : (QPF.P F).A) (f : (QPF.P F).B a → (QPF.P F).W),
QPF.recF g (WType.mk a f) = g (QPF.abs ((QPF.P F).map (QPF.recF g) (PFunctor.Obj.mk a f)))
inductive QPF.Wequiv E1 #
{F : Type u → Type v} → [q : QPF F] → (QPF.P F).W → (QPF.P F).W → Prop
two trees are equivalent if their F-abstractions are
ctor QPF.Wequiv.ind E0 #
∀ {F : Type u → Type v} [q : QPF F] (a : (QPF.P F).A) (f f' : (QPF.P F).B a → (QPF.P F).W),
(∀ (x : (QPF.P F).B a), QPF.Wequiv (f x) (f' x)) → QPF.Wequiv (WType.mk a f) (WType.mk a f')
ctor QPF.Wequiv.abs E0 #
∀ {F : Type u → Type v} [q : QPF F] (a : (QPF.P F).A) (f : (QPF.P F).B a → (QPF.P F).W) (a' : (QPF.P F).A)
(f' : (QPF.P F).B a' → (QPF.P F).W),
QPF.abs (PFunctor.Obj.mk a f) = QPF.abs (PFunctor.Obj.mk a' f') → QPF.Wequiv (WType.mk a f) (WType.mk a' f')
ctor QPF.Wequiv.trans E0 #
∀ {F : Type u → Type v} [q : QPF F] (u v w : (QPF.P F).W), QPF.Wequiv u v → QPF.Wequiv v w → QPF.Wequiv u w
theorem QPF.recF_eq_of_Wequiv E1 #
∀ {F : Type u → Type v} [q : QPF F] {α : Type u} (u : F α → α) (x y : (QPF.P F).W),
QPF.Wequiv x y → QPF.recF u x = QPF.recF u y
recF is insensitive to the representation
theorem QPF.Wequiv.abs' E1 #
∀ {F : Type u → Type v} [q : QPF F] (x y : (QPF.P F).W), QPF.abs x.dest = QPF.abs y.dest → QPF.Wequiv x y
theorem QPF.Wequiv.refl E1 #
∀ {F : Type u → Type v} [q : QPF F] (x : (QPF.P F).W), QPF.Wequiv x x
theorem QPF.Wequiv.symm E1 #
∀ {F : Type u → Type v} [q : QPF F] (x y : (QPF.P F).W), QPF.Wequiv x y → QPF.Wequiv y x
def QPF.Wrepr E1 #
{F : Type u → Type v} → [q : QPF F] → (QPF.P F).W → (QPF.P F).W
maps every element of the W type to a canonical representative
theorem QPF.Wrepr_equiv E1 #
∀ {F : Type u → Type v} [q : QPF F] (x : (QPF.P F).W), QPF.Wequiv (QPF.Wrepr x) x
def QPF.Wsetoid E1 #
{F : Type u → Type v} → [q : QPF F] → Setoid (QPF.P F).W
Define the fixed point as the quotient of trees under the equivalence relation Wequiv.
def QPF.Fix E1 #
(F : Type u → Type u) → [q : QPF F] → Type u
inductive type defined as initial algebra of a Quotient of Polynomial Functor
def QPF.Fix.rec E1 #
{F : Type u → Type u} → [q : QPF F] → {α : Type u} → (F α → α) → QPF.Fix F → α
recursor of a type defined by a qpf
def QPF.fixToW E1 #
{F : Type u → Type u} → [q : QPF F] → QPF.Fix F → (QPF.P F).W
access the underlying W-type of a fixpoint data type
def QPF.Fix.mk E1 #
{F : Type u → Type u} → [q : QPF F] → F (QPF.Fix F) → QPF.Fix F
constructor of a type defined by a qpf
def QPF.Fix.dest E1 #
{F : Type u → Type u} → [q : QPF F] → QPF.Fix F → F (QPF.Fix F)
destructor of a type defined by a qpf
theorem QPF.Fix.rec_eq E0 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (g : F α → α) (x : F (QPF.Fix F)),
QPF.Fix.rec g (QPF.Fix.mk x) = g (QPF.Fix.rec g <$> x)
theorem QPF.Fix.ind_aux E0 #
∀ {F : Type u → Type u} [q : QPF F] (a : (QPF.P F).A) (f : (QPF.P F).B a → (QPF.P F).W),
QPF.Fix.mk (QPF.abs (PFunctor.Obj.mk a fun x ↦ ⟦f x⟧)) = ⟦WType.mk a f⟧
theorem QPF.Fix.ind_rec E1 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (g₁ g₂ : QPF.Fix F → α),
(∀ (x : F (QPF.Fix F)), g₁ <$> x = g₂ <$> x → g₁ (QPF.Fix.mk x) = g₂ (QPF.Fix.mk x)) → ∀ (x : QPF.Fix F), g₁ x = g₂ x
theorem QPF.Fix.rec_unique E1 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (g : F α → α) (h : QPF.Fix F → α),
(∀ (x : F (QPF.Fix F)), h (QPF.Fix.mk x) = g (h <$> x)) → QPF.Fix.rec g = h
theorem QPF.Fix.mk_dest E1 #
∀ {F : Type u → Type u} [q : QPF F] (x : QPF.Fix F), QPF.Fix.mk x.dest = x
theorem QPF.Fix.dest_mk E0 #
∀ {F : Type u → Type u} [q : QPF F] (x : F (QPF.Fix F)), (QPF.Fix.mk x).dest = x
theorem QPF.Fix.ind E1 #
∀ {F : Type u → Type u} [q : QPF F] (p : QPF.Fix F → Prop),
(∀ (x : F (QPF.Fix F)), Functor.Liftp p x → p (QPF.Fix.mk x)) → ∀ (x : QPF.Fix F), p x
def QPF.corecF E1 #
{F : Type u → Type u} → [q : QPF F] → {α : Type u} → (α → F α) → α → (QPF.P F).M
does recursion on q.P.M using g : α → F α rather than g : α → P α
theorem QPF.corecF_eq E0 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (g : α → F α) (x : α),
(QPF.corecF g x).dest = (QPF.P F).map (QPF.corecF g) (QPF.repr (g x))
def QPF.IsPrecongr E1 #
{F : Type u → Type u} → [q : QPF F] → ((QPF.P F).M → (QPF.P F).M → Prop) → Prop
A pre-congruence on q.P.M viewed as an F-coalgebra. Not necessarily symmetric.
def QPF.Mcongr E1 #
{F : Type u → Type u} → [q : QPF F] → (QPF.P F).M → (QPF.P F).M → Prop
The maximal congruence on q.P.M.
def QPF.Cofix E1 #
(F : Type u → Type u) → [q : QPF F] → Type u
coinductive type defined as the final coalgebra of a qpf
instance QPF.instInhabitedCofixOfAP E0 #
{F : Type u → Type u} → [q : QPF F] → [Inhabited (QPF.P F).A] → Inhabited (QPF.Cofix F)
def QPF.Cofix.corec E1 #
{F : Type u → Type u} → [q : QPF F] → {α : Type u} → (α → F α) → α → QPF.Cofix F
corecursor for type defined by Cofix
def QPF.Cofix.dest E1 #
{F : Type u → Type u} → [q : QPF F] → QPF.Cofix F → F (QPF.Cofix F)
destructor for type defined by Cofix
theorem QPF.Cofix.dest_corec E1 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (g : α → F α) (x : α),
(QPF.Cofix.corec g x).dest = QPF.Cofix.corec g <$> g x
theorem QPF.Cofix.bisim_rel E1 #
∀ {F : Type u → Type u} [q : QPF F] (r : QPF.Cofix F → QPF.Cofix F → Prop),
(∀ (x y : QPF.Cofix F), r x y → Quot.mk r <$> x.dest = Quot.mk r <$> y.dest) → ∀ (x y : QPF.Cofix F), r x y → x = y
theorem QPF.Cofix.bisim E1 #
∀ {F : Type u → Type u} [q : QPF F] (r : QPF.Cofix F → QPF.Cofix F → Prop),
(∀ (x y : QPF.Cofix F), r x y → Functor.Liftr r x.dest y.dest) → ∀ (x y : QPF.Cofix F), r x y → x = y
theorem QPF.Cofix.bisim' E1 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u_1} (Q : α → Prop) (u v : α → QPF.Cofix F),
(∀ (x : α),
Q x →
∃ a f f',
(u x).dest = QPF.abs ⟨a, f⟩ ∧
(v x).dest = QPF.abs (PFunctor.Obj.mk a f') ∧
∀ (i : (QPF.P F).B a), ∃ x', Q x' ∧ f i = u x' ∧ f' i = v x') →
∀ (x : α), Q x → u x = v x
def QPF.comp E1 #
{F₂ : Type u → Type u} → [q₂ : QPF F₂] → {F₁ : Type u → Type u} → [q₁ : QPF F₁] → QPF (Functor.Comp F₂ F₁)
composition of qpfs gives another qpf
def QPF.quotientQPF E1 #
{F : Type u → Type u} →
[q : QPF F] →
{G : Type u → Type u} →
[inst : Functor G] →
{FG_abs : {α : Type u} → F α → G α} →
{FG_repr : {α : Type u} → G α → F α} →
(∀ {α : Type u} (x : G α), FG_abs (FG_repr x) = x) →
(∀ {α β : Type u} (f : α → β) (x : F α), FG_abs (f <$> x) = f <$> FG_abs x) → QPF G
Given a qpf F and a well-behaved surjection FG_abs from F α to
functor G α, G is a qpf. We can consider G a quotient on F where
elements x y : F α are in the same equivalence class if
FG_abs x = FG_abs y.
theorem QPF.mem_supp E0 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (x : F α) (u : α),
u ∈ Functor.supp x ↔
∀ (a : (QPF.P F).A) (f : (QPF.P F).B a → α), QPF.abs (PFunctor.Obj.mk a f) = x → u ∈ f '' Set.univ
theorem QPF.supp_eq E0 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (x : F α),
Functor.supp x =
{u | ∀ (a : (QPF.P F).A) (f : (QPF.P F).B a → α), QPF.abs (PFunctor.Obj.mk a f) = x → u ∈ f '' Set.univ}
theorem QPF.has_good_supp_iff E0 #
∀ {F : Type u → Type u} [q : QPF F] {α : Type u} (x : F α),
(∀ (p : α → Prop), Functor.Liftp p x ↔ ∀ u ∈ Functor.supp x, p u) ↔
∃ a f,
QPF.abs (PFunctor.Obj.mk a f) = x ∧
∀ (a' : (QPF.P F).A) (f' : (QPF.P F).B a' → α),
QPF.abs (PFunctor.Obj.mk a' f') = x → f '' Set.univ ⊆ f' '' Set.univ
def QPF.IsUniform E1 #
{F : Type u → Type u} → [q : QPF F] → Prop
A qpf is said to be uniform if every polynomial functor representing a single value all have the same range.
def QPF.LiftpPreservation E1 #
{F : Type u → Type u} → [q : QPF F] → Prop
does abs preserve Liftp?
def QPF.SuppPreservation E1 #
{F : Type u → Type u} → [q : QPF F] → Prop
does abs preserve supp?
theorem QPF.supp_eq_of_isUniform E1 #
∀ {F : Type u → Type u} [q : QPF F],
QPF.IsUniform →
∀ {α : Type u} (a : (QPF.P F).A) (f : (QPF.P F).B a → α),
Functor.supp (QPF.abs (PFunctor.Obj.mk a f)) = f '' Set.univ
theorem QPF.liftp_iff_of_isUniform E1 #
∀ {F : Type u → Type u} [q : QPF F],
QPF.IsUniform → ∀ {α : Type u} (x : F α) (p : α → Prop), Functor.Liftp p x ↔ ∀ u ∈ Functor.supp x, p u
theorem QPF.supp_map E1 #
∀ {F : Type u → Type u} [q : QPF F],
QPF.IsUniform → ∀ {α β : Type u} (g : α → β) (x : F α), Functor.supp (g <$> x) = g '' Functor.supp x
theorem QPF.suppPreservation_iff_uniform E1 #
∀ {F : Type u → Type u} [q : QPF F], QPF.SuppPreservation ↔ QPF.IsUniform
theorem QPF.suppPreservation_iff_liftpPreservation E1 #
∀ {F : Type u → Type u} [q : QPF F], QPF.SuppPreservation ↔ QPF.LiftpPreservation
theorem QPF.liftpPreservation_iff_uniform E1 #
∀ {F : Type u → Type u} [q : QPF F], QPF.LiftpPreservation ↔ QPF.IsUniform