# Documentation

Mathlib.Data.W.Basic

# W types #

Given α : Type and β : α → Type→ Type, the W type determined by this data, WType β, 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 WType β 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 WType is somewhat verbose, it is preferable to putting a single character identifier W in the root namespace.

inductive WType {α : Type u_1} (β : αType u_2) :
Type (maxu_1u_2)
• mk: {α : Type u_1} → {β : αType u_2} → (a : α) → (β a) →

Given β : α → Type _→ Type _, WType β 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
Equations
def WType.toSigma {α : Type u_1} {β : αType u_2} :
(a : α) × (β a)

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 → WType β→ WType β.

Equations
• = match x with | WType.mk a f => { fst := a, snd := f }
def WType.ofSigma {α : Type u_1} {β : αType u_2} :
(a : α) × (β a)

The canonical map from the sigma type into a WType. Given a node a : α, and its children as a function β a → WType β→ WType β, return the corresponding tree.

Equations
• = match x with | { fst := a, snd := f } => WType.mk a f
@[simp]
theorem WType.ofSigma_toSigma {α : Type u_1} {β : αType u_2} (w : ) :
@[simp]
theorem WType.toSigma_ofSigma {α : Type u_1} {β : αType u_2} (s : (a : α) × (β a)) :
@[simp]
theorem WType.equivSigma_symm_apply {α : Type u_1} (β : αType u_2) :
∀ (a : (a : α) × (β aWType fun a => β a)), ↑() a =
@[simp]
theorem WType.equivSigma_apply {α : Type u_1} (β : αType u_2) :
∀ (a : ), ↑() a =
def WType.equivSigma {α : Type u_1} (β : αType u_2) :
(a : α) × (β a)

The canonical bijection with the sigma type, showing that WType is a fixed point of the polynomial functor X ↦ Σ a : α, β a → X↦ Σ a : α, β a → X→ X.

Equations
• One or more equations did not get rendered due to their size.
def WType.elim {α : Type u_1} {β : αType u_2} (γ : Type u_3) (fγ : (a : α) × (β aγ)γ) :
γ

The canonical map from WType β into any type γ given a map (Σ a : α, β a → γ) → γ→ γ) → γ→ γ.

Equations
theorem WType.elim_injective {α : Type u_2} {β : αType u_3} (γ : Type u_1) (fγ : (a : α) × (β aγ)γ) (fγ_injective : ) :
instance WType.instIsEmptyWType {α : Type u_1} {β : αType u_2} [hα : ] :
Equations
theorem WType.infinite_of_nonempty_of_isEmpty {α : Type u_2} {β : αType u_1} (a : α) (b : α) [ha : Nonempty (β a)] [he : IsEmpty (β b)] :
def WType.depth {α : Type u_1} {β : αType u_2} [inst : (a : α) → Fintype (β a)] :

The depth of a finitely branching tree.

Equations
theorem WType.depth_pos {α : Type u_1} {β : αType u_2} [inst : (a : α) → Fintype (β a)] (t : ) :
0 <
theorem WType.depth_lt_depth_mk {α : Type u_1} {β : αType u_2} [inst : (a : α) → Fintype (β a)] (a : α) (f : β a) (i : β a) :
instance WType.instEncodableWType {α : Type u_1} {β : αType u_2} [inst : (a : α) → Fintype (β a)] [inst : (a : α) → Encodable (β a)] [inst : ] :

WType is encodable when α is an encodable fintype and for every a : α, β a is encodable.

Equations
• One or more equations did not get rendered due to their size.