def build_correction(self):
     # Build Correction Circuit
     circ = QuantumCircuit(self.code, self.syndrm)
     circ.append(XGate().control(4, ctrl_state='0010'),
                 [self.syndrm[i] for i in range(4)] + [self.code[0]])
     circ.append(YGate().control(4, ctrl_state='1110'),
                 [self.syndrm[i] for i in range(4)] + [self.code[0]])
     circ.append(ZGate().control(4, ctrl_state='1100'),
                 [self.syndrm[i] for i in range(4)] + [self.code[0]])
     circ.append(XGate().control(4, ctrl_state='0101'),
                 [self.syndrm[i] for i in range(4)] + [self.code[1]])
     circ.append(YGate().control(4, ctrl_state='1101'),
                 [self.syndrm[i] for i in range(4)] + [self.code[1]])
     circ.append(ZGate().control(4, ctrl_state='1000'),
                 [self.syndrm[i] for i in range(4)] + [self.code[1]])
     circ.append(XGate().control(4, ctrl_state='1010'),
                 [self.syndrm[i] for i in range(4)] + [self.code[2]])
     circ.append(YGate().control(4, ctrl_state='1011'),
                 [self.syndrm[i] for i in range(4)] + [self.code[2]])
     circ.append(ZGate().control(4, ctrl_state='0001'),
                 [self.syndrm[i] for i in range(4)] + [self.code[2]])
     circ.append(XGate().control(4, ctrl_state='0100'),
                 [self.syndrm[i] for i in range(4)] + [self.code[3]])
     circ.append(YGate().control(4, ctrl_state='0111'),
                 [self.syndrm[i] for i in range(4)] + [self.code[3]])
     circ.append(ZGate().control(4, ctrl_state='0011'),
                 [self.syndrm[i] for i in range(4)] + [self.code[3]])
     circ.append(XGate().control(4, ctrl_state='1001'),
                 [self.syndrm[i] for i in range(4)] + [self.code[4]])
     circ.append(YGate().control(4, ctrl_state='1111'),
                 [self.syndrm[i] for i in range(4)] + [self.code[4]])
     circ.append(ZGate().control(4, ctrl_state='0110'),
                 [self.syndrm[i] for i in range(4)] + [self.code[4]])
     return circ
    def build_correction(self):

        # Build Correction Circuit
        circ = QuantumCircuit(self.code, self.syndrm)
        circ.append(XGate().control(2, ctrl_state=2), [self.syndrm[0], self.syndrm[1], self.code[2]])
        circ.append(XGate().control(2, ctrl_state=3), [self.syndrm[0], self.syndrm[1], self.code[1]])
        circ.append(XGate().control(2, ctrl_state=1), [self.syndrm[0], self.syndrm[1], self.code[0]])
        return circ
Пример #3
0
    def test_get_gate(self):
        """Test `get`."""
        sched = Schedule()
        sched.append(Play(Waveform(np.ones(5)), DriveChannel(0)))
        inst_map = InstructionScheduleMap()
        inst_map.add(XGate(), 0, sched)

        self.assertEqual(sched, inst_map.get(XGate(), (0, )))
 def _echo_rzx_dag(theta):
     rzx_dag = DAGCircuit()
     qr = QuantumRegister(2)
     rzx_dag.add_qreg(qr)
     rzx_dag.apply_operation_back(RZXGate(theta / 2), [qr[0], qr[1]], [])
     rzx_dag.apply_operation_back(XGate(), [qr[0]], [])
     rzx_dag.apply_operation_back(RZXGate(-theta / 2), [qr[0], qr[1]], [])
     rzx_dag.apply_operation_back(XGate(), [qr[0]], [])
     return rzx_dag
Пример #5
0
    def test_pop_gate(self):
        """Test pop with default."""
        sched = Schedule()
        inst_map = InstructionScheduleMap()

        inst_map.add(XGate(), 100, sched)
        self.assertEqual(inst_map.pop(XGate(), 100), sched)
        self.assertFalse(inst_map.has(XGate(), 100))

        self.assertEqual(inst_map.qubit_instructions(100), [])
        self.assertEqual(inst_map.qubits_with_instruction(XGate()), [])
        with self.assertRaises(PulseError):
            inst_map.pop('not_there', (0, ))
Пример #6
0
 def definition(self) -> List:
     """Return definition in terms of other basic gates. If the gate has
     open controls, as determined from `self.ctrl_state`, the returned
     definition is conjugated with X without changing the internal
     `_definition`.
     """
     if self._open_ctrl:
         closed_gate = self.copy()
         closed_gate.ctrl_state = None
         # pylint: disable=cyclic-import
         from qiskit.circuit.library.standard_gates import XGate
         bit_ctrl_state = bin(self.ctrl_state)[2:].zfill(
             self.num_ctrl_qubits)
         qreg = QuantumRegister(self.num_qubits)
         definition = [(closed_gate, qreg, [])]
         open_rules = []
         for qind, val in enumerate(bit_ctrl_state[::-1]):
             if val == '0':
                 open_rules.append([XGate(), [qreg[qind]], []])
         if open_rules:
             return open_rules + definition + open_rules
         else:
             return self._definition
     else:
         return super().definition
Пример #7
0
def reset_error(prob0, prob1=0):
    r"""
    Return a single qubit reset quantum error channel.

    The error channel returned is given by the map

    .. math::

        E(ρ) = (1 - p_0 - p_1) ρ + \text{Tr}[ρ] \left(
                p_0 |0 \rangle\langle 0|
                + p_1 |1 \rangle\langle 1| \right)

    where the probability of no reset is given by :math:`1 - p_0 - p_1`.

    Args:
        prob0 (double): reset probability to :math:`|0\rangle`.
        prob1 (double): reset probability to :math:`|1\rangle`.

    Returns:
        QuantumError: the quantum error object.

    Raises:
        NoiseError: If noise parameters are invalid.
    """
    if prob0 < 0 or prob1 < 0 or prob0 > 1 or prob1 > 1 or (prob0 + prob1) > 1:
        raise NoiseError("Invalid reset probabilities.")
    noise_ops = [([(IGate(), [0])], 1 - prob0 - prob1),
                 ([(Reset(), [0])], prob0),
                 ([(Reset(), [0]), (XGate(), [0])], prob1)]
    return QuantumError(noise_ops)
Пример #8
0
    def to_instruction(self):
        """Convert to Pauli circuit instruction."""
        from math import pi

        pauli, phase = self._to_label(self.z,
                                      self.x,
                                      self._phase[0],
                                      full_group=False,
                                      return_phase=True)
        if len(pauli) == 1:
            gate = {
                "I": IGate(),
                "X": XGate(),
                "Y": YGate(),
                "Z": ZGate()
            }[pauli]
        else:
            gate = PauliGate(pauli)
        if not phase:
            return gate
        # Add global phase
        circuit = QuantumCircuit(self.num_qubits, name=str(self))
        circuit.global_phase = -phase * pi / 2
        circuit.append(gate, range(self.num_qubits))
        return circuit.to_instruction()
Пример #9
0
 def definition(self) -> List:
     """Return definition in terms of other basic gates. If the gate has
     open controls, as determined from `self.ctrl_state`, the returned
     definition is conjugated with X without changing the internal
     `_definition`.
     """
     if not self._definition:
         self._define()
     # pylint: disable=cyclic-import
     from qiskit.circuit.library.standard_gates import XGate, CXGate
     bit_ctrl_state = bin(self.ctrl_state)[2:].zfill(self.num_ctrl_qubits)
     # hacky way to get register assuming single register
     if self._definition:
         qreg = self._definition[0][1][0].register
         definition = self._definition
     elif isinstance(self, CXGate):
         qreg = QuantumRegister(self.num_qubits, 'q')
         definition = [(self, [qreg[0], qreg[1]], [])]
     open_rules = []
     for qind, val in enumerate(bit_ctrl_state[::-1]):
         if val == '0':
             open_rules.append([XGate(), [qreg[qind]], []])
     if open_rules:
         return open_rules + definition + open_rules
     else:
         return self._definition
Пример #10
0
def diffuser(list_values: list, circuit_type: str):
    n = len(list_values[0])
    assert n >= 2, 'Length of input should be greater or equal to 2.'

    if (circuit_type == 'noancilla' or n == 2):

        q1 = QuantumRegister(n, "q")
        a1 = QuantumCircuit(q1)

        a1.h(q1[[*range(n)]])
        a1.x(q1[[*range(n)]])
        a1.h(q1[n - 1])

        gate = XGate().control(n - 1)
        a1.append(gate, q1)

    elif circuit_type == 'ancilla':
        r = 0
        pn = r + 2
        jn = r
        kn = r + 1
        q1 = QuantumRegister(n * 2, "q")
        a1 = QuantumCircuit(q1)

        ######### Apply Hadamard and X gates.
        a1.h(q1[[*range(n)]])
        a1.x(q1[[*range(n)]])
        a1.h(q1[n -
                1])  # Apply Hadamrd gate on the left of the target qubit n.
        #########

        a1.ccx(q1[r], q1[r + 1], q1[r + n])
        for i in range(n - 3):
            a1.ccx(q1[pn], q1[n + jn], q1[n + kn])
            if i < n - 4:
                pn += 1
                jn += 1
                kn += 1

        ##a1.barrier()
        a1.cx(q1[(n * 2) - 3], q1[(n - 1)])
        ##a1.barrier()

        for i in range(n - 3):
            a1.ccx(q1[pn], q1[n + jn], q1[n + kn])
            if i < n - 4:
                pn += -1
                jn += -1
                kn += -1
        a1.ccx(q1[r], q1[r + 1], q1[r + n])

    ######### Apply Hadamard and X gates.
    a1.h(q1[n - 1])  # Apply Hadamrd gate on the right of the target qubit n.
    a1.x(q1[[*range(n)]])
    a1.h(q1[[*range(n)]])
    #########
    return a1
Пример #11
0
 def setUp(self):
     super().setUp()
     self.ops = {
         'X': XGate(),
         'Y': YGate(),
         'Z': ZGate(),
         'H': HGate(),
         'S': SGate()
     }
    def _echo_rzx_dag(theta):
        """Return the following circuit

        .. parsed-literal::

                 ┌───────────────┐┌───┐┌────────────────┐┌───┐
            q_0: ┤0              ├┤ X ├┤0               ├┤ X ├
                 │  Rzx(theta/2) │└───┘│  Rzx(-theta/2) │└───┘
            q_1: ┤1              ├─────┤1               ├─────
                 └───────────────┘     └────────────────┘
        """
        rzx_dag = DAGCircuit()
        qr = QuantumRegister(2)
        rzx_dag.add_qreg(qr)
        rzx_dag.apply_operation_back(RZXGate(theta / 2), [qr[0], qr[1]], [])
        rzx_dag.apply_operation_back(XGate(), [qr[0]], [])
        rzx_dag.apply_operation_back(RZXGate(-theta / 2), [qr[0], qr[1]], [])
        rzx_dag.apply_operation_back(XGate(), [qr[0]], [])
        return rzx_dag
Пример #13
0
    def test_grover_oracle(self):
        """Synthesis of grover_oracle example"""
        oracle = compile_classical_function(examples.grover_oracle)
        quantum_circuit = oracle.synth()

        expected = QuantumCircuit(5)
        expected.append(XGate().control(4, ctrl_state="1010"), [0, 1, 2, 3, 4])

        self.assertEqual(quantum_circuit.name, "grover_oracle")
        self.assertEqual(quantum_circuit, expected)
Пример #14
0
    def test_grover_oracle(self):
        """grover_oracle.decomposition"""
        oracle = compile_classical_function(examples.grover_oracle)
        quantum_circuit = QuantumCircuit(5)
        quantum_circuit.append(oracle, [2, 1, 0, 3, 4])

        expected = QuantumCircuit(5)
        expected.append(XGate().control(4, ctrl_state="1010"), [2, 1, 0, 3, 4])

        self.assertEqual(quantum_circuit.decompose(), expected)
Пример #15
0
    def from_label(cls, label):
        """Return a tensor product of single-qubit operators.

        Args:
            label (string): single-qubit operator string.

        Returns:
            Operator: The N-qubit operator.

        Raises:
            QiskitError: if the label contains invalid characters, or the
                         length of the label is larger than an explicitly
                         specified num_qubits.

        Additional Information:
            The labels correspond to the single-qubit matrices:
            'I': [[1, 0], [0, 1]]
            'X': [[0, 1], [1, 0]]
            'Y': [[0, -1j], [1j, 0]]
            'Z': [[1, 0], [0, -1]]
            'H': [[1, 1], [1, -1]] / sqrt(2)
            'S': [[1, 0], [0 , 1j]]
            'T': [[1, 0], [0, (1+1j) / sqrt(2)]]
            '0': [[1, 0], [0, 0]]
            '1': [[0, 0], [0, 1]]
            '+': [[0.5, 0.5], [0.5 , 0.5]]
            '-': [[0.5, -0.5], [-0.5 , 0.5]]
            'r': [[0.5, -0.5j], [0.5j , 0.5]]
            'l': [[0.5, 0.5j], [-0.5j , 0.5]]
        """
        # Check label is valid
        label_mats = {
            'I': IGate().to_matrix(),
            'X': XGate().to_matrix(),
            'Y': YGate().to_matrix(),
            'Z': ZGate().to_matrix(),
            'H': HGate().to_matrix(),
            'S': SGate().to_matrix(),
            'T': TGate().to_matrix(),
            '0': np.array([[1, 0], [0, 0]], dtype=complex),
            '1': np.array([[0, 0], [0, 1]], dtype=complex),
            '+': np.array([[0.5, 0.5], [0.5, 0.5]], dtype=complex),
            '-': np.array([[0.5, -0.5], [-0.5, 0.5]], dtype=complex),
            'r': np.array([[0.5, -0.5j], [0.5j, 0.5]], dtype=complex),
            'l': np.array([[0.5, 0.5j], [-0.5j, 0.5]], dtype=complex),
        }
        if re.match(r'^[IXYZHST01rl\-+]+$', label) is None:
            raise QiskitError('Label contains invalid characters.')
        # Initialize an identity matrix and apply each gate
        num_qubits = len(label)
        op = Operator(np.eye(2 ** num_qubits, dtype=complex))
        for qubit, char in enumerate(reversed(label)):
            if char != 'I':
                op = op.compose(label_mats[char], qargs=[qubit])
        return op
Пример #16
0
    def from_label(label):
        """Return a tensor product of single-qubit Clifford gates.

        Args:
            label (string): single-qubit operator string.

        Returns:
            Clifford: The N-qubit Clifford operator.

        Raises:
            QiskitError: if the label contains invalid characters.

        Additional Information:
            The labels correspond to the single-qubit Cliffords are

            * - Label
              - Stabilizer
              - Destabilizer
            * - ``"I"``
              - +Z
              - +X
            * - ``"X"``
              - -Z
              - +X
            * - ``"Y"``
              - -Z
              - -X
            * - ``"Z"``
              - +Z
              - -X
            * - ``"H"``
              - +X
              - +Z
            * - ``"S"``
              - +Z
              - +Y
        """
        # Check label is valid
        label_gates = {
            'I': IGate(),
            'X': XGate(),
            'Y': YGate(),
            'Z': ZGate(),
            'H': HGate(),
            'S': SGate()
        }
        if re.match(r'^[IXYZHS\-+]+$', label) is None:
            raise QiskitError('Label contains invalid characters.')
        # Initialize an identity matrix and apply each gate
        num_qubits = len(label)
        op = Clifford(np.eye(2 * num_qubits, dtype=np.bool))
        for qubit, char in enumerate(reversed(label)):
            _append_circuit(op, label_gates[char], qargs=[qubit])
        return op
Пример #17
0
def qor(n=2):
    q = QuantumRegister(n)
    a = QuantumRegister(1)
    qc = QuantumCircuit(q, a, name="Or(%i)" % n)

    qc.x(q)
    qc.append(XGate().control(n), q[:] + [a])
    qc.x(q)
    qc.x(a)

    return qc
    def test_cx_1_0(self):
        """CX(1, 0)"""
        tweedledum_circuit = {'num_qubits': 2, 'gates': [{'gate': 'X',
                                                          'qubits': [0],
                                                          'control_qubits': [1],
                                                          'control_state': '1'}]}
        circuit = tweedledum2qiskit(tweedledum_circuit)

        expected = QuantumCircuit(2)
        expected.append(XGate().control(1, ctrl_state='1'), [1, 0])

        self.assertEqual(expected, circuit)
Пример #19
0
 def to_instruction(self):
     """Convert to Pauli circuit instruction."""
     from qiskit.circuit import QuantumCircuit, QuantumRegister
     from qiskit.circuit.library.standard_gates import IGate, XGate, YGate, ZGate
     gates = {'I': IGate(), 'X': XGate(), 'Y': YGate(), 'Z': ZGate()}
     label = self.to_label()
     num_qubits = self.num_qubits
     qreg = QuantumRegister(num_qubits)
     circuit = QuantumCircuit(qreg, name='Pauli:{}'.format(label))
     for i, pauli in enumerate(reversed(label)):
         circuit.append(gates[pauli], [qreg[i]])
     return circuit.to_instruction()
Пример #20
0
    def _define(self):
        definition = []
        qr = QuantumRegister(self.num_ctrl_qubits + 1)

        ctrl_qr = qr[:self.num_ctrl_qubits]
        target_qubit = qr[self.num_ctrl_qubits]

        if self.qubit_values:
            for qubit_index, qubit_value in enumerate(self.qubit_values):
                if not qubit_value:
                    definition.append((XGate(), [ctrl_qr[qubit_index]], []))

        definition.append((MCXGate(self.num_ctrl_qubits),
                           list(ctrl_qr) + [target_qubit], []))

        if self.qubit_values:
            for qubit_index, qubit_value in enumerate(self.qubit_values):
                if not qubit_value:
                    definition.append((XGate(), [ctrl_qr[qubit_index]], []))

        self.definition = definition
Пример #21
0
 def test_thermal_relaxation_error_t1_equal_t2_1state(self):
     """Test qobj instructions return for t1=t2"""
     actual = thermal_relaxation_error(1, 1, 1, 1)
     expected = QuantumError([
         (IGate(), np.exp(-1)),
         ([(Reset(), [0]), (XGate(), [0])], 1 - np.exp(-1)),
     ])
     for i in range(actual.size):
         circ, prob = actual.error_term(i)
         expected_circ, expected_prob = expected.error_term(i)
         self.assertEqual(circ, expected_circ, msg=f"Incorrect {i}-th circuit")
         self.assertAlmostEqual(prob, expected_prob, msg=f"Incorrect {i}-th probability")
Пример #22
0
    def test_pauli_error_1q_gate_from_string(self):
        """Test single-qubit pauli error as gate qobj from string label"""
        paulis = ['I', 'X', 'Y', 'Z']
        probs = [0.4, 0.3, 0.2, 0.1]
        actual = pauli_error(zip(paulis, probs))

        expected = QuantumError([(IGate(), 0.4), (XGate(), 0.3), (YGate(), 0.2), (ZGate(), 0.1)])
        for i in range(actual.size):
            circ, prob = actual.error_term(i)
            expected_circ, expected_prob = expected.error_term(i)
            self.assertEqual(circ, expected_circ, msg=f"Incorrect {i}-th circuit")
            self.assertAlmostEqual(prob, expected_prob, msg=f"Incorrect {i}-th probability")
    def test_cx_qreg(self):
        """CX(0, 1) with qregs parameter"""
        qr = QuantumRegister(2, 'qr')
        tweedledum_circuit = {'num_qubits': 2, 'gates': [{'gate': 'X',
                                                          'qubits': [0],
                                                          'control_qubits': [1],
                                                          'control_state': '1'}]}
        circuit = tweedledum2qiskit(tweedledum_circuit, qregs=[qr])

        expected = QuantumCircuit(qr)
        expected.append(XGate().control(1, ctrl_state='1'), [qr[1], qr[0]])

        self.assertEqual(expected, circuit)
    def judge(new_qc, gate, bitstrings):
        target_qubit = gate[1][-1]
                
        """
        gate[0] : gate class
        gate[1] : qregs
        gate[2] : cregs
        """

        # Toffoli gates
        if gate[0].name in ['ccx', 'rccx']:
            
            if '11' in bitstrings:
                if len(bitstrings) == 1:
                    new_qc.append(XGate(label=None), [target_qubit], gate[2])

                elif '10' not in bitstrings:
                    new_qc.append(XGate(label=None).control(1), [gate[1][1], target_qubit], gate[2])

                elif '01' not in bitstrings:
                    new_qc.append(XGate(label=None).control(1), [gate[1][0], target_qubit], gate[2])

                else: #11と00の時だけようにもう一つ作る?(Qubit connectionを一つ減らせる)
                    new_qc.append(gate[0],gate[1],gate[2])

            else:
                pass # Delete CCX

        # Two-qubit gates
        else:
            if '1' in bitstrings:
                if '0' not in bitstrings:
                    new_qc.append(gate[0].base_gate, [target_qubit], gate[2])
                else:
                    new_qc.append(gate[0],gate[1],gate[2])
            else:
                pass # Delete CU
            
        return new_qc
    def _reverse_echo_rzx_dag(theta):
        """Return the following circuit

        .. parsed-literal::

                 ┌───┐┌───────────────┐     ┌────────────────┐┌───┐
            q_0: ┤ H ├┤1              ├─────┤1               ├┤ H ├─────
                 ├───┤│  Rzx(theta/2) │┌───┐│  Rzx(-theta/2) │├───┤┌───┐
            q_1: ┤ H ├┤0              ├┤ X ├┤0               ├┤ X ├┤ H ├
                 └───┘└───────────────┘└───┘└────────────────┘└───┘└───┘
        """
        reverse_rzx_dag = DAGCircuit()
        qr = QuantumRegister(2)
        reverse_rzx_dag.add_qreg(qr)
        reverse_rzx_dag.apply_operation_back(HGate(), [qr[0]], [])
        reverse_rzx_dag.apply_operation_back(HGate(), [qr[1]], [])
        reverse_rzx_dag.apply_operation_back(RZXGate(theta / 2), [qr[1], qr[0]], [])
        reverse_rzx_dag.apply_operation_back(XGate(), [qr[1]], [])
        reverse_rzx_dag.apply_operation_back(RZXGate(-theta / 2), [qr[1], qr[0]], [])
        reverse_rzx_dag.apply_operation_back(XGate(), [qr[1]], [])
        reverse_rzx_dag.apply_operation_back(HGate(), [qr[0]], [])
        reverse_rzx_dag.apply_operation_back(HGate(), [qr[1]], [])
        return reverse_rzx_dag
Пример #26
0
def build_encode_circuit(num, qubits, register_size):
	""" Create the registery conversion circuit. Assume the last qubits are the register.
	qubits [int]: Total number of qubits in the global circuit
	register_size [int]: Total number of qubits allocated for the register.
	num [int]: target encoding
	"""

	# generate the X-gate configuration
	CGates, XGates = encode_X(num, qubits, register_size)
	# create a quantum circuit acting on the registers
	conv_register = MCMT(XGate(), len(CGates), len(XGates))
	XRange = [*CGates, *XGates]

	return conv_register, XRange
    def test_cx_1_0(self):
        """CX(1, 0)"""
        tweedledum_circuit = Circuit()
        qubits = list()
        qubits.append(tweedledum_circuit.create_qubit())
        qubits.append(tweedledum_circuit.create_qubit())
        tweedledum_circuit.apply_operator(X(), [qubits[1], qubits[0]])

        circuit = tweedledum2qiskit(tweedledum_circuit)

        expected = QuantumCircuit(2)
        expected.append(XGate().control(1, ctrl_state="1"), [1, 0])

        self.assertEqual(expected, circuit)
Пример #28
0
    def test_cx_0_1(self):
        """CX(0, 1)"""
        tweedledum_circuit = Circuit()
        qubits = list()
        qubits.append(tweedledum_circuit.create_qubit())
        qubits.append(tweedledum_circuit.create_qubit())
        tweedledum_circuit.apply_operator(X(), [qubits[0], qubits[1]])

        circuit = tweedledum2qiskit(tweedledum_circuit)

        expected = QuantumCircuit(2)
        expected.append(XGate().control(1, ctrl_state='1'), [0, 1])

        self.assertEqual(circuit, expected)
    def test_cx_qreg(self):
        """CX(0, 1) with qregs parameter"""
        tweedledum_circuit = Circuit()
        qubits = list()
        qubits.append(tweedledum_circuit.create_qubit())
        qubits.append(tweedledum_circuit.create_qubit())
        tweedledum_circuit.apply_operator(X(), [qubits[1], qubits[0]])

        qr = QuantumRegister(2, "qr")
        circuit = tweedledum2qiskit(tweedledum_circuit, qregs=[qr])

        expected = QuantumCircuit(qr)
        expected.append(XGate().control(1, ctrl_state="1"), [qr[1], qr[0]])

        self.assertEqual(expected, circuit)
    def test_grover_oracle_arg_regs(self):
        """Synthesis of grover_oracle example with arg_regs"""
        oracle = compile_classical_function(examples.grover_oracle)
        quantum_circuit = oracle.synth(registerless=False)

        qr_a = QuantumRegister(1, 'a')
        qr_b = QuantumRegister(1, 'b')
        qr_c = QuantumRegister(1, 'c')
        qr_d = QuantumRegister(1, 'd')
        qr_return = QuantumRegister(1, 'return')
        expected = QuantumCircuit(qr_d, qr_c, qr_b, qr_a, qr_return)
        expected.append(XGate().control(4, ctrl_state='0101'),
                        [qr_d[0], qr_c[0], qr_b[0], qr_a[0], qr_return[0]])

        self.assertEqual(quantum_circuit.name, 'grover_oracle')
        self.assertEqual(quantum_circuit, expected)