Documentation

Linglib.Core.Data.Tree.Encodable

Binary trees are encodable #

A binary tree is a W-type: its shapes are a leaf and a node labelled by a value, with no children and two children respectively. Mathlib's W-types over encodable shapes with finite encodable arities are encodable, so binary trees over an encodable type are too, and binary trees over a countable type are countable. Mathlib.Data.Tree.Basic provides neither instance.

Main declarations #

[UPSTREAM] candidate for Mathlib.Data.Tree.Basic.

def BinaryTree.WArity {α : Type u_1} :
Option α → Type

The arity of a binary-tree shape: a leaf has no children and a node two.

Equations
Instances For
    @[instance_reducible]
    instance BinaryTree.instFintypeWArity {α : Type u_1} (a : Option α) :
    Fintype (WArity a)
    Equations
    @[instance_reducible]
    instance BinaryTree.instEncodableWArity {α : Type u_1} (a : Option α) :
    Encodable (WArity a)
    Equations
    def BinaryTree.toWType {α : Type u_1} :
    BinaryTree α → WType WArity

    A binary tree as a W-type: a leaf has the shape none, a node the shape of its value, with its left subtree at true and its right subtree at false.

    Equations
    Instances For
      def BinaryTree.ofWType {α : Type u_1} :
      WType WArity → BinaryTree α

      A W-type of binary-tree shapes as a binary tree.

      Equations
      Instances For
        theorem BinaryTree.ofWType_toWType {α : Type u_1} (t : BinaryTree α) :
        @[instance_reducible]
        instance BinaryTree.instEncodable_linglib {α : Type u_1} [Encodable α] :
        Encodable (BinaryTree α)
        Equations
        instance BinaryTree.instCountable_linglib {α : Type u_1} [Countable α] :
        Countable (BinaryTree α)