W types #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
Given α : Type
and β : α → Type
, the W type determined by this data, W_type β
, is the
inductively defined type of trees where the nodes are labeled by elements of α
and the children of
a node labeled a
are indexed by elements of β a
.
This file is currently a stub, awaiting a full development of the theory. Currently, the main result
is that if α
is an encodable fintype and β a
is encodable for every a : α
, then W_type β
is
encodable. This can be used to show the encodability of other inductive types, such as those that
are commonly used to formalize syntax, e.g. terms and expressions in a given language. The strategy
is illustrated in the example found in the file prop_encodable
in the archive/examples
folder of
mathlib.
Implementation details #
While the name W_type
is somewhat verbose, it is preferable to putting a single character
identifier W
in the root namespace.
Given β : α → Type*
, W_type β
is the type of finitely branching trees where nodes are labeled by
elements of α
and the children of a node labeled a
are indexed by elements of β a
.
Instances for W_type
- W_type.has_sizeof_inst
- W_type.inhabited
- W_type.is_empty
- W_type.encodable
Equations
The canonical map to the corresponding sigma type, returning the label of a node as an
element a
of α
, and the children of the node as a function β a → W_type β
.
The canonical bijection with the sigma type, showing that W_type
is a fixed point of
the polynomial functor X ↦ Σ a : α, β a → X
.
Equations
- W_type.equiv_sigma β = {to_fun := W_type.to_sigma β, inv_fun := W_type.of_sigma (λ (a : α), β a), left_inv := _, right_inv := _}