I want to create a gate that, given a sequence of qbits that encode n, transforms that sequence in n+1, in other words the successor function. I managed to do it in qiskit by writing this:
def plus_one(qubit_number : int):
circuit = QuantumCircuit(qubit_number, name="plus_one")
for q in reversed(range(1, qubit_number)):
circuit.mcx([x for x in range(0, q)], q, ctrl_state=(2**q)-1)
circuit.x(0)
return circuit.to_gate()
The idea is: iterating from most significant to least significant, if all less significant qbits are equal to one flip the current qbit.
The problem is that, when I use several of them, transpilation takes forever. Is there some simpler way to implement this, that doesn't use multiple MCXGates?