We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Cornucopia

From Esolang
Jump to navigation Jump to search
Cornucopia
Paradigm(s) Functional
Designed by User:Hakerh400
Appeared in 2026
Computational class Unknown
Major implementations Implemented
File extension(s) .txt

Cornucopia is an esolang invented by User:Hakerh400 in 2026.

Overview

Functions operate on natural numbers. There are only two built-in functions:

  • succ(n) - returns the successor of n
  • sub(n, m) - returns the difference n - m, or 0 if n < m

User can define any number of functions, but there must be a unary function named main that represents the entry point. Functions that take no arguments are called constants.

If there exists a unique assignment of functions that satisfy all the definitions, then the program is executed. Otherwise (the definitions are contradictory, or have multiple models) throw an error.

For example, program main(n) := succ(main(n)) is invalid, because there is no such function. Similarly, main(n) := main(n) is also invalid, because all functions satisfy that equation.

Example

In this example the main function is just the identity function. The intention here is to show how to implement constants 0 and 1, boolean negation, and finally addition of natural numbers. It has been formally verified that add(a, b) in this program correctly implements the sum a + b for all natural numbers a and b. In other words, there exists a unique assignment of constants 0, 1 and functions not, bool, add and main that satisfies all the equations in this program.

0 := sub(0, 0)
1 := succ(0)
not(a) := sub(1, a)
bool(a) := not(not(a))
add(a, b) := sub(sub(sub(succ(succ(add(sub(a, 1), sub(b, 1)))), not(a)), not(b)), add(0, 0))
main(a) := a

Computational class

The requirement that there exists a unique assignment of functions satisfying the definitions is probably undecidable, so the language is hypercomputable. It is also unknown whether the language is Turing complete.

External resources