A Refresher on Boolean Logic

Before diving into the fascinating realm of quantum logic, mastering the fundamentals of classical logic and traditional logic gates is essential.
Introduction
Author

NicDeclic

Published

September 16, 2026

“Nature proposes an ‘AND’. Our observation enforces an ‘OR’.”
Professor Alvin



Click to see library imports
import sys
if 'google.colab' in sys.modules:
    # 1. Download qmc.py from GitHub
    !wget -q https://raw.githubusercontent.com/nicdeclic/quantum-molecular-computing/main/qmc.py
    
    # 2. Download requirements.txt from GitHub
    !wget -q https://raw.githubusercontent.com/nicdeclic/quantum-molecular-computing/main/requirements.txt

    # 3. Install dependencies
    !pip install -q -r requirements.txt

sys.path.insert(0, "../..") # Select root directory
from qmc import * # QMC library

Logical States

Before diving into the fascinating realm of quantum logic, mastering the fundamentals of classical logic and traditional logic gates is essential.

Logic gates are the foundational building blocks of digital electronics and modern computing. They manipulate binary signals—units of information represented by bits that take one of two distinct values: “0” (false, low, off) or “1” (true, high, on).

Throughout this blog, we will express all circuits in matrix form. So, we might as well get comfortable with this concept right from the start.

We define the logical states as:
\[ \text{ZERO} = \begin{bmatrix} 1 & 0 \end{bmatrix} \]
and
\[ \text{ONE} = \begin{bmatrix} 0 & 1 \end{bmatrix} \]


Logical Gates

Basic logic gates are the elementary building blocks of any digital system. These gates are: NOT, AND, OR, NAND, NOR, XOR, and XNOR. Each gate exhibits a specific behavior, formally defined by a truth table that maps its inputs to its output.

The NOT Gate (Inverter)

The NOT gate is the simplest of all logic gates. It takes a single input and returns its inverse.

Symbol :

Code
# Print in LaTex format
merge.to_katex(row_labels=['a','b','c','d'])

\[ \begin{array}{r|cc|} \text{} & \text{``0''} & \text{``1''} \\ \hline \text{a} & 0 & 1 \\ \text{b} & 1 & 0 \\ \text{c} & 1 & 0 \\ \text{d} & 0 & 0 \\ \hline \end{array} \]

Standard NOT Gate (Inverter)

Truth Table: NOT Gate
Input (\(A\)) Output (\(Y\))
0 1
1 0

The output is the inverse of the input.

\[ \text{NOT} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \]

The AND Gate

The output is 1 only if both inputs \(A\) and \(B\) are 1.

Truth Table: AND Gate
Input \(A\) Input \(B\) Output \(Y\)
0 0 0
0 1 0
1 0 0
1 1 1

\[ {\text{AND}} = \begin{bmatrix} 1 & 0 \\ 1 & 0 \\ 1 & 0 \\ 0 & 1 \end{bmatrix} \]


The OR Gate

The output is 1 if at least one of the inputs is 1.

Truth Table: OR Gate
Input \(A\) Input \(B\) Output \(Y\)
0 0 0
0 1 1
1 0 1
1 1 1

\[ {\text{OR}} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 0 & 1 \\ 0 & 1 \end{bmatrix} \]


The NAND Gate (NOT-AND)

The output is 0 only when both inputs are 1.

Truth Table: NAND Gate
Input \(A\) Input \(B\) Output \(Y\)
0 0 1
0 1 1
1 0 1
1 1 0

\[ {\text{NAND}} = \begin{bmatrix} 0 & 1 \\ 0 & 1 \\ 0 & 1 \\ 1 & 0 \end{bmatrix} \]


The NOR Gate (NOT-OR)

The output is 1 only when both inputs are 0.

Truth Table: NOR Gate
Input \(A\) Input \(B\) Output \(Y\)
0 0 1
0 1 0
1 0 0
1 1 0

\[ {\text{NOR}} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ 1 & 0 \\ 1 & 0 \end{bmatrix} \]


The XOR Gate (Exclusive OR)

The output is 1 if the inputs are different, and 0 if they are identical.

Truth Table: XOR Gate
Input \(A\) Input \(B\) Output \(Y\)
0 0 0
0 1 1
1 0 1
1 1 0

\[ {\text{XOR}} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 0 & 1 \\ 1 & 0 \end{bmatrix} \]


The XNOR Gate (Equivalence Gate)

The inverse of XOR. The output is 1 only if the inputs are identical.

Truth Table: XNOR Gate
Input \(A\) Input \(B\) Output \(Y\)
0 0 1
0 1 0
1 0 0
1 1 1

\[ {\text{XNOR}} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ 1 & 0 \\ 0 & 1 \end{bmatrix} \]