from sympy import *
import numpy as np
from sympy.physics.quantum import TensorProduct
from sympy import Matrix, I
from sympy.physics.quantum.dagger import Dagger
init_printing(use_unicode=True)

H=Matrix([[1/sqrt(2), 1/sqrt(2)],[1/sqrt(2), -1/sqrt(2)]])
lhs=H
lhs

bra_0=Matrix([[1],[0]])
ket_0=Dagger(bra_0)
bra_1=Matrix([[0],[1]])
ket_1=Dagger(bra_1)
bra_plus=(1/sqrt(2))*Matrix([[1],[1]])
ket_plus=Dagger(bra_plus)
bra_minus=(1/sqrt(2))*Matrix([[1],[-1]])
ket_minus=Dagger(bra_minus)
bra_0, ket_0, bra_1, ket_1, bra_plus, bra_minus, ket_plus, ket_minus

#Test
1/sqrt(2)*(TensorProduct(bra_0, ket_0)+TensorProduct(bra_1, ket_1))

#option A
rhs=1/sqrt(2)*(TensorProduct(bra_0, ket_0)+TensorProduct(bra_1, ket_1))
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")

#option B
rhs=(TensorProduct(bra_0, ket_plus)+TensorProduct(bra_1, ket_minus))
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")

#option C
rhs=1/sqrt(2)*(TensorProduct(bra_0, ket_0)+
               TensorProduct(bra_0, ket_1)+
               TensorProduct(bra_1, ket_0)-
               TensorProduct(bra_1, ket_1))
                
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")

#option C
rhs=1/sqrt(2)*(TensorProduct(bra_plus, ket_0)+
               TensorProduct(bra_minus, ket_1))
                
print (lhs)
print (rhs)
if (lhs==rhs):
    print ("It is true")
else:
    print ("It is false")