Mock theta

From Esolang
Jump to navigation Jump to search

Mock theta, named after a pun on string theory, is a variant of Srinivasa, that operates on strings instead of numbers. Its is Turing complete, like all other variants of Srinivasa that User:Yayimhere has made(however she has not yet proven Srinivasa itself TC).

Semantics and Syntax

rinivasa has two functions, called κ, and a function called ζ. These have nothing to do with anything outside of this language. κ and ζ are defined like this:

κ(x,y,z,...) <- expression here ζ(x,y,z,...) <- other expression here Both functions must have the same amount of inputs, though even still, ζ can be left empty/not in the program. Recursive functions are explicitly allowed, and are in fact the only way of looping. The commands within a function are ?'+-()[", which are described below:

[(x,y): return the character at index x of string y. indexing starts at 0.
?(x,y,z,w): if x is equal to y, return z, else return w.
'x': x is a string
+(x,y): append y to x.
-(x,y): delete every instance of y from x.
(x): brackets.
"(x): print x, and return x.

here, the order of operations follow: ()"[+-, with the leftmost one first. The final line of the program, is κ, with all its inputs(strings surrounded in ' qoutes), on an indented line starting with an arrow and a space, like this:

	> κ(x,y,z,...)

There is a way of taking input. This is by referencing a variable iN. It gets a single string as input when first encountering the variable, and returns that input.

Computational class

Mock theta is Turing complete, as it can be translated from BCT:

  • Start with defining κ as the function κ(d) <- ζ((pd)) where p is the BCT program.
  • Then move every command to prefix, as if the data string was the input.
  • Then we make every command x followed by the rest of the program p(remember that we reversed it) into x(p).
  • Then for 11(p) we say: +(((p),?([(0,d),'0','','1'))).
  • For every 10(p) we say: +(((p),?([(0,d),'0','','0'))).
  • And for every 0(p) we say: -(((p),+('|',[(0,d)))).
  • Last we say that ζ(d) <- κ("(d)).
  • And initialize as:
	> κ(+('|',d))

Where d is the data string.

So say we have the collatz program:

10 11 10 10 10 11 0 11 10 10 0 11 10 10 11 10 10 11 10 10 0 0 0 0

We compile into:

0 0 0 0 10 10 11 10 10 11 10 10 11 0 10 10 11 0 11 10 10 10 11 10 ->  0(0(0(0(10(10(11(10(10(11(10(10(11(0(10(10(11(0(11(10(10(10(11(10))))))))))))))))))))))) ->
-(((-(((-(((-(((+(((+(((+(((+(((+(((+(((+(((+(((+(((-(((+(((+(((
+(((-(((+(((+(((+(((+(((+(((+(((d),?([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),?  ([(0,d),'0','','0')))),?([(0,d),'0','','1')))),+('|',[(0,d))))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),
+('|',[(0,d))))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?  
([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),+('|',[(0,d))))),+('|',[(0,d))))),
+('|',[(0,d))))),+('|',[(0,d)))) ->
κ(d) <- ζ(-(((-(((-(((-(((+(((+(((+(((+(((+(((+(((+(((+(((+(((-(((+(((+(((
+(((-(((+(((+(((+(((+(((+(((+(((d),?([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),?   ([(0,d),'0','','0')))),?([(0,d),'0','','1')))),+('|',[(0,d))))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),
+('|',[(0,d))))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?  
([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),+('|',[(0,d))))),+('|',[(0,d))))),
+('|',[(0,d))))),+('|',[(0,d)))))
ζ(d) <- κ("(d))
  	> κ(+('|',100n))

Where n is the input to the function. As such, the Mock theta collatz program is:

κ(d) <- ζ(-(((-(((-(((-(((+(((+(((+(((+(((+(((+(((+(((+(((+(((-(((+(((+(((
+(((-(((+(((+(((+(((+(((+(((+(((d),?([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),?    ([(0,d),'0','','0')))),?([(0,d),'0','','1')))),+('|',[(0,d))))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),
+('|',[(0,d))))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?   
([(0,d),'0','','0')))),?([(0,d),'0','','1')))),?([(0,d),'0','','0')))),?([(0,d),'0','','0')))),+('|',[(0,d))))),+('|',[(0,d))))),
+('|',[(0,d))))),+('|',[(0,d)))))
ζ(d) <- κ("(d))
  	> κ(+('|',100n))