esolang

S₅

Eight words, every one a form of "set", over ordered sets of sets.

Gribnit, 2026 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: 2

The idea

Gribnit made S₅ in 2026. Every token is a form of the word set, and all data are ordered sets of sets. There are no numbers in memory. A set has a value instead. Read its elements from left to right starting at 0; an empty element adds 1 and any other element doubles. So {∅, {∅}, ∅} is 3, and 42 takes eight elements.

Read the story

The same rule turns words into integers. set adds 1 and sets doubles, so set sets set is 3. The only branch is a call that runs when a set is not empty, and the only loop is a call. The specification shows it is Turing complete with a Bitwise Cyclic Tag interpreter.

The machine

The universe U starts as {∅} and the cache C starts unbound. An instruction is Set, an opcode and its addresses.

WordsDoes
Set sets A B set DD = A ∪ B, the elements of both in order
Set Set's A B set DD = the elements of A that appear in B
Set set A B set DD = the elements of A that do not appear in B
Set Sets set sets' NC = C[N]
Set Sets' ACall the subroutine in A, or in C
Set Sets' set X ACall it only when X is not empty
Sets' Sets' A ... Sets'Define a subroutine and store it in A, or in C
AddressIs
Set's sets Set's setU and C
Sets sets sets' N Sets set sets' NU[N] and C[N]
Sets sets' A{A}, the set that holds A
set's'A number line in, a number line out
sets set's'One byte in, the value as bytes out

An address may end in sets' N, which reads the value N more times as an index into U. The run halts as soon as U is empty. A byte 0 reads as {{∅}}, which is not empty, so only the end of input reads as ∅.

This implementation leaves out the .s5b binary I/O, whose token codes the specification does not give.

Example

The first prints the value of U ∪ U, which is {∅, ∅}.
Expected: 42

The first prints the value of U ∪ U, which is {∅, ∅}. The second reads 42 as the set {∅, {∅}, {∅}, ∅, {∅}, {∅}, ∅, {∅}}, takes away the elements of U[0], which is ∅ and has none, and prints the value.

The cat stores two subroutines at U[1] and U[2]. The first reads a byte into C and calls the second when C is not empty; the second writes C and calls the first. Each call ends its body, so it takes that body's place and the loop runs in constant space.

Expected: cat

Patterns it teaches

Further

Tree-based

Generated by AI

Write your own in Run Convert a program from S₅

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: s5.

Command line

shib run s5 -e 'Set sets Set'\''s sets Set'\''s sets set set'\''s'\'''
shib manual s5

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/s5.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org