Exercise 4
Exercise 4
2-2 (1,2)
3-2 (1,2,3)
1.
1. (a AND NOT b)
a b (a ∧ ¬b)
0 0 0
0 1 0
1 0 1
1 1 0
Verifications
● a=0,b=0→c=0
● a = 0, b = 1 → c = 0
● a = 1 and b = 0 → c = 1
● a = 1, b = 1 → c =0
2. (a OR b) AND (NOT c)
a b c ((a ∨ b) ∧ ¬c)
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0
Verifications
* Not all states are depicted but the most important ones
1 1 1 1 0 0 1 0 0
1 1 1 0 0 1 1 0 0
1 1 0 1 0 1 0 0 0
1 1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 0 0
1 0 1 0 1 1 1 1 1
1 0 0 1 1 1 0 1 0
1 0 0 0 1 0 0 0 0
0 1 1 1 1 0 0 0 0
0 1 1 0 1 1 0 1 0
0 1 0 1 1 1 0 1 0
0 1 0 0 1 0 0 0 0
0 0 1 1 1 0 0 0 0
0 0 1 0 1 1 0 1 0
0 0 0 1 1 1 0 1 0
0 0 0 0 1 0 0 0 0
Verification
● What happens when you input values in superposition to the program (|+⟩ or |−⟩)?
4.
2.
1.
def main():
# Definition of registers
qr = qiskit.QuantumRegister(7)
cr = qiskit.ClassicalRegister(7)
for i in range(4):
qc.h(i)
# b XOR d
qc.cx(1, 3)
qc.cx(3, 5)
qc.barrier()
# a AND b
qc.ccx(0, 1, 6)
qc.barrier()
################################
qc.h(6)
qc.ccx(4, 5, 6)
qc.h(6)
################################
qc.barrier()
# a AND b
qc.ccx(0, 1, 6)
qc.barrier()
# b XOR d
qc.cx(1, 3)
qc.cx(3, 5)
qc.barrier()
for i in range(4):
qc.h(i)
for i in range(4):
qc.x(i)
qc.barrier()
qc.h(3)
qc.mcx([0 ,1, 2], 3)
qc.h(3)
qc.barrier()
for i in range(4):
qc.x(i)
for i in range(4):
qc.h(i)
qc.barrier()
# Draw circuit
print(qc.draw())
# Plot results
plot_histogram(counts)
plt.show()
2. Introducing noise to the model
As you can see, when noise is introduced to the computation, the probability of error states
goes up negating the amplitude amplification of the intended state.
3.
2. Come up with a use case for Grover’s algorithm and consider what would be its
ramifications.
Use case: search and find a matching key from a large unstructured keyspace
Ramification: Since Glover’s algorithm can search a large key space efficiently compared to
classical computing and its algorithms, the number of iterations that could take to crack
symmetric key encryption is low. (explained above sqrt of N time complexity)
3. What sort of caveats do you think that the algorithm can have in realistic real-world
scenarios?
Current encryption keys usually use 256 bits, which means that there can be 2 ^ 256
possibilities. However with Grovers algorithm, the number of iterations can be summarized as,
N = Keyspace
M = No of qubits
In the real world currently, the number of qubits in Quantum computers is quite small and not
widely available. From 20-50 in the most performant quantum computers. Assuming it is 50
103
qubits the number of iterations to get the correct key from the key space is about π/4 * 2
which is pretty significantly large.