# Summary:

For any given language, what is the smallest amount of unique characters for your language to be Turing-Complete?

# Challenge:

For any language of your choice, find the smallest subset of characters that allows your language to be Turing-Complete. You may reuse your set of characters as many times as you want.

# Examples:

• JavaScript: +!()[] (http://www.jsfuck.com)

• Brainfuck: +<>[] (assumes a wrapping cell size)

• Python 2: ()+1cehrx (made from scripts like exec(chr(1+1+1)+chr(1)))

# Scoring:

This challenge is scored in characters, not bytes. For example, The scores for the examples are 6, 5, and 9.

# Notes:

• This challenge differentiates from others in the sense that you only your language to be Turing-Complete (not necessarily being able to use every feature of the language.)

• Although you can, please do not post answers without reducing the characters used. Example: Brainfuck with 8 characters (since every other character is a comment by default.)

• You MUST provide at least a brief explanation as to why your subset is Turing-Complete.

• Unary, 1 character. sighs – Dennis Feb 20 '17 at 15:24
• @Dennis It's not that different from Jelly or 05AB1E having a built-in for an interesting number theory problem. This challenge still seems like an interesting and non-trivial optimisation problem in any language that wasn't designed to be a tarpit. – Martin Ender Feb 20 '17 at 15:35
• @MartinEnder I'd be especially interested to see answers in languages like Java or C. – Julian Lachniet Feb 20 '17 at 15:41
• Please don't post solutions in esolangs where the solution is every valid character in the language. It's not intresting or clever. – Pavel Feb 20 '17 at 17:20
• @Pavel Not interesting or clever may mean that it shouldn't get upvoted, but certainly not that it shouldn't get posted. – Dennis Feb 20 '17 at 21:36

# Stacked, 5 chars

{!n:}


This is surprisingly short. If Stacked can implement each of the SKI combinations, then it is Turing Complete. Recap:

• I combinator - the identity function. x -> x
• K combinator - the constant function. x -> y -> x
• S combinator - the substitution function. (x, y, z) -> x(z)(y(z))

## I combinator: {!n}

Now, for the stacked specifics. {! ... } is an n-lambda. It is a unary function whose argument is implicitly n. Then, the last expression is returned from the function. Thus, {!n} is a function that takes an argument n and yields n.

## K combinator: {!{:n}}

Now, {:...} is a function that takes no arguments, and returns .... Combining this with our n-lambda formation, we get (adding whitespace for clarity):

{! { : n } }
{!         }   n-lambda. arguments: (n)
{ : n }     lambda.   arguments: ()
n       yields n.


## S Combinator: {n!nn!nnn:nnn{!n}!nn!nnn{!n}!n!!}

Ok, this looks a little more complicated. So, a lambda takes arguments, separated by non-identifier characters. Thus, the lambda in the header is equivalent to:

{n nn nnn:nnn{!n}!nn!nnn{!n}!n!!}


This is a lambda that takes three arguments, n, nn, and nnn. Let's replace these with x, y, and z for clarity:

{x y z:z{!n}!y!z{!n}!x!!}


The two {!n}! are just identity function to again avoid whitespace, where ! means "execute". So, again, reducing:

{x y z:z y!z x!!}


With an explanation:

{x y z:z y!z x!!}
{x y z:         }  three arguments
z y!        apply y to z -- y(z)
z x!    apply x to z -- x(z)
!   apply x(z) to y(z) -- x(z)(y(z))


And therefore, this is the S combinator.

• {n nn nnn:nnn{!n}!nn!nnn{!n}!n!!} contains spaces. – CalculatorFeline Jun 4 '17 at 1:20
• @CalculatorFeline Did you read the sentence before that? Ok, this looks a little more complicated. So, a lambda takes arguments, separated by non-identifier characters. Thus, the lambda in the header is equivalent to: – Conor O'Brien Jun 4 '17 at 1:29
• Oh. (Note to self: Stop being an idiot.) – CalculatorFeline Jun 4 '17 at 2:58

## tinylisp, 5 characters

(q d)


Using only the macros def and quote, we can implement the S and K combinators, which are Turing-complete. (Thanks to Qwerp-Derp for the inspiration.) Here it is all on one line:

(d dd (q (qq qq)))  (d dq (q ((qq) (dd (q (qqq)) (dd (q q) qq)))))  (d dqq (q ((qq) (dd (q (qqq)) (dd (q dqqd) (dd (q q) qq) (q qqq))))))  (d dqqd (q ((qq qqq) (dd (q (qqqq)) (dd (dd (dd (q q) qq) (q qqqq)) (dd (dd (q q) qqq) (q qqqq)))))))


The functions dq and dqq are the K and S combinators, respectively. They expect their arguments curried: i.e., for SKK you have to do ((dqq dq) dq), not (dqq dq dq). dd is a helper function that makes a list out of its arguments (a reimplementation of the list function in the standard library). dqqd is a partially curried helper function for dqq that takes arguments f and g (as opposed to dqq that takes only f).

Try it online! (with some test cases that implement the I combinator and the argument-reversing combinator S(K(SI))K).

(load lib/utilities)

(def K
(lambda (x)
(list (q (y)) (list (q q) x))))

(def S
(lambda (f)
(list (q (g)) (list (q S2) (list (q q) f) (q g)))))

(def S2
(lambda (f g)
(list (q (x)) (list (q S3) (list (q q) f) (list (q q) g) (q x)))))

(def S3
(lambda (f g x)
((f x)
(g x))))


Functions in tinylisp are simply lists with two elements: the parameters and the function body. For example, the function ((y) (q (1 2 3))) takes one argument, y, and returns the list (1 2 3) (which had to be quoted to prevent evaluation). So to return this function from another function, we only need to build the correct list. This is what K does. If we pass the list (1 2 3) to K, it is bound to K's parameter x, and we get:

(list (q q) x) -> literal q followed by value of x -> (q (1 2 3))
(list (q (y)) ...) -> literal (y) followed by the above -> ((y) (q (1 2 3)))


which is a function that takes one argument and always returns (1 2 3), as desired.

S and its helper functions work the same way. Passing func1 to S returns the list/function

((g) (S2 (q func1) g))


Passing func1 and func2 to S2 returns the list/function

((x) (S3 (q func1) (q func2) x))


And finally, passing func1, func2, and arg to S3 evaluates

((func1 arg) (func2 arg))


which implements the S-combinator.

To get from this more-readable form to the 5-character version, we replace the library macro lambda with the direct method of defining functions as lists: (lambda (x) (expr)) -> (q ((x) (expr))). We also reimplement list and call it dd:

(d dd    Define dd
(q      to be this list (which acts as a lambda function):
(qq     Take a list of variadic args qq
qq)))  and return the arglist


Then it's just a matter of renaming all the functions and arguments to use only ds and qs.

# Whispers v1, 7 characters

> 1+'⍎



The main idea is to build an arbitrary Python expression using + (addition or string concat) and ' (chr) and ⍎ (eval) it. So the proof is in two parts: constructing an arbitrary string, and making sure that Python's eval (as opposed to an arbitrary program) is Turing-complete.

### Python eval is Turing-complete

Unlike exec, we can't use many syntactic keywords like while and even def. But we have lambda expressions, and it turns out that we can implement untyped lambda calculus. As a minimal example, the following expression is an infinite loop:

(lambda a:a(a))(lambda a:a(a))


To make it more explicit, here are SKI combinators:

S = lambda l:lambda a:lambda m:l(m)(a(m))
K = lambda l:lambda a:l
I = lambda l:l


### > 1+'\n is enough to construct an arbitrary string

Now to actual Whispers code. The lines starting with single > are constant lines, and those with double >> reference other expressions using line numbers. We will only use 1, 11, 111 for constant lines, and construct the required charcodes using addition. The following sets up three numbers for the string "123" (charcodes 49, 50, 51):

> 1
> 11
>> 2+2  // 22
>> 3+3  // 44
>> 1+1  // 2
>> 5+5  // 4
>> 4+6  // 48
>> 7+1  // 49
>> 8+1  // 50
>> 9+1  // 51


Then we apply ' (chr) to each of the charcodes:

>> '8   // "1"
>> '9   // "2"
>> '10  // "3"


Finally, we concat and eval them.

>> 11+12
>> 14+13
>> ⍎15


We successfully created the string "123" and passed it to eval. Now the only problem is that we used all digits to reference lines. It can be easily circumvented by inserting dummy syntactically valid lines > 1 so that we can reference meaningful lines with repunits (so the line number n will be translated to the number containing n copies of 1):

> 1  // valid line 1
> 1    // from line 2...
> 1
...
> 1    // ...to line 10 are dummy lines
> 11 // valid line 11
> 1    // from line 12...
...
> 1    // ...to line 110 are dummy lines
>> 11+11 // valid line 111
...


### 7 chars is (likely) minimal, at least in v1

I checked the whole source code, and all one-char functions except ⍎ do not have mutable state at all. There are looping constructs like While, but using it alone requires at least 8 chars > While1. Therefore, the approach using ⍎ must be minimal (where 7-char solution is already known).

For TC-ness in Python eval, we need at least lambd :(), which is already 9 chars, and chr is definitely needed to create them without them in the source code. There is no 1-char solution to create those charcodes, and 1+ shares + with string concatenation. Therefore using 1+' as the core chars is the minimal way to build a string that enables TC-ness.

I didn't read all of v2 and v3 source code, but I believe the 7-char solution is likely minimal on those too.

• It's funny that the program length increases exponentially. Just that program eval'ing 123 has to use 1111111111111111 lines of code – Jo King Aug 31 '20 at 13:53

# APL, 9 characters

⍎⎕UCS(≢⍬)


Why this is Turing-complete:

• ≢ is length, ⍬ is the empty list, and a list can be expressed simply by naming its elements, i.e. ⍬⍬⍬ is a list of three empty lists. This way, all numbers can be formed. ≢⍬ is 0, ≢≢⍬ is 1, and from then on ≢⍬⍬⍬... is N, where N is the amount of ⍬s.
• () are used to change evaluation order. List construction works with anything, so this way (≢⍬)(≢⍬⍬)(≢⍬⍬⍬) evaluates to [0,2,3].
• ⎕UCS gives a string of Unicode characters given a list of numbers. We can now generate any text we want.
• ⍎ is evaluate.
• ≢≢⍬ does not look right. Should it be ≢⍬⍬? – CalculatorFeline May 30 '17 at 19:23
• @CalculatorFeline: no, ≢⍬⍬ is 2. ⍬⍬ is the list containing two empty lists, and its length (≢) is 2. ≢≢⍬ is 1, because ⍬ is the empty list, its length (≢) is 0, and the length of that (≢) is 1. ≢≢⍬ = ≢0 = 1.Try it yourself: tryapl.org/… – marinus May 31 '17 at 20:12
• Save a character: ⍎⎕AV[≢],). One-based indexing obviates the need for any "zeroth" character. – Adám Jun 2 '17 at 14:21
• Change any code to an expression consisting of those 8 chars: Try it online! – Adám Jun 2 '17 at 15:36

## Tildehyph, 2 characters

~-


The language uses only two characters a tilde and a hyphen. The easy answer why Tildehyph is Turing-complete is the fact that there is a Brainfuck interpreter created in it and Brainfuck is proven to be Turing-complete.

• I'd like to know who downvoted this. – Esolanging Fruit Feb 21 '17 at 22:09
• @Challenger5 I don't see any point in an answer that removes no characters from the languages existing character set. Its just as boring as the Unary answer. – Wheat Wizard Feb 22 '17 at 1:22
• And yet the Unary answer gets 21 upvotes? – G B Feb 22 '17 at 8:47
• @GB: The Unary answer shouldn't have been upvoted according to the normal advice. However, SE rules also say you shouldn't downvote something just because it's been incorrectly upvoted. – user62131 Feb 22 '17 at 9:36
• @user62131 Then why downvote this answer? – MilkyWay90 Mar 3 '19 at 3:54

# Java, 30 26 characters

 ()+-.0;=Sacdefgimnorstv{}


Taking a different approach from the other (more clever) Java answer, this one uses "regular" characters.

Java (like most languages) offers many facilities above and beyond what is required to be Turing-complete: basic arithmetic, jumps, and declaring variables (memory on the tape). The only types of jumps necessary are the simple if and for statements.

I started by writing a small program shell (main method), then adding statements that implement the bare minimum set that represents a Turing-complete subset of Java. I did so in a way that used the fewest characters possible, and came up with this:

interface S {

static void main(String... s) {
int r = 0;
r++;
int t = p;
t--;
if (t == 0) {
r--;
}
for(;;) {
t++;
r++;
}
}
}


Removing all whitespace except for one space (0x20), sorting, and removing duplicates provides the string above.

These characters allow:

• if conditionals.
• Variable assignments.
• Comparing variables against each other and zero.
• for loops, including infinite loops (for(;;))
• Adding and subtracting arbitrary numbers via repeated unary increment and decrement.

In other words, I have reduced Java to a slightly more readable version of Brainfuck.

• You need some way to create an infinite loop, for Turing completeness. I suspect you can do it via recursion (or for(;;)), but you probably need to mention that in your submission; manually unrolling an infinite loop is of course impossible, so the current explanation doesn't work. – user62131 Feb 22 '17 at 5:16
• You can use interface instead of class, which allows you to drop the public. – corvus_192 Feb 24 '17 at 16:11
• Also, replace the [] with ... to save another character. – corvus_192 Feb 24 '17 at 16:12
• @corvus_192 thanks, good catches. [] could be useful in a state machine, but is not strictly necessary. To use it, however, I would need to add w to support new. – user18932 Feb 24 '17 at 16:25
• Actually, you can do it all with decrement and unary minus. Have one variable as -1. Plus is not needed. – Robert Fraser Sep 21 '17 at 7:12

## PowerShell, 15 14 characters

+[char](1)|iex


Thanks to @Erik-the-Outgolfer for seeing that we don't need the " marks.

I'm reasonably confident this is the smallest set we can have. Similar to the Python answers, this constructs up a program one character at a time (via things like [char](1+1+1+1+1...+1+1) to get the appropriate ASCII value) and then evaluating the string via |iex. For example, here is an example program that is equivalent to "Test: "+(3+4). As a result, we can construct literally any PowerShell program with this method, and this is therefore Turing-Complete.

• I don't think you need the ", I tried removing them in your example program. – Erik the Outgolfer Feb 26 '17 at 9:35
• @EriktheOutgolfer You're right -- thanks! Must be a difference in behavior for newer versions of PowerShell, since previous versions would try to mathematically add the chars together, rather than concatenate. – AdmBorkBork Feb 27 '17 at 13:53

# Binary Lambda Calculus, Binary Mode, 3 characters (ascii-encoded)

HR.


Interpreted as incomplete segments of Binary Lambda Calculus, writing \ for lambda, * for application and De Bruijn indices for variables:

H = 01001000 = * \ 1 \
R = 01010010 = * * \ 1
. = 00101110 = \ 1 3


Suppose x and y are valid terms.

Then,

  H x
= * \ 1 \ x
= \ x

R x y
= * * \ 1 x y
= * x y

R .
= * .
= * \ 1 3
= 3


Thus we can use H as \, R as *, and R. as 3.

For 2 and 1, suppose we have any valid term z.

Then,

* \ 3 z = 2

* \ 2 z = 1


(Free variables get decremented in beta-reduction with De Bruijn indices)

As for the choice of z, we can use z = \ \ \ 3 (or if we allow free variables in our program, we can just use 3).

Finally, to show we don't need more than 3 variables, we can implement SKI combinator calculus:

I = \ 1
K = \ \ 2
S = \ \ \ * * 3 1 * 2 1


Written using our 3 characters, these are

I = HRHRHR.HHHR.HHHR.
K = HHRHR.HHHR.
S = HHHRRR.RHRHR.HHHR.HHHR.RRHR.HHHR.RHRHR.HHHR.HHHR.


Which can be applied to each other in arbitrary ways using R.

# Scala, 12 chars

(),:;=>[]def


Using these characters, you can encode the SKI calculus. I replaced the semicolons with newlines for readability:

def>[d,e,f]:(d=>(e=>f))=>(d=>e)=>(d=>f)=(dd:d=>e=>f)=>(ee:d=>e)=>(ff:d)=>dd(ff)(ee(ff))
def>>[d,e]:d=>e=>d=(dd:d)=>(ee:e)=>dd
def>>>[d]:d=>d=(>[d,d=>d,d])(>>[d,d=>d])(>>[d,d])


(Ab-)using the fact that you can call a method >, which will be seperated from the def by the parser to save the space.

Borrowed from here and optimised for this challenge.

• I don't think you need to have a computer science degree to know whether something is Turing-Complete... – Julian Lachniet Feb 21 '17 at 23:36
• @DLosc Right, you'd have to add either a newline or a semicolon. – corvus_192 Feb 24 '17 at 16:02

## Nock, 6 characters

[ ]012


Nock is a minimal virtual machine based on combinator reduction. It's memory model is a binary tree of bignums, and the spec gzips to 340 bytes. There's a trivial transformation from Nock operations to the SKI combinators, which I stole from the Urbit examples library (which seems to originate from this reddit discussion):

S = [[1 1 2] [1 0 1] [1 1] 0 1]
K = [[1 1] 0 1]
I = [0 1]


A more interesting way to do this would be to re-compile Nock with the Nock 4 operator, which is increment, to create the other operators. [4 1 1] is 2, [4 4 1 1] is 3, etc. S could alternatively be defined [[1 4 1 1] [1 0 1] [1 1] 0 1], for example. I think that you still need a non-synthesized 2 operator in order to apply functions and reduce the 4, though.

## BitCycle, 8 characters

AB>/+~


plus space and newline.

My first demonstration of BitCycle's Turing-completeness was a Bitwise Cyclic Tag interpreter. But it turns out I can avoid quite a few extra characters by instead constructing a reduction, this time from a cyclic tag system.

Consider any cyclic tag system, which consists of an ordered list of productions: strings of 0's and 1's (possibly including the empty string). Encode it as a string of 0's, 1's, and semicolons, with a semicolon following each production. For instance, the example from the Esolangs article, with productions (011, 10, 101), would be represented as 011;10;101;. Then translate each element to a block of BitCycle instructions as follows:

0

    >>      ~
+~ ~
> +
> ~
> A~
B /    ~   >>

+   ~    ~


1

    >>      ~
+~ /
> +
> ~
>   A~
B /    ~   >>

+   ~    ~


;

    .

B / >

.


(The . characters here are placeholders and don't affect the function of the program. They should be replaced with spaces in the actual reduction.)

Concatenate these blocks side-by-side according to the three-character representation of the cyclic tag system. Then wrap the concatenation in this looping construct:

> ... ~

~     ~


where ... represents the rest of the program, the > is on the same line as the B collectors, and the ~ ~ don't have anything but spaces in between them.

To test this, insert a ? before the > in the wrapper and give the input string as a command-line argument. For example, here's the cyclic tag system 1;0;:

       >>      ~           >>      ~
+~ /                +~ ~
> +                 > +
> ~                 > ~
>   A~                > A~
?> B /    ~   >> B / > B /    ~   >> B / > > ~

~                                           ~

1           ;       0           ;

+   ~    ~          +   ~    ~


## ARM7 assembly - 8 bytes

CRS15,


And space and newline

With these characters, one can construct the following:

• Registers R1, R5, and R15 (R15 is the instruction pointer)
• The instruction RSC (Reverse Subtract with Carry)
• The condition code CC (do if carry clear)
• Any decimal number consisting of the numerals 1 and 5

These allow for data manipulation (subtract two registers), memory manipulation (specify destination as an address made up of 1s and 5s), and conditional jumping (R15 as the destination of a subtract with a condition code).

Comma, space, and newline are syntactic requirements of assemblers and cannot be avoided (in most cases).

One may be apt to point out that ARM does not have infinite pointers, and thus cannot be Turing complete. True, however no computer is Turing complete, and all of these languages are limited by their implementation. It is entirely possible to extend the ARM specification to allow for larger addresses. Ultimately, you'd have to let this one slide, and assume the best for the challenge.

Also, I admit to not knowing the minimum version of ARM this works in; I picked the one I know works

# J language, 7 char

To acheive Turing completeness, J can make do with the following 6 characters, plus space.

".u:1b


1b is a prefix for numbers meaning they are expressed in unary, so that e.g. 1b1111 1b11 is the array 4 2. This can represent every positive integer.

Then, u: converts ASCII character codes to characters, and ". evaluates a string as J code. This allows full access to the language.

## Is this minimal?

Probably. What I have is pretty darn lean.

No proper subset of these characters is sufficient, though there are a couple of equivalent sets like do u:1b and ".1b {a.

J has no good facilities for doing something overly clever like embedding some lambda calculus or tag system, either, so I don't think a different strategy has a better shot, but I won't rule out the chance that I'm overlooking something sneaky.

• Why not just put the space in the list? – mbomb007 Feb 21 '17 at 21:45

# Setanta, 14 characters

adghimnort(){}


Provides a way to encode the SKI combinator calculus as shown:

i := gniomh(g){toradh(g)}


Then inline i, k, and s as needed.

# Self-modifying Brainfuck, 2 characters

<+


Using these characters we can modify the end of the program in a way that it executes normal Brainfuck code.

Start by choosing the Brainfuck program, put [>] in the begining, that way the pointer will start where it should be. The number of bytes will be the number of + in the end of our code. Next we need the ascii values of the characters used in the bf code minus 43. These are how much we need to add to each +. For each number in our list we print < followed by that number of +, but start by the end of the list. Put everything together and it should do the same thing the bf code does.

Exemple: a bf cat ,[.,]

It becomes [>],[.,].

Now it has 8 bytes, so we should end the smbf code with ++++++++.

The ascii values are 91, 62, 93, 44, 91,46, 44 and 93. Subtracting 43 we get 48, 19, 50, 1, 48, 3, 1 and 50.

50: <++++++++++++++++++++++++++++++++++++++++++++++++++
1: <+
3: <+++
48: <++++++++++++++++++++++++++++++++++++++++++++++++
1: <+
50: <++++++++++++++++++++++++++++++++++++++++++++++++++
19: <+++++++++++++++++++
48: <++++++++++++++++++++++++++++++++++++++++++++++++


Putting this before the ++++++++ gives the final smbf code:

<++++++++++++++++++++++++++++++++++++++++++++++++++<+<+++<++++++++++++++++++++++++++++++++++++++++++++++++<+<++++++++++++++++++++++++++++++++++++++++++++++++++<+++++++++++++++++++<++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Try it online!

Execution:

<++++++++++++++++++++++++++++++++++++++++++++++++++  # Add 50 to the last byte of this code, now it ends with +++++++++++++]
<+                                                   # Add 1 to the byte to the left of that, now it ends with ++++++++++++,]
<+++                                                 # +++++++++++.,]
<++++++++++++++++++++++++++++++++++++++++++++++++    # ++++++++++[.,]
<+                                                   # +++++++++,[.,]
<++++++++++++++++++++++++++++++++++++++++++++++++++  # ++++++++],[.,]
<+++++++++++++++++++                                 # +++++++>],[.,]
<++++++++++++++++++++++++++++++++++++++++++++++++    # ++++++[>],[.,]
[>]                                                  # This was originally +++ ,but now it tells the pointer to go to the right until it leaves the code
,[.,]                                                # Execute the Brainfuck code


Here is a GolfScript program where you input a Brainfuck code and it outputs a Self-modifying Brainfuck code that does the same, using only < and +.

'[>]'\+.,:l{'<'\)43-'+'*\}\*'+'l*


Try it online!

# Unlambda, 3 characters

sk


It's a turing tarpit of course.

# ///, 2 characters

/\


It was proven Turing Complete when someone wrote a Bitwise Cyclic Tag interpreter using it.

Shortened to 3 characters thanks to @Leo and @ETHproductions.

Shortened to 2 characters thanks to @ØrjanJohansen

• I'm fairly sure that /// is Turing-complete with just forward slash and backslash, but I'm not sure if that's actually been proven anywhere. This can likely be minimized, anyway. – user62131 Feb 24 '17 at 18:10
• I think that at least characters ()|PD01 are used only for convenience in that code (it could be written without them, but it would be longer and it would be harder to encode the input to the tag). I don't know this language well enough, but i'm guessing that /\ could very well be enough, since with just those two characters you can build an infinite set of words. – Leo Feb 24 '17 at 18:11
• () are also only used for convenience. You could write the entire thing using only \/. – ETHproductions Feb 24 '17 at 18:13
• Thanks. I am very new to this language, so I wouldn't know this. – sporklpony Feb 24 '17 at 19:39
• Hi, author here. Even the . is just for convenience, everything other than slash and backslash is expanded before entering the main loop. – Ørjan Johansen Feb 27 '17 at 2:52

# Skull, 9 characters

[]{}|:NUM


So Skull is an interesting language. You need NUM to set number mode. This adds to the amount of characters you need as you have to use one at the beginning of your programs. Also I mean that is the entire language except for 3 other characters.

{ x [ y ] } Increment or decrement the specified cell (x) by the specified number (y)
{ x { While the specified cell (x) is not 0...
} } End while
| x | Print out the specified cell (x) to the screen

This is a simple program doing addition (4+2)

:NUM:       // set mode to NUM
{0[+4]}      // set cell 0 to 4
{1[+2]}      // set cell 1 to 2
{0{         // while cell 0 is not 0
{0[-1]}   // subtract cell 0 by 1
{1[+1]}   // add 1 to cell 1
}}          // end while
|1|         // print cell 1 (6)

• ASCII or ASKII? – NoOneIsHere Feb 20 '17 at 17:23
• @NoOneIsHere Opps! Thanks for that. – Christopher Feb 20 '17 at 21:31
• You don't need to print something to be Turing complete, so I think you can drop the ASC. – Laikoni Feb 20 '17 at 22:25
• @Laikoni nice! That will cut this down! – Christopher Feb 20 '17 at 22:26
• This also needs a Turing proof. – Brian Minton Feb 24 '17 at 13:48

# C (gcc), 19 bytes

main*fort(){}-=1[];


My implementation is Turing-complete because it can emulate another Turing-complete language.

32-bit cell Brainfuck interpreter (no I/O) using the commands as UTF-32 characters from the first command-line argument:

itr;nat;arr[111111-11111];rra=111-11-1-1-1-1-1-1-1;ora=111-11-1-1-1-1-1-1-1-1-1;aro=111-11-11-11-11-1-1-1-1-1-1-1;rar=111-11-11-11-11-1-1-1-1-1;min=111-11-11-11-11-11-11;aff=111-11-11-11-11-11-11-1-1;main(i,a)int**a;{for(i-=1;a[1][i];i-=-1){if(a[1][i]==aff)arr[itr]-=-1;if(a[1][i]==min)arr[itr]--;if(a[1][i]==aro)itr--;if(a[1][i]==rar)itr-=-1;if((a[1][i]==ora)*(arr[itr]==1-1))for(nat=1;nat;){i-=-1;nat-=-(a[1][i]==ora);nat-=a[1][i]==rra;}if((a[1][i]==rra)*(1-(arr[itr]==1-1)))for(nat=1;nat;){i-=1;nat-=-(a[1][i]==rra);nat-=a[1][i]==ora;}}}


aff is +.
min is -.
aro is <.
rar is >.
ora is [.
rra is ].

Note that I can't figure out how to run it yet but it should theoretically work.

• Why is t needed? – ceilingcat Mar 14 '20 at 21:39
• @ceilingcat For int. I guess I was tuning it to my example too much. – S.S. Anne Mar 14 '20 at 22:01

# 05AB1E, 5 bytes

+X.VB


Explanation:

• +: Pops the top two items on the stack, and adds them together
• X: A constant with value 1 by default. Why don't I just use 1 itself? Because putting 2 on the stack would be 1 1+ (note the space) instead of XX+. 11 would have been interpret as eleven instead of two ones.
• .V: Pops and evaluates the top string as 05AB1E code
• B: Pops the top two items on the stack, and does base-conversion

Using the X+ we can create any positive number. Using B we can convert combinations of two numbers to any character in the 05AB1E codepage. And using .V we can evaluate those characters as 05AB1E code.

One thing to note when creating such programs: according to the 05AB1E source code, the order of the characters used in the base-conversion up to 256 is: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzǝʒαβγδεζηθвимнт\nΓΔΘιΣΩ≠∊∍∞₁₂₃₄₅₆ !"#$%&'()*+,-./:;<=>?@[\]^_{|}~Ƶ€Λ‚ƒ„…†‡ˆ‰Š‹ŒĆŽƶĀ‘’“”–—˜™š›œćžŸā¡¢£¤¥¦§¨©ª«¬λ®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ. So a slightly different order than the 05AB1E codepage (which makes sense, since we start with digits and letters for the base-conversion). Try it online: Here a few example programs using these five bytes: # SmileBASIC, 9 charcaters (space)$+=@GOT[]


$ - required for string variables + - for concatenating strings = - assignment @ - labels and label string literals (@ABC = "@ABC", when used in an expression) GOT - used for GOTO, variable names, and label names [] - accessing characters in strings space - separator Here is a Bitwise Cyclic Tag interpreter (some spaces replaced with line breaks for readability) Program is encoded as G=0, O=10, T=11, and the data string uses T and O as 1 and 0. G$=@<program here>
G$[O]=O$
T$=@<initial data here> T$[O]=O$GOTO @G @TO @OO G$=G$+G$[O]
G$[O]=O$
@G
GOTO O$+@G[O]+G$[O]+T$[O] @GO @GT T$[O]=O$GOTO @OO @TT @OT T$=T$+G$[O]
GOTO @OO

• Using these constructs, can you create unbounded data structures? They could be in the form of arrays, lists, strings, or even integers, as long as they're not limited in size by the implementation. If not, the language isn't Turing-complete. For example, in QBasic, trying to DIM an array larger than 64KB (that's 16384 SINGLE numbers) gives a Subscript out of range error. (This is different from running out of memory, which will happen with any language and is considered an implementation difficulty rather than a limitation of the language.) – DLosc Feb 24 '17 at 21:21

# Perl 6, 9 characters

~^<>.EVAL


The goal here is to EVALuate arbitrary strings. To do this, we can use the ~^ to bitwise xor strings into other strings, as long as we have enough characters, as well as the <<>> to delimit the actual strings themselves. There's some fiddling in avoiding syntax errors when using <>, but we can generally use the characters .EVAL~^ to produce more characters.

For example, if you wanted to create the string 4*9, you could do:

<<...>>~^<<VEV>>~^<<LAA>>


And to evaluate that, you wrap it in more <<>>s and EVAL it a few times:

say <<<<...>>~^<<VEV>>~^<<LAA>>>>.EVAL.EVAL


Try it online!

Unfortunately, we can't get the full range of ASCII with just xors, so we can use ~& inside the evaluated strings, in the form 'string'~&'string'. This gets us a Turing complete subset of ASCII, but not all of it, so for convenience we can xor it once more to get a full subset.

For reference, a full program will go through 5 EVAL stages before executing:

<<<<........EE............................>>~^<<.E.....EVVE.....E.....................>>~^<<.V.....VLLVEEE..V....E.....E..EEEE..E.>>~^<<EL.....L~~LLVV.ELE.VEL.....L..LLLL.ELE>>~^<<L^.....^^^^~~L.V^L~^L~EE..E~~^~~~~^^~L>>>>
(<< ........EE............................ >>~^<< .E.....EVVE.....E..................... >>~^<< .V.....VLLVEEE..V....E.....E..EEEE..E. >>~^<< EL.....L~~LLVV.ELE.VEL.....L..LLLL.ELE >>~^<< L^.....^^^^~~L.V^L~^L~EE..E~~^~~~~^^~L >>)
'/.....//wm_.=/'~&'wEE..Ew~^wwww^5w'
'..'~^'weW5'
say 1


Here is a full program generator that can handle ASCII characters, and an example Hello World! program.

## Keg, 9 characters

~+-*/:{|}


This subset of Keg was shown to compile to Volatile, which was in turn compiled to the Minsky Machine by TuxCrafting. The lack of output commands does not matter because Turing-completeness does not require output capabilities.

• I feel like + isn't necessary since, for example, if you wanted to add one you could do ~:/::--- – EdgyNerd Sep 14 '19 at 11:13
• ::--- works for that – EdgyNerd Sep 14 '19 at 11:15
• Actually wait, ::--- doesn't actually work, oops – EdgyNerd Sep 14 '19 at 11:18
• can we continue this in the Keg chat room? – EdgyNerd Sep 14 '19 at 11:20

# APL (Dyalog Unicode), 8 characters

016 ⎕DR⍎


The "create an arbitrary source code and eval it" approach.

While a typical APL source code contains lots of Unicode symbols, all of them have codepoints that fit into two bytes. That means any reasonable APL source code as a string will have data representation 160. Such a string can be generated by applying reinterpret data representation of an array on any type of array, including a Boolean array.

For example, the following code runs the shortest infinite loop ~⍣≡0:

⍎160⎕DR 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0


Try it online!

Having access to all APL features, this character set is definitely Turing-complete.

I considered emulating a Minsky machine or other minimalistic Turing-complete languages using tradfns/dfns, but I can't find anything that works within 7 distinct characters.

# Zsh, 8 characters

$#< (){}  • <<<string prints string • (){body} args is an anonymous function, which is immediately called with args • <<<$# outputs the number of arguments to a function
• So we can use (){<<<$#}$  to output 3 (for example)
• ${(#)var} gets the character with the codepoint stored in var • ${(#)$(command)} gets the character with the codepoint that is the result of command • We can combine these to generate arbitrary characters, e.g. ${(#)$((){<<<$#}  $)} is \x03 Hence, we can construct the string eval: ${(#)$((){<<<$#}                                                   $)}${(#)$((){<<<$#}                                                           )}${(#)$((){<<<$#}$                                                )}${(#)$((){<<<$#}$                                                      $)}  And use that to execute any arbitrary code. Here is demonstration that outputs Hello, World: ${(#)$((){<<<$#}                                                   $)}${(#)$((){<<<$#}                                                  $)}${(#)$((){<<<$#}                                                    )}${(#)$((){<<<$#}$                                                       )} ${(#)$((){<<<$#}$                                    $)}${(#)$((){<<<$#}                                                   $)}${(#)$((){<<<$#}                                                      )}${(#)$((){<<<$#}$                                                      $)}${(#)$((){<<<$#}                                                        $)}${(#)$((){<<<$#}                      )}${(#)$((){<<<$#}$                $)}${(#)$((){<<<$#}                                            $)}${(#)$((){<<<$#}                                                        $)}${(#)$((){<<<$#}                                                         )}${(#)$((){<<<$#}$                                                      $)}${(#)$((){<<<$#}                                                  )}


\$#(){} are integral to this method, but I think there might be a way to remove   or <. Unfortunately I can't find one without adding a different character instead.

# Pyth, 5 characters

 1Cv+


 1C+ can construct any string, and v evaluates a string as Python 3 expression.

A Hello World program in this format can be written as follows:

v+++++++++++++++++++++C+111 1C+++111 1 1 1C++++++++++++++11 11 11 11 11 11 11 11 11 1 1 1 1 1 1C+++++++++11 11 11 11 11 11 11 11 11 11C+++++111 1 1 1 1 1C+++++++++11 11 11 1 1 1 1 1 1 1C+++11 11 11 1C+++++++++++11 11 11 11 11 11 1 1 1 1 1 1C++++++++++11 11 11 11 11 11 11 11 11 1 1C+++++++++++++++++11 11 11 11 11 11 11 11 11 1 1 1 1 1 1 1 1 1C+++++++++++++++++11 11 11 11 11 11 11 11 11 1 1 1 1 1 1 1 1 1C111C+++11 11 11 11C+++++++++++11 11 1 1 1 1 1 1 1 1 1 1C++++++++111 1 1 1 1 1 1 1 1C111C+++111 1 1 1C+++++++++++++++++11 11 11 11 11 11 11 11 11 1 1 1 1 1 1 1 1 1C+++++++++11 11 11 11 11 11 11 11 11 1C++11 11 11C+++11 11 11 1C++++++++++11 11 11 1 1 1 1 1 1 1 1


as seen here.

# Pxem, 5 characters (assumes arbitrary length of filename and arbitrary size of stack are available).

.acvz


## How it works

According to this blog, this is how to emulate a CTS:

3.2.2.1. Syntax in EBNF

Filename = init, main [, omitable ];
init = dummy, data-string;
dummy = '01';
data-string = { data-bit }, end-of-string;
data-bit = '0', actual-bit;
actual-bit = '0' | '1';
end-of-string = '1';
main = '.z', { command, } exiter, '.a';
command = empty-checker, actual-command;
empty-checker = 'c0.z1.z.a.v1.v.c0.z0000.a'; If empty, data string is updated with a '0' string.
actual-command = '00.a1.z.a0.zv', pushing-data-string-reversed, '.v00.a';
pushing-data-string-reversed = { actual-bit, '0' };
exiter = '.c0.z1.z.a.v1.v00.a.c1';
omitable = '.d.pxe';


But these modification would make it still Turing-complete:

• Omit omitable
• Replace 0 and 1 with a and z respectively

This is thus the code to emulate the program (011, 10, 101) with input "1":

azazz.z.ca.zz.z.a.vz.v.ca.zaaaa.aaa.az.z.aa.zvzazaaa.vaa.a.ca.zz.z.a.vz.v.ca.zaaaa.aaa.az.z.aa.z.vaaza.vaa.a.ca.zz.z.a.vz.v.ca.zaaaa.aaa.az.z.aa.z.vzaaaza.vaa.a.ca.zz.z.a.vz.vaa.a.cz.a


# HSPAL, 6 characters

012346


The BF interpreter linked in the esolangs article uses only the digits 0-4, plus 6, for all tokens except number literals and label IDs. It uses at most 116 distinct label IDs [the actual number is probably slightly lower, but I don't feel like counting them right now], which can be reassigned to use only the reduced 6-digit alphabet; and the BF instructions can likewise be reassigned to different code points; therefore all other digits can be excluded from the alphabet while leaving the language turing complete.

# Decimal, 7 characters

012345D


These three commands are necessary to be Turing-complete:

• 3 - I/O
• 4 - MATH
• 5 - COND

0, 1 and 2 are used as arguments to the commands. D is like the closing parenthesis for some commands.

How it's Turing-complete:

• 310 reads a character to the stack (3=I/O, 1=from input, 2=to stack)
• The first four arguments to command 4 MATH are +, -, *, / (1, 2, 3, 4). For example, calling 41D takes DSI and DSI-1, pops them, and pushes the result of adding them together.
• Command 5 COND is a conditional. Jumps to the next COND if the DSI value is falsy.
• I don't think you need 3. I/O isn't required for turing completeness – 12Me21 Feb 8 '19 at 17:27

# Turing Machine But Way Worse - 4 characters

0 1\n (The \n should be replaced with an actual newline)

States can be represented in binary and everything else uses a 0 or 1.

Spaces separate different parts of a command and newlines separate commands.