Questions

  1. Run Grover's algorithm using different iteration numbers to solve 3sat_mystery(a,b,c). What happens when we use only one iteration? Zero iterations? More than the recommended number?
  2. Switch variables b and c in the 3sat_mystery(a,b,c) function to create a new mystery function. What result do you expect? Verify that you get this result classically, and that Grover's algorithm works for this new function to reproduce the classic result.
  3. Challenge problem: modify the implementation of 3sat_mystery(a,b,c) to use at least one fewer temporary qubits. Verify your modification still produces the correct result. Continue modifying the code to use as few temporary qubits as possible while producing the correct result. What is the smallest number you can possibly use? The fewer qubits used, the smaller the number of qubits in the quantum computer necessary to solve the problem.
  4. 2SAT Grover:
    1. Implement the following 2SAT function classically, where each clause contains the OR of two variables, and the clauses are combined with an AND: . Verify your function returns true only for the case of =True, =False. How many inputs did you need to check classically?
    2. Implement your function on a quantum computer using multi-qubit AND and multi-qubit OR.
    3. Modify the code in this chapter to execute Grover's algorithm to find the input for this 2SAT function that satisfies it. How many iterations did you need? What happens if you increase or decrease the number of iterations?
    1. Challenge problem: modify the code to run on IBM QX hardware. You will need to make sure to use no more than the number of qubits available on the current hardware you have access to, to make sure the program is of the appropriate length, and to take care that, on IBM hardware, it is in general possible to compute a CNOT gate between two qubits only for some pairs of qubits.
  1. Apply the mover and checker functions once more to the output by manually calculating their results:

What is the probability of observing the correct state |"110"> after this second iteration?