From Esolang
Jump to navigation Jump to search
Paradigm(s) not specified
Designed by User:Grom
Appeared in 2021
Computational class Turing complete
Major implementations Unimplemented
File extension(s) .grain

Grain is a theoretical programming language in which all functions can be infinitely recursively derived from combinations of other functions.

User:Grom believes it could be possible to implement such a language in an efficient and relatively deterministic manner without rounded floating points.

Essentially the language boils down to two concepts/problems:

The first is how to create varied functional effects from large integers. This will be achieved via a function called the granulator (herein simply "𝔾").

The second is to, given any number A, produce an ordered combination of functions (integers) that when applied successively (ie: f(g(h(j(x)))) ) maps the domain of 𝔾(A) to the codomain of 𝔾(A)


A(x) = f(g(h(i(x))))

𝕄(A)(x) = f(g(h(i(x))))

𝕄(A) = (f, g, h, i)

𝕄'(f(x), g(x), h(x), i(x)) = A(x)

The function that produces this combination of functions will herein be referred to as the Master Function, or simply "𝕄".

Formal Definition of 𝕄 and 𝔾

For all integers x,

- 𝔾(𝕄(x)) is a function which exists in the co-domain of 𝔾.

- 𝔾(x) shares the same mapping as 𝔾(𝕄(x))

- 𝕄(x) does not contain x

More succinctly:

βˆ€xβˆˆβ„€ (βˆ€nβˆˆβ„€ 𝔾(x)(n) = 𝔾(𝕄(x))(n) β‹€ (𝕄(x) β‹‚ x = βˆ…) β‹€ (𝔾(𝕄(x)) β‹‚ 𝔾 β‰  βˆ…))

Properties of the Master Function

- reversible

- O(1) time

(The resulting function composition can be computed mathematically (as opposed to iteratively) directly from func with 𝕄(func) )

Evidence of viability

To prove that some non zero amount of viable Master Functions exist, consider some 𝕄 wherein:


𝔾(x) ∈ {f(n) = n+1, g(n) = n-1, h(n) = n+2, i(n) = n-2}

βˆ€xβˆˆβ„€ (𝔾(x)(n) = n+1 = f(n) | 𝔾(𝕄(x))(n) = g(h(n)) = n+2-1 = n+1)

βˆ€xβˆˆβ„€ (𝔾(x)(n) = n-1 = g(n) | 𝔾(𝕄(x))(n) = f(i(n)) = n-2+1 = n-1)

βˆ€xβˆˆβ„€ (𝔾(x)(n) = n+2 = h(n) | 𝔾(𝕄(x))(n) = f(f(n)) = n+1+1 = n+2)

βˆ€xβˆˆβ„€ (𝔾(x)(n) = n-2 = i(n) | 𝔾(𝕄(x))(n) = g(g(n)) = n-1-1 = n-2)

This is not a very interesting 𝕄 or 𝔾, not only is 𝔾 of finite cardinality, but βˆ€xβˆˆβ„€ card|𝕄(x)| = 2.