Documentation

Linglib.Theories.Syntax.Minimalism.Formal.MCB2023.BinaryOptimality

n-ary trees (generalized Merge) #

inductive Minimalism.NaryTree (n : ) :

n-ary tree: generalization of SyntacticObject to n-ary branching. When n = 2 this recovers binary trees (= SyntacticObject). When n ≥ 3 this models hypothetical n-ary Merge.

Instances For

    Leaf count of an n-ary tree

    Equations
    Instances For

      Achievable leaf counts (Lemma 4.4) #

      For n-ary trees:

      The set of leaf counts achievable by n-ary trees

      Equations
      Instances For

        A single leaf achieves count 1 for any arity

        Binary trees achieve leaf count 2 (a single node with two leaves)

        Replace the leftmost leaf of a binary tree with a node of two leaves. This increases leafCount by exactly 1.

        Equations
        Instances For

          Binary trees achieve all leaf counts k ≥ 1.

          Proof: induction on k. Base k=1: single leaf. Step: expand a leaf to get one more, via expandLeaf which increases leafCount by exactly 1.

          Node count of an n-ary tree

          Equations
          Instances For
            theorem Minimalism.nary_leaf_node_relation {n : } (hn : n 2) (t : NaryTree n) :
            t.leafCount = t.nodeCount * (n - 1) + 1

            For n-ary trees, leafCount = nodeCount * (n-1) + 1. This is the key structural invariant that implies the modular constraint.

            theorem Minimalism.nary_leaf_count_mod {n : } (hn : n 2) (t : NaryTree n) :
            (t.leafCount - 1) % (n - 1) = 0

            For n-ary trees (n ≥ 2), leaf count k must satisfy k ≡ 1 (mod n-1).

            Each n-ary node replaces 1 "slot" with n children, net gain of n-1 leaves. Starting from 1 leaf, after j nodes we have j(n-1) + 1 leaves.

            theorem Minimalism.nary_misses_two (n : ) (hn : n 3) :

            For n ≥ 3, not all leaf counts are achievable. Specifically, 2 is not achievable when n ≥ 3 (since 2-1 = 1 is not divisible by n-1 ≥ 2).

            theorem Minimalism.binary_unique_optimal (n : ) (hn : n 2) (h : k1, k achievableLeafCounts n) :
            n = 2

            Binary Merge is uniquely optimal: it's the only n ≥ 2 that achieves all leaf counts (Lemma 4.4).

            Catalan bridge #

            The number of binary tree shapes with n internal nodes equals the nth Catalan number. We connect this to SyntacticObject via the FreeMagma equivalence.

            @[reducible, inline]

            Binary tree shape: SO with Unit tokens (only tree structure matters)

            Equations
            Instances For

              The nodeCount of an SO equals the nodeCount of its FreeMagma image

              Internal node count = FreeMagma.length - 1 for FreeMagma trees

              SO.nodeCount = FreeMagma.length - 1 via the isomorphism. Bridges leaf_node_relation to FreeMagma.length.

              Map an SO to its shape (forget token identity, keep tree structure)

              Equations
              Instances For

                The number of binary tree shapes with n internal nodes equals the nth Catalan number.

                This is a direct application of mathlib's treesOfNumNodesEq_card_eq_catalan, which counts Tree Unit shapes. The connection to SyntacticObject goes through the FreeMagma ≃ SO equivalence and the well-known bijection between full binary trees and Tree Unit.