Tree calculus is minimal, Turing-complete, reflective, modular


                                                                                                                                                                                    



Tree Calculus was discovered by Barry Jay. Check out his book and blog!
The demos on this website were developed by Johannes Bader.
See here for more background, resources and contact info.


  • Minimal

    There is one operator β–³ that computes whenever it is acting on three values. Grammar: E ::= β–³ | E E

    Visually, β–³ is a tree node and the application of E1 to E2 attaches E2 to the root of E1 on the right. This forms trees like that in the picture above. Values are natural binary trees. We call their nodes leaves, stems or forks.

    Practical consequences

    πŸš€ Demo: Trivial, safe interpreters on any platform.
    πŸš€ Demo: Good fit for cross-plat config generation.

  • Turing-complete

    1. K=β–³ β–³

    2. S x=β–³ (β–³ x)

    Unlike Ξ»-calculus, recursive functions can be represented as normal forms, using fixpoint constructions like orange/brown in the picture above.

  • Reflective

    triage{l,s,f}=β–³ (β–³ l s) f performs case analysis on leafs, stems and forks.

    We can represent natural number n as β–³nβ–³. The zero test is triage{true, Kfalse, K2false}.

    Since programs are also values, intensional programs can be self-applied, to achieve reflection. The picture above shows program size, which computes its argument’s number of nodes. For instance, size  size evaluates to 180.

    Practical consequences

    πŸš€ Demo: Abillity to serialize programs.
    πŸš€ Demo: Simpler formulation of the halting problem.
    πŸš€ Demo: Program analysis/optimization as a function.
    πŸš€ Demo: Static vs dynamic typing? Just function calls.

  • Modular

    Sub-terms are represented as sub-trees. The size program pictured at the top of this page uses triage { (+ 0), Ξ»u. (+ size u), Ξ»uv. (+ size u) ∘ (+ size v) } ∘ (+ 1) to count nodes recursively.

    Practical consequences

    πŸš€ Demo: Common functionality is easy to bootstrap.
    πŸš€ Demo: Powerful programs need not be large trees.

  • Democratizing functions

  • Democratizing metatheory