A Reimplementation of OR

Learn how we can reimplement OR and implement the reverse qubit.

OR implementation

Press + to interact
def my_or(p, q):
return not (not p and not q)
print('P | Q | P or Q')
print('--------------')
print('T | T | {}'.format(my_or(True, True)))
print('T | F | {}'.format(my_or(True, False)))
print('F | T | {}'.format(my_or(False, True)))
print('F | F | {}'.format(my_or(False, False)))

This is what programming is all about. Programmers write functions that produce a particular behavior. They use and combine these functions to create even more functions that exhibit complex behavior. The entire program they write comes down to a set of functions that have been intelligently combined. Programmers have their compiler or interpreter to translate the higher-level functions down to basic boolean logic. This basic boolean logic can be performed using electrical switches. The switches and their combination are called gates. When we connect gates, they form a circuit.

At a discrete interval, the computer sends a pulse of electricity through the circuit. If we receive a pulse of electricity appropriately, we interpret it as 1 (true). If we don’t receive a pulse, we interpret it as 0(false).

Despite the name, there is nothing circular about circuits. They are linear and are read from left to right. Let’s look at an example that corresponds to the boolean functions that we looked at earlier.

The following figure depicts the circuit diagram of not (not P and not Q). The circuit receives the input from the left and outputs it to the right.

Such gates and circuits are the building blocks of any modern computer. This includes quantum computers. While the world of quantum mechanics is different, the world of quantum computing is surprisingly similar.

Let’s return to our introductory formula:

ψ=α0+β1=[αβ]|\psi\rangle = \alpha|0\rangle + \beta|1\rangle = \begin{bmatrix}\alpha\\\beta\end{bmatrix}, with ...