These days, I'm trying to use the things I learned from physics in the field of computer science. That is, I'm using IBM Quantum Computing Lab and Composer to run Python codes utilizing the Quantum Computing algorithms and I do it on real Quantum Computers (and Quantum Simulators). It is very exciting and I find it (I mean Quantum Computing) very enjoyable, but I must admit that it is difficult at first, -- after all it is different than classical computing. I mean, we still have those operators, those quantum gates (somewhat similar with the classical logic gates), but we exploit the power of the quantum computing by using those two phenomena called superposition and entanglement, and these are a little bit confusing.. It is an interesting journey, made me go back to the Linear algebra, Matrices, Tensor Products, Logic gates and stuff like that.
Well.. I will go a little quick and concise in this one. So, we have QBITs, and we do the measurements at the right place to get our results.(measuring collapses the wave function (according to the Copenhagen Interpretation of Quantum Mechanics) and make us lose those quantum states -- that's why it is important) . Actually I have lots to say about this subject but this will be the subject of a future blog post, so let's concentrate on this particular issue that I 've faced while using Qiskit Terra. (Note that-- when I try a similar code with similar logical expressions with Qiskit Aqua(which is deprecated), the expected outputs are produced).
As you may already sensed, actually it wasn't an issue. I mean the thing I identified as an issue is actually by design.. So, I will just share some information, something I learned on the way running Grover's Algorithm. In short; I was doing some quantum computing gymnastics, and I saw (thought) that some outputs are not aligned with the truth tables.
Lets see;
##Importing what I need
from qiskit import *
from qiskit.tools.visualization import plot_histogram
from qiskit.circuit.library import PhaseOracle
from qiskit.algorithms import Grover, AmplificationProblem
from qiskit.visualization import plot_histogram
##Creating my Oracle (this has nothing to do with Oracle Corporation :) Just check Grover's algorithm to understand the concept..
{'1101': 251, '0111': 274, '0011': 231, '1100': 268}