Repository: Qiskit/qiskit

Issue:
bottom.QuantumCircuit.tensor(top. inplace=True) doubles ancillas on modified bottom
### Environment

- **Qiskit Terra version**:  0.19.1
- **Python version**: 3.8.5
- **Operating system**: Win11x64


### What is happening?

Given QuantumCircuits "bottom" and "top",
if "bottom" contains ancillas AND if performing bottom.tensor(top, inplace=True)
then the modified "bottom" QuantumCircuit will have the ancilla entries doubled (with same name, so they are not visible in draw) in bottom.ancillas
This does NOT happen if inplace=False


### How can we reproduce the issue?
```python
bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)

c = QuantumCircuit(QuantumRegister(2), ClassicalRegister(2), AncillaRegister(2))
print(c.ancillas)

# output: 
# [AncillaQubit(AncillaRegister(2, 'a8'), 0),
# AncillaQubit(AncillaRegister(2, 'a8'), 1)]

c.tensor(bell, inplace=True)
print(c.ancillas)

# output: 
# [AncillaQubit(AncillaRegister(2, 'a8'), 0),
# AncillaQubit(AncillaRegister(2, 'a8'), 1),
# AncillaQubit(AncillaRegister(2, 'a8'), 0),
# AncillaQubit(AncillaRegister(2, 'a8'), 1)]
```

### What should happen?

Only the relevant ancillas should stay.

### Any suggestions?

 a related question:
QuantumCircuit.qubits shows all qubits, including ancilla. Is that by design?


Discussion:

Resolving patch:
diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py
--- a/qiskit/circuit/quantumcircuit.py
+++ b/qiskit/circuit/quantumcircuit.py
@@ -1352,7 +1352,9 @@ def add_register(self, *regs: Union[Register, int, Sequence[Bit]]) -> None:
                 raise CircuitError('register name "%s" already exists' % register.name)
 
             if isinstance(register, AncillaRegister):
-                self._ancillas.extend(register)
+                for bit in register:
+                    if bit not in self._qubit_indices:
+                        self._ancillas.append(bit)
 
             if isinstance(register, QuantumRegister):
                 self.qregs.append(register)


Test patch:
diff --git a/test/python/circuit/test_circuit_operations.py b/test/python/circuit/test_circuit_operations.py
--- a/test/python/circuit/test_circuit_operations.py
+++ b/test/python/circuit/test_circuit_operations.py
@@ -22,6 +22,7 @@
 from qiskit.circuit.classicalregister import Clbit
 from qiskit.circuit.exceptions import CircuitError
 from qiskit.circuit.quantumcircuit import BitLocations
+from qiskit.circuit.quantumregister import AncillaQubit, AncillaRegister, Qubit
 from qiskit.test import QiskitTestCase
 from qiskit.circuit.library.standard_gates import SGate
 from qiskit.quantum_info import Operator
@@ -948,6 +949,41 @@ def test_compare_a_circuit_with_none(self):
 
         self.assertFalse(qc1 == qc2)
 
+    def test_overlapped_add_bits_and_add_register(self):
+        """Test add registers whose bits have already been added by add_bits."""
+        qc = QuantumCircuit()
+        for bit_type, reg_type in (
+            [Qubit, QuantumRegister],
+            [Clbit, ClassicalRegister],
+            [AncillaQubit, AncillaRegister],
+        ):
+            bits = [bit_type() for _ in range(10)]
+            reg = reg_type(bits=bits)
+            qc.add_bits(bits)
+            qc.add_register(reg)
+
+        self.assertEqual(qc.num_qubits, 20)
+        self.assertEqual(qc.num_clbits, 10)
+        self.assertEqual(qc.num_ancillas, 10)
+
+    def test_overlapped_add_register_and_add_register(self):
+        """Test add registers whose bits have already been added by add_register."""
+        qc = QuantumCircuit()
+        for bit_type, reg_type in (
+            [Qubit, QuantumRegister],
+            [Clbit, ClassicalRegister],
+            [AncillaQubit, AncillaRegister],
+        ):
+            bits = [bit_type() for _ in range(10)]
+            reg1 = reg_type(bits=bits)
+            reg2 = reg_type(bits=bits)
+            qc.add_register(reg1)
+            qc.add_register(reg2)
+
+        self.assertEqual(qc.num_qubits, 20)
+        self.assertEqual(qc.num_clbits, 10)
+        self.assertEqual(qc.num_ancillas, 10)
+
     def test_deprecated_measure_function(self):
         """Test that the deprecated version of the loose 'measure' function works correctly."""
         from qiskit.circuit.measure import measure