Examples of W-types #
We take the view of W types as inductive types.
Given α : Type and β : α → Type, the W type determined by this data, WType β, is the
inductively with constructors from α and arities of each constructor a : α given by β a.
This file contains Nat and List as examples of W types.
Main results #
WType.equivNat: the construction of the naturals as a W-type is equivalent toNatWType.equivList: the construction of lists on a typeγas a W-type is equivalent toList γ
The constructors for the naturals
Instances For
Equations
- WType.instInhabitedNatα = { default := WType.Natα.zero }
The naturals are equivalent to their associated WType
Equations
- WType.equivNat = { toFun := WType.toNat, invFun := WType.ofNat, left_inv := WType.leftInverse_nat, right_inv := WType.rightInverse_nat }
Instances For
WType.Natα is equivalent to PUnit ⊕ PUnit.
This is useful when considering the associated polynomial endofunctor.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- WType.instInhabitedListα γ = { default := WType.Listα.nil }
Equations
- WType.instInhabitedListβCons γ hd = { default := PUnit.unit }
The isomorphism from lists to the WType construction of lists
Equations
- WType.ofList γ [] = WType.mk WType.Listα.nil PEmpty.elim
- WType.ofList γ (hd :: tl) = WType.mk (WType.Listα.cons hd) fun (x : WType.Listβ γ (WType.Listα.cons hd)) => WType.ofList γ tl
Instances For
The isomorphism from the WType construction of lists to lists
Equations
- WType.toList γ (WType.mk WType.Listα.nil f) = []
- WType.toList γ (WType.mk (WType.Listα.cons hd) f) = hd :: WType.toList γ (f PUnit.unit)
Instances For
Lists are equivalent to their associated WType
Equations
- WType.equivList γ = { toFun := WType.toList γ, invFun := WType.ofList γ, left_inv := ⋯, right_inv := ⋯ }
Instances For
WType.Listα is equivalent to γ with an extra point.
This is useful when considering the associated polynomial endofunctor
Equations
- One or more equations did not get rendered due to their size.