0

I started play with the Qiskit, and can't find an anti-control not there. By "anti-control" I mean the gate is executed only for these states of the superposition, where control qubit is in the Zero state. It's annoying to use a code like

circuit.x(control)
circuit.cx(control, target)
circuit.x(control)

I would rather prefer

circuit.acx(control, target)

On the circuits language, I want to use a control gate from

enter image description here

Is there a dedicated operation for it in the Qiskit?

Community
  • 1
  • 1
Oxoron
  • 598
  • 1
  • 5
  • 20

1 Answers1

2

You can make your own "anti-controlled" gate by specifying what to control an x gate on, using this method here.

I think this would look something like

anti_gate = XGate.control(ctrl_state='0')
circuit.append(anti_gate, [control, target])
met927
  • 301
  • 4
  • 8
  • could you help with imports, please? "from qiskit.extensions.standard import XGate" handles XGate, but how to import control? "from qiskit.circuit import *" doesn't work – Oxoron Apr 18 '20 at 11:16
  • You shouldn't need to import control - the first mention of control is a method on the `XGate` and the second mention of control I was copying your terminology from the question, it is the qubit you want to control the gate on. – met927 Apr 19 '20 at 08:49
  • 1
    unfortunately, this functionality doesn't work properly at the moment, the fix is waiting for release: https://github.com/Qiskit/qiskit-terra/issues/4175 , https://github.com/Qiskit/qiskit-terra/issues/4180 . In any case, you shown me the right direction, and I thank you for help. – Oxoron Apr 20 '20 at 20:45