Simple example programs using Silq
In this section, let's see some simple quantum circuits that can be implemented in Silq; mostly, we will be focusing our discussion on the quantum logic gates that we learned about in Chapter 2, Quantum Bits, Quantum Measurements, and Quantum Logic Gates.
Let's start with the Pauli X gate, which looks as follows in the Silq language:
def main() { return PauliX(); } def PauliX() { x:=0:; return X(x); }
The preceding program is fairly easy to understand and implement. You can see that the x
qubit is initialized to 0
, so the expected output should be 1
. Figure 6.12 shows the output of this program:
Now, let's see the Pauli Y gate. The code for the Y gate is as follows:
def main() { return PauliY(); } def PauliY() { ...