We are currently working on new rules that expand the scope of this website to allow more content, and are looking for feedback! See Esolanging:2026 topicality proposal to view and give feedback on the current draft.

User draft:PkmnQ/HOT combinator draft

From Esolanging
Jump to navigationJump to search

It seems that there are no other explorations of HOT terms aside from [1] and [2], which leaves me with some questions.

Classifying terms

There are two trivial static checks that can be performed to check that a term is HOT.

  • If, when expressed in De Bruijn notation, the term only uses indices 0 and 1, it is HOT.
    • This can easily be seen using the transformation λ M -> (λ λ M) 0 (or (λ λ M) I for the outermost lambda); each lambda abstraction becomes its own self-contained HOT term. For example, \x. x (\y. y x (\z. z y)) = λ 0 (λ 0 1 (λ 0 1)) becomes (λ λ 0 ((λ λ 0 1 ((λ λ 0 1) 0)) 0)) I, which can more obviously be expressed as a HOT term:
A1 x y = y x
A2 x y = y x (A1 y)
A3 x y = y (A2 y)
A3 I = λ 0 (λ 0 1 (λ 0 1))
  • If the term uses only two unique variables, it is HOT.
    • This can easily be seen by turning abstractions whose variables are not used into K. For example, \x. \y. \z. z x becomes \x. K (\z. z x), which can be expressed as a HOT term using a transformation similar to the above:
A1 x y = y x
A2 x y = K (A1 y)
A2 I = \x. \y. \z. z x

The following Python code returns potentially non-HOT terms, i.e. those that don't fall to one of the two trivial checks.

import functools, itertools

@functools.cache
def enumerate_terms(size, depth=0):
    if size == 0:
        return tuple(range(depth))
    x = [(term,) for term in enumerate_terms(size-1, depth+1)]
    for i in range(size):
        x += itertools.product(enumerate_terms(i, depth), enumerate_terms(size-i-1, depth))
    return tuple(x)

def stringify_term(term):
    if isinstance(term, int):
        return f"{term}"
    if len(term) == 1:
        return f"λ {stringify_term(term[0])}"
    left_side = stringify_term(term[0])
    if isinstance(term[0], tuple) and len(term[0]) == 1:
        left_side = f"({left_side})"
    right_side = stringify_term(term[1])
    if isinstance(term[1], tuple):
        right_side = f"({right_side})"
    return f"{left_side} {right_side}"

def simplify_term(term):
    def substitute_term(term1, term2, depth=0):
        def deepen_term(term, depth=0):
            if isinstance(term, int):
                return term if term < depth else term + 1
            if len(term) == 1:
                return (deepen_term(term[0], depth+1),)
            return (deepen_term(term[0], depth), deepen_term(term[1], depth))
        if isinstance(term1, int):
            return term2 if term1 == depth else (
                term1-1 if term1 > depth else term1
            )
        if len(term1) == 1:
            return (substitute_term(term1[0], deepen_term(term2), depth+1),)
        return (substitute_term(term1[0], term2, depth), substitute_term(term1[1], term2, depth))
    if isinstance(term, int):
        return term
    if len(term) == 1:
        inner_term = simplify_term(term[0])
        if (
            isinstance(inner_term, tuple) and len(inner_term) == 2 and
            inner_term[1] == 0 and count_term(inner_term[0], (0,), {0: 0})[0] == 0
        ):
            return inner_term[0]
        return (inner_term,)
    if isinstance(term[0], tuple) and len(term[0]) == 1:
        return substitute_term(term[0][0], term[1])
    return (simplify_term(term[0]), simplify_term(term[1]))

def count_term(term, names=(), name_counter=None):
    if name_counter is None:
        name_counter = {}
    if isinstance(term, int):
        if term < len(names):
            name_counter[names[~term]] += 1
    elif len(term) == 1:
        name_counter[new_name := len(name_counter)] = 0
        count_term(term[0], (*names, new_name), name_counter)
    else:
        count_term(term[0], names, name_counter)
        count_term(term[1], names, name_counter)
    return name_counter

def easily_hot(term):
    def hot_check_1(term):
        if isinstance(term, int):
            return term < 2
        if len(term) == 1:
            return hot_check_1(term[0])
        return hot_check_1(term[0]) and hot_check_1(term[1])
    def hot_check_2(term):
        name_counts = count_term(term)
        return len([i for i in name_counts.values() if i]) <= 2
    def expression_check(term):
        return (
            hot_check_1(term) or hot_check_2(term)
        )
    current_term = term
    for _ in range(100):
        if expression_check(current_term):
            return True
        current_term = simplify_term(current_term)
    return expression_check(current_term)

with open("cold_terms.txt", "w", encoding="utf8") as f:
    for term in enumerate_terms(5):
        if not easily_hot(term):
            f.write(f"{stringify_term(term)}\n")

All terms of Fokker size four or lower can be checked to be trivially HOT using the above code.

B is known to not be HOT, meaning there's at least one of Fokker size five; running the code gives eleven candidates:

Q4 = λ λ λ 0 (1 2) = \x. \y. \z. z (y x)
Q3 = λ λ λ 0 (2 1) = \x. \y. \z. z (x y)
Q2 = λ λ λ 1 (0 2) = \x. \y. \z. y (z x)
Q = λ λ λ 1 (2 0) = \x. \y. \z. y (x z)
Q1 = λ λ λ 2 (0 1) = \x. \y. \z. x (z y)
B = λ λ λ 2 (1 0) = \x. \y. \z. x (y z)
F = λ λ λ 0 1 2  = \x. \y. \z. z y x
V = λ λ λ 0 2 1  = \x. \y. \z. z x y
R = λ λ λ 1 0 2 = \x. \y. \z. y z x
C = λ λ λ 2 0 1 = \x. \y. \z. x z y
X11 = λ λ 0 (λ 0 2) = \x. \y. y (\z. z x)

Of these, three can be proven to be HOT manually:

Q4 x y = T (y x)
Q3 x y = T (x y)
X11 x y = y (T x)

This leaves behind these eight, which are provably not HOT:

Q2 = λ λ λ 1 (0 2) = \x. \y. \z. y (z x)
Q = λ λ λ 1 (2 0) = \x. \y. \z. y (x z)
Q1 = λ λ λ 2 (0 1) = \x. \y. \z. x (z y)
B = λ λ λ 2 (1 0) = \x. \y. \z. x (y z)
F = λ λ λ 0 1 2  = \x. \y. \z. z y x
V = λ λ λ 0 2 1  = \x. \y. \z. z x y
R = λ λ λ 1 0 2  = \x. \y. \z. y z x
C = λ λ λ 2 0 1  = \x. \y. \z. x z y
  • B is already proven in the above two papers.
  • Q can be trivially used to define B:
B x y = Q y x
  • F and V can be used to form arbitrary Church pairs, allowing two arguments to be "packed" into one:
Б x y = x K (x K' y)
B x y = Б (V x y) = Б (F y x)
  • C and R can be used to rearrange Q3 into B:
Q3 x y = T (x y)
B x y = C (Q3 y) x = R x (Q3 y)
  • Q1 and Q2 can be used to form F, which as above also leads to B:
F x y = Q1 (T x) y = Q2 y (T x)

The code gives 314 candidates for Fokker size six.

A table of combinators and their HOT expressions and ranks

Table of Selected Combinators
Combinator Name Formula HOT expression HOT rank
B Bluebird Bxyz=x(yz) Not HOT
B1 Blackbird B1xyzw=x(yzw) Not HOT
B2 Bunting B2xyzwv=x(yzwv) Not HOT
B3 Becard B3xyzw=x(y(zw)) Not HOT
C Cardinal Cxyz=xzy Not HOT
D Dove Dxyzw=xy(zw) Not HOT
D1 Dickcissel D1xyzwv=xyz(wv) Not HOT
D2 Dovekie D2xyzwv=x(yz)(wv) Not HOT
E Eagle Exyzwv=xy(zwv) Not HOT
Ê Bald eagle Êxyzwvut=x(yzw)(vut) Not HOT
F Finch Fxyz=zyx Not HOT
G Goldfinch Gxyzw=xw(yz) Not HOT
H Hummingbird Hxyz=xyzy Not HOT
I Identity bird Ix=x
K' x y = y
I = K' K
1
J Jay bird Jxyzw=xy(xwz) Not HOT
K Kestrel Kxy=x
K x y = x
1
K' Kite K'xy=y
K' x y = y
1
L Lark Lxy=x(yy)
L x y = x (y y)
1
M Mockingbird Mx=xx
A x y = y y
M = A K
1
M2 Double mockingbird M2xy=xy(xy)
M2 x y = x y (x y)
1
O Owl Oxy=y(xy)
O x y = y (x y)
1
Q Queer bird Qxyz=y(xz) Not HOT
Q1 Quixotic bird Q1xyz=x(zy) Not HOT
Q2 Quizzical bird Q2xyz=y(zx) Not HOT
Q3 Quirky bird Q3xyz=z(xy)
T x y = y x
Q3 x y = T (x y)
2
Q4 Quacky bird Q4xyz=z(yx)
T x y = y x
Q4 x y = T (y x)
2
R Robin Rxyz=yzx Not HOT
S Starling Sxyz=xz(yz) Not HOT
S' Converse starling S'xyz=yz(xz) Not HOT
T Thrush Txy=yx
T x y = y x
1
U Turing bird Uxy=y(xxy)
U x y = y (x x y)
1
V Vireo Vxyz=zxy Not HOT
W Warbler Wxy=xyy
W x y = x y y
1
W' Converse warbler W'xy=yxx
W' x y = y x x
1
I* Identity bird once removed I*xy=xy
I x y = x y
1
W* Warbler once removed W*xyz=xyzz
W x y = x y y
W* x y = W (x y)
2
C* Cardinal once removed C*xyzw=xywz Not HOT
R* Robin once removed R*xyzw=xzwy Not HOT
F* Finch once removed F*xyzw=xwzy Not HOT
V* Vireo once removed V*xyzw = xwyz Not HOT
W** Warbler twice removed W**xyzw=xyzww
W x y = x y y
W* x y = W (x y)
W** x y = W* (x y)
3
C** Cardinal twice removed C**xyzwv=xyzvw Not HOT
R** Robin twice removed R**xyzwv=xywvz Not HOT
F** Finch twice removed F**xyzwv=xyvwz Not HOT
V** Vireo twice removed V**xyzwv=xyvzw Not HOT
Θ or Y Sage bird Θx=x(Θx)
U x y = y (x x y)
Θ = U U
1
ϕ Phoenix ϕxyzw=x(yw)(zw) Not HOT
Ψ Psi bird Ψxyzw=x(yz)(yw) Not HOT
ω Omega bird [unsourced] ω=MM
A x y = y y
ω = A K (A K)
1
ι Iota (not a bird) ιx=xSK Not HOT

Quantifying power