Repository: Qiskit/qiskit

Issue:
Constructing a Clifford from an Instruction discards phase
### Environment

- **Qiskit Terra version**: `0.25.3`
- **Python version**: `3.10.12`
- **Operating system**: macOS Ventura 13.6


### What is happening?

If you make a `Clifford` from an `Instruction` which contains a phase, the phase is discarded.

### How can we reproduce the issue?

```python
from qiskit.quantum_info import Pauli, Clifford

Clifford(Pauli("-I").to_instruction()) == Clifford(Pauli("I").to_instruction())
>>> True
```

### What should happen?

I am not sure if this quite qualifies as a bug, but it seems like one of these would be helpful:
* Return `False`.
* Raise an error when the phase of the input instruction is non-zero.
* Display a warning when the phase of the input instruction is non-zero.
* Include a statement about this in the documentation somewhere (unless I missed it!).

### Any suggestions?

_No response_


Discussion:
This looks like a straight bug to me - I imagine it's just that we forget to examine the `global_phase` of instruction definitions when building a Clifford from a circuit or instruction.  I think the right course of action will be to succeed if the phase is a multiple of $\pi/2$ and fail if it's not, similar to how the $R_z$ gate (e.g.) is brought in.
I do not think that this is a bug, since a `Clifford` is only defined up to a global phase. Indeed, it's not written in the documentation, but this is something well known (see e.g. this [summary](http://home.lu.lv/~sd20008/papers/essays/Clifford%20group%20%5Bpaper%5D.pdf) about the Clifford group).

Here are a few examples of Clifford identities:

```
qc = QuantumCircuit(1)
qc.s(0)
qc.h(0)
qc.s(0)
qc.h(0)
qc.s(0)
qc.h(0)
Clifford(qc) == Clifford(Pauli("I").to_instruction()) # True
Operator(qc).equiv(Operator(Pauli("I").to_instruction())) # True
Operator(qc) == Operator(Pauli("I").to_instruction()) # False
```

and:

```
qc1 = QuantumCircuit(1)
qc1.x(0)
qc1.y(0)

qc2 = QuantumCircuit(1)
qc2.z(0)

Clifford(qc1) == Clifford(qc2) # True
Operator(qc1).equiv(Operator(qc2)) # True
Operator(qc1) == Operator(qc2) # False
```

I would therefore suggest to close this issue.
Oh yeah, you're right Shelly, sorry.

For sure I think we ought to update the documentation to highlight this, since it's a defined part of the group.  I think we might want to unify the various construction methods to ensure they behave similarly, though; at the moment, `Clifford(Pauli(...))` and `Clifford.from_label` will both reject Paulis that include an explicit non-zero phase ("-X", etc), but `Clifford.from_instruction` silently accepts such circuits, as shown in the issue.

I think that making `Clifford.from_instruction` reject Paulis with non-zero phases could be quite inconvenient for users, so I think keeping the current behaviour of erasing the phases is potentially the best.  In that case, it might be helpful to make `Clifford.from_label` also erase the phase, so that `Clifford(Pauli(qc))` and Clifford(qc)` will both accept the same set of circuits.

I don't think that emitting a warning would be great UX, given the class representation explicitly is phase-agnostic because of the equivalent action of the group.  If it's required, perhaps we could add a `strict_phase` kwarg to the constructors that could be used to turn a non-zero phase into an error, though?  I can't think of any uses for that, though, so I'd avoid it unless we've got a use-case.

Does that sound reasonable?
I agree that it's more a documentation issue and not a bug, so I changed the label accordingly.
The current documentation does not explain what a Clifford is, and relies on the fact that the users are aware of the literature, so perhaps this can be improved.
Since a Clifford object can be created in so many different ways: from a QuantumCircuit, Instruction, Gate, LinearFunction, Permutation, Pauli etc. (and combinations of all the above), it may be difficult to impose a consistent warning behavior. 
> Since a Clifford object can be created in so many different ways: from a QuantumCircuit, Instruction, Gate, LinearFunction, Permutation, Pauli etc. (and combinations of all the above), it may be difficult to impose a consistent warning behavior

I don't think we should warn, I was more meaning that we should be consistent in how we handle phases.  The `Clifford` class represents an object that's only defined up to a phase, and things like composition with a Pauli should happily throw away the phase of Pauli term, so I think it makes sense to make sure that `Clifford.from_label` and all other `Clifford` constructors treat phase in the same way (i.e. ignore a global phase).  `Clifford.from_label` at the moment just doesn't have the handling in place to throw away the phase, so it chokes.

> The current documentation does not explain what a Clifford is, and relies on the fact that the users are aware of the literature, so perhaps this can be improved.

Yeah, I'm roughly familiar with it and I still made the same mistake too, so definitely lets comment about exactly what `Clifford` represents in its documentation.

Resolving patch:
diff --git a/qiskit/quantum_info/operators/symplectic/clifford.py b/qiskit/quantum_info/operators/symplectic/clifford.py
--- a/qiskit/quantum_info/operators/symplectic/clifford.py
+++ b/qiskit/quantum_info/operators/symplectic/clifford.py
@@ -38,7 +38,23 @@
 
 
 class Clifford(BaseOperator, AdjointMixin, Operation):
-    """An N-qubit unitary operator from the Clifford group.
+    r"""
+    An N-qubit unitary operator from the Clifford group.
+
+    An N-qubit Clifford operator takes Paulis to Paulis via conjugation
+    (up to a global phase). More precisely, the Clifford group :math:`\mathcal{C}_N`
+    is defined as
+
+     .. math::
+
+        \mathcal{C}_N = \{ U \in U(2^N) | U \mathcal{P}_N U^{\dagger} = \mathcal{P}_N \} / U(1)
+
+     where :math:`\mathcal{P}_N` is the Pauli group on :math:`N` qubits
+     that is generated by single-qubit Pauli operators,
+     and :math:`U` is a unitary operator in the unitary group
+     :math:`U(2^N)` representing operations on :math:`N` qubits.
+     :math:`\mathcal{C}_N` is the quotient group by the subgroup of
+     scalar unitary matrices :math:`U(1)`.
 
     **Representation**
 
@@ -92,7 +108,7 @@ class Clifford(BaseOperator, AdjointMixin, Operation):
     :class:`~qiskit.circuit.library.SGate`, :class:`~qiskit.circuit.library.SdgGate`,
     :class:`~qiskit.circuit.library.SXGate`, :class:`~qiskit.circuit.library.SXdgGate`,
     :class:`~qiskit.circuit.library.CXGate`, :class:`~qiskit.circuit.library.CZGate`,
-    :class:`~qiskit.circuit.library.CYGate`, :class:`~qiskit.circuit.library.DXGate`,
+    :class:`~qiskit.circuit.library.CYGate`, :class:`~qiskit.circuit.library.DCXGate`,
     :class:`~qiskit.circuit.library.SwapGate`, :class:`~qiskit.circuit.library.iSwapGate`,
     :class:`~qiskit.circuit.library.ECRGate`, :class:`~qiskit.circuit.library.LinearFunction`,
     :class:`~qiskit.circuit.library.PermutationGate`.


Test patch: