from sympy import *
from sympy.physics.quantum.state import Ket, Bra
from sympy.physics.quantum import TensorProduct
import numpy as np
init_printing(use_unicode=True)

#One Q bit gates
H=Matrix([[1/sqrt(2), 1/sqrt(2)],[1/sqrt(2), -1/sqrt(2)]])
S=Matrix([[0, 1],[1, I]])
X=Matrix([[0, 1],[1, 0]])
Y=Matrix([[0, -I],[I, 0]])
Z=Matrix([[1, 0],[0, -1]])
Identity=Matrix([[1, 0],[0, 1]])
H, S, X, Y, Z, Identity

#Two Q  bit gates
CNOT=Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]])
CNOT
HI=TensorProduct(H, Identity)    #Example only
CNOT, HI

circuit=TensorProduct(X, Identity)*CNOT*TensorProduct(X, Identity)
circuit

#option A
in_1=Matrix([[1],[0],[0],[0]])
lhs=circuit*in_1
rhs=Matrix([[0],[1],[0],[0]])
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")

#option B
in_1=Matrix([[0],[1],[0],[0]])
lhs=circuit*in_1
rhs=Matrix([[0],[1],[0],[0]])
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")

#option C
in_1=Matrix([[0],[0],[1],[0]])
lhs=circuit*in_1
rhs=Matrix([[0],[0],[1],[0]])
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")

#option D
in_1=Matrix([[0],[0],[1],[0]])
lhs=circuit*in_1
rhs=Matrix([[0],[0],[0],[1]])
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")