xVector

From Esolang
Jump to navigation Jump to search

xVector is an OISC invented by User:None1 and inspired by Vector, it uses a 3-dimensional vector. Instead of dot product, it uses cross product.

Data

As said above, xVector uses a 3D vector called A, it is initially (0,0,0).

A vector literal is represented by 3 real numbers separated by spaces.

Command

B C D

B,C and D are 3D vectors. The command means: If A×B equals to C, then (add A by D and jump to the start of program).

There is an output command, it is not required so it does not count in the number of commands:

B C D E

(Print the first dimension of A×E then add A by D and jump to the start of program) if A×B equals to C. Whether as number or as character depends on implementation.

Examples

Infinite loop

0 0 0 0 0 0 0 0 0

Computational class

xVector is equivalent in power to a 1-counter Minsky machine (and thus is not Turing-complete – it would be more powerful than a finite state automaton if it supported input, but is less powerful than a push-down automaton).

First, consider programs that do not have any command with B = C = 0 0 0. The language's only form of control flow, checking if A×B=C (with B and C constant), is equivalent to checking whether A (interpreted as a point on 3D space) is on a particular line in 3D space, so the program is only capable of control flow at times when A is close to one of the finitely many lines of the program (and the program will halt if A is not on any of the lines). For programs where A always returns to within a finite distance from the original, the program implements a finite-state machine (because there are only finitely many reachable points within any given distance of the origin) – so any more powerful program has to go arbitrarily far from the origin and stay there. But (once you go sufficiently far from the origin) non-parallel lines get further apart from each other as you get further from the origin, so at some point, such a program will reach a situation where the only possible moves between lines are between parallel lines. The state of such a program can be fully stored by specifying which line A is on and how far along the line A is (measuring from some arbitrary point), and the only operations possible on this state (assuming that the program stays arbitrarily far from the origin) are adding and subtracting constants from the position-on-line and changing which of the parallel lines A is on, giving the language the same power as a 1-counter Minsky machine.

If the program contains a command starting 0 0 0 0 0 0 (which always runs), it is able to move from one line to a line that isn't parallel (because A moves through space at a constant rate based on that command' D when it isn't on any of the lines) – however, after A gets sufficiently far from the origin, it can only do this finitely many times. To see this, imagine looking in the direction at which A moves while it isn't on a line, to produce a 2D view of the 3D space. If two lines don't coincide with each other in this 2D view, then there is at most one point on those lines at which the move is possible (the point at which they cross in the 2D view) – but that transition can't be used once A has gone further from the origin than the crossing point. If two lines do coincide with each other in the 2D view, then the move is possible; but once A has permanently gone further from the origin than any points at which the lines cross in the full 3D space, it is only capable of moving between the lines in a single direction (i.e. if it can go from line X to line Y, it can't go from line Y to line X, even indirectly). This means the language implements a 1-counter machine that can add and subtract from the counter, change state between finitely many states, and multiply the counter by a constant finitely many times; but that is no more powerful than a 1-counter Minsky machine is (you can implement the finitely many multiplications by using additional states to remember which multiplications have been done, and scaling the additions and subtractions accordingly).