# Expandable Quantum Brainfuck

EQBF is very much like Quantum brainfuck, but with more features that may make it more "quantum complete". It is being developed by Gregor Richards

Unlike QBF or brainfuck, some commands in EQBF take parameters. Those that do use a C-like format of command(param,param,param), with all whitespace optional. Also unlike QBF, there are two tape pointers. In general, the second is used as a control for gates.

The tape starts initialized to |1>'s, with both tape pointers pointing at cell 0. The tape ideally would expand infinitely as needed.

The commands are:

```< Move the first tape pointer left.
> Move the first tape pointer right.
{ Move the second tape pointer left.
} Move the second tape pointer right.
% Perform the Hadamard transform on the qubit pointed to by the first tape head.
- Define a phase-shift gate (described below)
+ Define a control gate (described below)
& Swap the qubit pointed to by the first tape head with the one pointed to by the second.
* Swap the first and second tape pointers.
, Input to the first qubit.
. Output the first qubit.
[ While observing the first qubit gives a 1...
] End while.
```

The two commands that take paramters are - and +.

- takes two parameters.

``` -(c,x)
```

C is a single character, which will be defined to perform this gate. x is used to define the transform, like so:

```    |0> |1>
|0> 1   0
|1> 0   e^(2*pi*i*x)
```

The character used as the first parameter will from then on be a command which can be used to perform this gate, until it's redefined or the program terminates.

+ takes nine parameters:

``` +(c,x[real],x[imaginary],y[real],y[imaginary],z[real],z[imaginary],a[real],a[imaginary])
```

C a single character (which will from then on be used for the gate), the following are sets of two representing the real and imaginary parts of four numbers, which define the following gate:

```     |00> |01> |10> |11>
|00> 1    0    0    0
|01> 0    1    0    0
|10> 0    0    x    y
|11> 0    0    z    a
```

Note that, in the above matrix, the qubit displayed on the left is actually the second pointer, and the one on the right is the first.

While it is semantically possible to define gates that do not produce valid states, the results are undefined.

Both input and output use CNOT gates. The matrix for a CNOT gate, for your reference, is:

```     |00> |01> |10> |11>
|00> 1    0    0    0
|01> 0    1    0    0
|10> 0    0    0    1
|11> 0    0    1    0
```

With input, the qubit pointed at by the first pointer is your non-control qubit (the right one in the matrix above), and the input itself is the control qubit (the left one). So, if the qubit being pointed at is 0, the input qubit will be copied. If it is 1, the inverse of the input qubit will be copied.

For output, the qubit pointed at by the first pointer is your control qubit (the left one in the matrix), and the output channel is the non-control (the right one). The output qubit is always |0> from the program's perspective, so the input qubit will be copied. The qubit pointed at and the output qubit are entangled. So, if the output qubit is observed, the qubit pointed at gets stuck, but if it goes to another program, it does not (any realistic interpreter would be forced to stick it).

This language is still under construction, make sure you consider it so :)