0% found this document useful (0 votes)
12 views13 pages

Exercise 4

1. Grover's algorithm is a quantum search algorithm that allows finding a specific entry in an unstructured database exponentially faster than classical algorithms. It works by using amplitude amplification via quantum phenomena to achieve quadratic speedup compared to classical search. 2. One use case is for searching a large unencrypted keyspace for a matching key. This could potentially allow cracking symmetric encryption faster than with classical computing. 3. However, current quantum computers only have 50-100 qubits, which is not enough to search large keyspaces like 256-bit encryption in a reasonable number of iterations due to the exponential relationship between keyspace size and required qubits. Real-world applications may be limited until quantum hardware improves further.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views13 pages

Exercise 4

1. Grover's algorithm is a quantum search algorithm that allows finding a specific entry in an unstructured database exponentially faster than classical algorithms. It works by using amplitude amplification via quantum phenomena to achieve quadratic speedup compared to classical search. 2. One use case is for searching a large unencrypted keyspace for a matching key. This could potentially allow cracking symmetric encryption faster than with classical computing. 3. However, current quantum computers only have 50-100 qubits, which is not enough to search large keyspaces like 256-bit encryption in a reasonable number of iterations due to the exponential relationship between keyspace size and required qubits. Real-world applications may be limited until quantum hardware improves further.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

1-2 (1,2,3,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

The third qubit is an ancilla qubit.

Verifications

* Not all states are depicted but the most important ones

● Whenever C is 1; the result is 0


● So c has to be 0 at all times and the minimum either of a or b should be 1 to result to
become 1
3. (a NAND c) AND (b XOR d) AND (a AND b)

a c b d a↑c b⊕d a∧ (a↑c)∧(b⊕d) ((a↑c)∧(b⊕d))∧(a∧b)


b

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

Only a = 1 , b = 1 , c = 0 , d = 0 gives the result → 1


All the other states would give result state → 0

● What happens when you input values in superposition to the program (|+⟩ or |−⟩)?

This would result in a superposition-driven computation of 0 and 1 states simultaneously


leading to better performance than classical gates.

4.
2.

1.
def main():
# Definition of registers
qr = qiskit.QuantumRegister(7)
cr = qiskit.ClassicalRegister(7)

# Quantum circuit goes here!


qc = qiskit.QuantumCircuit(qr, cr)

for i in range(4):
qc.h(i)

# 'a NAND c'


qc.ccx(0, 2, 4)
qc.x(4)
qc.barrier()

# 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()

# 'a NAND c'


qc.ccx(0, 2, 4)
qc.x(4)
qc.barrier()
# Grovers

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()

# Measure the qubits


qc.measure(qr, cr)

# Draw circuit
print(qc.draw())

# Run circuit in simulator backend for 1000 shots


backend = AerSimulator()
job = backend.run(qc, shots=10000)
results = job.result()
counts = results.get_counts()

# Plot results
plot_histogram(counts)
plt.show()
2. Introducing noise to the model

backend = AerSimulator(method='automatic', noise_model = create_noise_model(0,


0.001, 0.1))

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.

1. Explore Grover’s algorithm and explain to yourself what it does.

Grover's algorithm is a quantum algorithm, that can be used as an efficient search


algorithm, to search specific values in huge pools of unstructured data. While classical
search algorithms have to go one by one resulting in O(N) of time complexity Grover’s
algorithm only takes of time complexity. The main reason for such speed-up is
the ability to use amplitude amplification in quotum phenomena and the quadratic
speedup that comes with qubits’ and their simultaneous superpositions.

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.

You might also like