Bud generating systems on colored binary trees #
A bud generating system ([Gir19]) equips an operad with a set of
colors, a set of colored operations (the rules), and a set of terminal
colors; the generated language is the set of colored operations derivable
from a single-color unit by color-matching operad composition. This file
develops the construction over the free binary operad, whose operations are
binary trees and whose insertions graft a tree onto a leaf. A Bud.Tree
carries a color at every vertex: leaf colors are the operation's inputs,
the root color its output, and the internal colors record the colors
matched during composition — in a colored operad the color at a grafting
vertex is determined by the matched pair, so the decorations are exactly
the data of a decomposition into generators.
Main declarations #
Bud.Tree,Bud.Tree.out,Bud.Tree.inputs— vertex-colored binary trees with their output and input colors.Bud.Tree.graft— insertion at thei-th leaf, the free binary operad's partial composition;Bud.Tree.graft_graftis the nested-insertion relation.Bud.Tree.NodeLocal— a predicate holds at every internal vertex; the invariant format preserved by color-matched grafting.Bud.System,Bud.System.Derives,Bud.System.Lang— bud generating systems with initial colors the non-terminal ones ([Gir19]'sI = Ω ∖ Tcase), derivability from a unit, and the generated language.Bud.System.Derives.compose— derivations compose along color-matched inputs;Bud.System.Derives.nodeLocal— any vertex-local property of the rules holds throughout every derivable tree.
Implementation notes #
Bud generating systems are the operadic analogue of context-free
grammars, with trees in place of words ([Gir19] develops the
correspondence); this file follows the register of
Mathlib.Computability.ContextFreeGrammar — a rule set, an inductive
derivation relation, and the generated language — with colors playing the
role of Symbol and the terminal-color set replacing the
terminal/nonterminal type split. Mathlib's SimpleGraph.Coloring is not
applicable: proper graph coloring constrains adjacent colors to differ,
while operadic coloring constrains composed colors to match.
A binary tree with a color at every vertex: an operation of the bud operad over the free binary operad, decorated with the colors it propagates ([Gir19]).
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Bud.instDecidableEqTree.decEq (Bud.Tree.leaf a) (Bud.Tree.leaf b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Bud.instDecidableEqTree.decEq (Bud.Tree.leaf c) (Bud.Tree.node c_1 l r) = isFalse ⋯
- Bud.instDecidableEqTree.decEq (Bud.Tree.node c l r) (Bud.Tree.leaf c_1) = isFalse ⋯
Instances For
Equations
- Bud.instReprTree = { reprPrec := Bud.instReprTree.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
The output color: the color at the root.
Equations
- (Bud.Tree.leaf a).out = a
- (Bud.Tree.node a a_1 a_2).out = a
Instances For
The input colors: the leaf colors, left to right.
Equations
- (Bud.Tree.leaf a).inputs = [a]
- (Bud.Tree.node a a_1 a_2).inputs = a_1.inputs ++ a_2.inputs
Instances For
The number of inputs.
Equations
- (Bud.Tree.leaf a).numInputs = 1
- (Bud.Tree.node a a_1 a_2).numInputs = a_1.numInputs + a_2.numInputs
Instances For
Graft s onto the i-th leaf of x: the free binary operad's
insertion x ∘ᵢ s. Out-of-range indices leave the tree unchanged.
Equations
- (Bud.Tree.leaf c).graft 0 x✝ = x✝
- (Bud.Tree.leaf c).graft n.succ x✝ = Bud.Tree.leaf c
- (Bud.Tree.node c l r).graft x✝¹ x✝ = if x✝¹ < l.numInputs then Bud.Tree.node c (l.graft x✝¹ x✝) r else Bud.Tree.node c l (r.graft (x✝¹ - l.numInputs) x✝)
Instances For
P holds at every internal vertex, of the vertex color and the two
children's output colors.
Equations
- Bud.Tree.NodeLocal P (Bud.Tree.leaf a) = True
- Bud.Tree.NodeLocal P (Bud.Tree.node a a_1 a_2) = (P a a_1.out a_2.out ∧ Bud.Tree.NodeLocal P a_1 ∧ Bud.Tree.NodeLocal P a_2)
Instances For
Color-matched grafting preserves vertex-local properties: the host's vertices keep their colors (the replaced leaf's color equals the inserted root's), and the inserted tree brings its own.
Derivability from the unit of color c: start from the one-leaf tree
and repeatedly graft rules onto color-matched leaves.
- unit {Ω : Type u_1} {B : System Ω} {c : Ω} (hc : ¬c ∈ B.Terminal) : B.Derives c (Tree.leaf c)
- graft {Ω : Type u_1} {B : System Ω} {c : Ω} {x s : Tree Ω} (i : ℕ) (hx : B.Derives c x) (hs : s ∈ B.rules) (hm : x.inputs[i]? = some s.out) : B.Derives c (x.graft i s)
Instances For
Derivations compose along a color-matched input: a derivation of the matched color can be carried out in place inside the host.
Any vertex-local property of the rules holds throughout every derivable tree: the fundamental invariant of bud derivation.
Bottom-up node formation: when the one-node operation on the parts' output colors is a rule, joining two derivable trees under it is derivable — top-down bud derivation subsumes bottom-up structure building.