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
| 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. [1] There are only two built-in functions [2] [3] :
succ(n)- returns the successor ofnsub(n, m)- returns the differencen - m, or 0 ifn < m
User can define any number of functions, but there must be a unary function named main that represents the entry point. [4] Functions that take no arguments are called constants.
If there exists a unique [5] assignment of functions that satisfy all the definitions (the program has a unique model), then the program is executed. Otherwise (the definitions are contradictory, or have multiple models) throw an error.
Examples
All examples are formally verified and each claim about programs is supported by a proof. If you want to submit a new program or function, please discuss it on the talk page before updating the article.
Identity function
main(a) := a
This program represents the identity function. [6] It has a unique model. [7]
Loop
main(a) := main(a)
This program has infinitely many models and therefore is not a valid program. [8] [9]
Loop with successor
main(a) := succ(main(a))
This program does not have a model. [10]
Another loop with successor
main(a) := main(succ(a))
This program has infinitely many models (constant function for each natural number). [11] [12]
Constant one
main(a) := 1 1 := sub(succ(1), 1)
This program defines constant 1 that is equal to number 1. [13] The main function ignores the argument and outputs 1. [14] This program has a unique model. [15] This definition of constant 1 is submitted by User:Blashyrkh.
Arithmetic
main(a) := a 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)) ite(a, b, c) := sub(sub(sub(succ(ite(a, sub(b, 1), sub(c, 1))), sub(bool(a), b)), sub(not(a), c)), ite(a, 0, 0))
This program has a unique model. [16] The main function is just the identity function. [17] The intention is to show how to implement arithmetical functions.
- Constant
0has value 0. [18] - Constant
1has value 1. [19] - Unary function
nottakes a number; if the number is 0, returns 1, otherwise returns 0. [20] - Unary function
booltakes a number; if the number is 0, returns 0, otherwise returns 1. [21] - Binary function
addrepresents addition. [22]. - Ternary function
itetakes numbersa,bandc; ifais 0, returnsc, otherwise returnsb. [23] This function is submitted by User:PkmnQ.
Computational class
The requirement that there exists a unique assignment of functions satisfying the definitions is probably undecidable, so the language is maybe hypercomputable. It is also unknown whether the language is Turing complete.
External resources
- Implementation in Lean.