-
Notifications
You must be signed in to change notification settings - Fork 5
SQSL
The Simulated Quantum Scripting Language, also abbreviated as SQSL or Squazzle (I came up with that as a way to pronounce SQSL), is a interpreter-based language I created using two classes, one of which is a Main class called ScriptLauncher (the other is a tester, which can be deleted without any problems). This program reads from a filename that the user can specify, or a file named script.txt located in the resources folder. SQSL currently only has a few lines of code that can be used. These lines of code allow for the use of the logic gates mentioned above, as well as output for any values provided. Currently, this only includes measurement values.
###Basic Syntax
Several things will help with writing in SQSL. First, one can put as many spaces as they want before the code. However, one should never put any other spaces in the code, as it will almost certainly cause the program to fail. However, blank lines are allowed.
Comments can be added to a program with a pair of slashes (//). Anything with a pair of slashes at the beginning of it will be ignored. Using qubits in a program requires the use of an "at" symbol (@), followed by the index. For example, @3 refers to the qubit at index 3. The use of the @ symbol is intended as a precaution in case classical bits are eventually used in the interpreter.
###Creating a Quantum Register
In any program, one will require a register to hold the values. To do so, one can write something like this:
#8|{2^3}{6^7}
The first part of this code, the #, indicates that a new register will be created. The size of this register is 8, which is followed by a |. This is used to separate the register size from the list of entangled pairs of qubits, if there are any. In this case, there are two. Each pair, as shown above, is contained in curly brackets, like this:
{a^b}
In the example above, the qubit at index a would be entangled to the qubit at index b. They are separated by a caret (^), which symbolizes the "branch", so to speak, that connects them via quantum entanglement. Applying this to the original register declaration, we can tell that index 2 is entangled to index 3, and index 6 is entangled to index 7.
###Logic Gates
At the moment, only two main types of logic gates exist for use. More will eventually be added, but for now, one can experiment with what has already been written.
#####CCNOT Gate
The CCNOT gate is a gate that reverses the value of a qubit if the value of two qubits are both equal to 1. The gate is shown below:
//CCNOT X gate
CCNOTX(@a,@b,@c)
//CCNOT Y gate
CCNOTY(@a,@b,@c)
//CCNOT Z gate
CCNOTZ(@a,@b,@c)
Where a and b are the qubits that are being tested, and c is the qubit that is changed. The CCNOT gate may or may not be representative of the real-world equivalent. #####CNOT Gate
The CNOT gate is a gate that will reverse the value of a qubit if and only if the value of another qubit is 1. The code is demonstrated below:
//CNOT X gate
CNOTX(@a,@b)
//CNOT Y gate
CNOTY(@a,@b)
//CNOT Z gate
CNOTZ(@a,@b)
Where a is the qubit that is tested, and b is the qubit being changed. The CNOT gate may or may not be representative of the real-world equivalent.
#####CSWAP Gate
The CSWAP gate is a Swap gate that requires a qubit to have a value of one. The gate performs the measurement on one of the three axes depending on the CSWAP gate chosen. The code is written as shown below:
//CSWAP X gate
CSWAPX(@a,@b,@c)
//CSWAP Y gate
CSWAPY(@a,@b,@c)
//CSWAP Z gate
CSWAPZ(@a,@b,@c)
Where a is the index of the Qubit being tested, and b and c are the qubits being swapped. Keep in mind that the representation may not be 100% accurate.
#####Pauli Gate
The first is the Pauli gate, of which three exist, as demonstrated below:
//Pauli-X gate
PauliX(@n)
//Pauli-Y gate
PauliY(@n)
//Pauli-Z gate
PauliZ(@n)
In each case, the respective gates are being used on the qubit at index n.
#####Swap Gate
The Swap gate will swap two qubits between their positions. One can see the above description for more information. The syntax as follows:
Swap(@a,@b)
This will swap the qubits at indexes a and b. The comma is obviously there to separate the two values and avoid confusion.
###Output
Output allows for values to be displayed on the screen. There are two ways to output this.
Output(param)
OutputLn(param)
The only difference between the two is that OutputLn will go to a new line after performing its task. The param in the parenteses can be replaced by any compatible values. This does NOT include qubits, since they are a superposition of multiple values.
#####Measurement
Measurement can be done through the use of one of three possible code segments, depending on the dimension. For example, measuring the X-axis of the qubit at index n would be done by writing:
MeasureX(@n)
For the Y and Z dimensions, replacing X with the proper value will get the desired code. Keep in mind that for measurement, it will guarantee either a 0 or 1 as output. This means that it can be used as a parameter for the Output and OutputLn code segments.
Home | About | Help Guide | SQSL | Created by Christopher Hittner