Convalescent

From Esolang
Jump to navigation Jump to search

Convalescent is a two-instruction esolang utilizing prime factors of integers. It was designed by User:Keymaker in 2024.

Program and execution

The program consists of two types of instructions ; and +. Instructions are executed deterministically from the first to the last, and after executing the last the program pointer moves back to the first. The memory is an unordered list of non-negative integers. Initially the list has one instance of the the smallest prime, 2. There is also the accumulator, a non-negative integer, initially 0. The program halts if the memory becomes empty (which can only happen after executing the + instruction), or if the + instruction is executed when the accumulator is 0 or 1. The instructions are:

  • ; increases the accumulator by one.
  • + causes the following effect (although an interpreter may arrive at the same end result differently):
1. Get the prime factorization of the accumulator's value. If the accumulator is 0 or 1 the program halts instead.
2. For every different value in the prime factorization, see if that type exists in the memory. If at least one instance is found in the memory, the instruction is considered successful.
3. If even one instance was found, this (step 3) is executed, otherwise not. For each different type of value in the prime factorization, it is seen if there are instances of that type in the memory. If there are no existing instances, then all the instances in the prime factorization are added to the memory. In case one or more instances exist, one instance is removed from the memory, and n-1 (where n is the number of instances in the prime factorization) are added to the memory.
4. If instruction was deemed successful in step 2 (even one instance of the prime factors was found to exist in the memory), the accumulator is set to 1, otherwise it is set to 0.

Because the programs can become immensely large and unstorable, there is an alternative format that in addition to understanding ; and + normally treats integers (positive, non-zero) written inside parentheses as that number of ; instructions.

Translation example

Here is a simple Minsky machine program:

1 inc A 2
2 inc A 3
3 inc B 4
4 inc B 5
5 dec A 4 6
6 halt

Run through the translator, this is the Convalescent translation in the alternative format:

(4)+(2277)+;;+
(697)+(205378)+(1926)+(1681)+(113692)+;;+
(1927)+(205378)+(2910)+(1681)+(171748)+;;+
(2911)+(2196)+(2172)+(1681)+(28248)+;;+
(2173)+(2196)+(1270)+(1681)+(16522)+;;+
(1271)+(58)+(2172)+(1681)+(1516)+;;+
(37)+(66)+;;+(4489)+;+

Computational class

The language is Turing-complete, which is shown via Minsky Machine translation. See external resources.

External resources

  • Convalescent information (detailed explanations of the language and the MM translation, translator program, interpreter in Python)