Grain
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)
ie:
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ββ€
πΎ(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
.