prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  inconsistency between CU1 and CU3 gate definitions
  <!-- ⚠️ If you do not respect this template, your issue will be closed -->
  <!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->
  
  ### What is the expected enhancement?
  
  This is not a bug or enhancement request as such, but seems like an internal inconsistency in Qiskit's gate definitions.
  In [the gate definitions](https://github.com/Qiskit/qiskit-tutorials/blob/master/qiskit/terra/summary_of_quantum_operations.ipynb), U1 is defined as [1,0,0,e^(iλ)], while an Rz is a [e^(-iλ/2),0,0,e^(iλ/2)].
  
  U3 is defined in the docs similarly to U1 - ie. a U3 is a U1*Ry*U1. Therefore, a U3(0,0,a) = U1(a). However, CU3 is defined in the docs in such a way that CU3(0,0,a) != CU1(a). CU3 is instead defined using the Rz definition, rather than the U1.
  
  So: 
  U3(0,0,a) = U1(a)
  CU3(0,0,a) != CU1(a)
  
  This is a confusing set of definitions. I assume that these definitions were a conscious decision, and that you are aware of the inconsistency, but I don't understand why?
  I hope this hasn't been asked already - I couldn't find a duplicate.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `qiskit/extensions/standard/cu3.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 # This code is part of Qiskit.
  4 #
  5 # (C) Copyright IBM 2017.
  6 #
  7 # This code is licensed under the Apache License, Version 2.0. You may
  8 # obtain a copy of this license in the LICENSE.txt file in the root directory
  9 # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
  10 #
  11 # Any modifications or derivative works of this code must retain this
  12 # copyright notice, and modified files need to carry a notice indicating
  13 # that they have been altered from the originals.
  14 
  15 """
  16 controlled-u3 gate.
  17 """
  18 from qiskit.circuit import Gate
  19 from qiskit.circuit import QuantumCircuit
  20 from qiskit.circuit import QuantumRegister
  21 from qiskit.extensions.standard.u1 import U1Gate
  22 from qiskit.extensions.standard.u3 import U3Gate
  23 from qiskit.extensions.standard.cx import CnotGate
  24 
  25 
  26 class Cu3Gate(Gate):
  27     """controlled-u3 gate."""
  28 
  29     def __init__(self, theta, phi, lam):
  30         """Create new cu3 gate."""
  31         super().__init__("cu3", 2, [theta, phi, lam])
  32 
  33     def _define(self):
  34         """
  35         gate cu3(theta,phi,lambda) c, t
  36         { u1((lambda-phi)/2) t; cx c,t;
  37           u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;
  38           u3(theta/2,phi,0) t;
  39         }
  40         """
  41         definition = []
  42         q = QuantumRegister(2, "q")
  43         rule = [
  44             (U1Gate((self.params[2] - self.params[1]) / 2), [q[1]], []),
  45             (CnotGate(), [q[0], q[1]], []),
  46             (U3Gate(-self.params[0] / 2, 0, -(self.params[1] + self.params[2]) / 2), [q[1]], []),
  47             (CnotGate(), [q[0], q[1]], []),
  48             (U3Gate(self.params[0] / 2, self.params[1], 0), [q[1]], [])
  49         ]
  50         for inst in rule:
  51             definition.append(inst)
  52         self.definition = definition
  53 
  54     def inverse(self):
  55         """Invert this gate."""
  56         return Cu3Gate(-self.params[0], -self.params[2], -self.params[1])
  57 
  58 
  59 def cu3(self, theta, phi, lam, ctl, tgt):
  60     """Apply cu3 from ctl to tgt with angle theta, phi, lam."""
  61     return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], [])
  62 
  63 
  64 QuantumCircuit.cu3 = cu3
  65
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/qiskit/extensions/standard/cu3.py b/qiskit/extensions/standard/cu3.py
  --- a/qiskit/extensions/standard/cu3.py
  +++ b/qiskit/extensions/standard/cu3.py
  @@ -33,7 +33,7 @@
       def _define(self):
           """
           gate cu3(theta,phi,lambda) c, t
  -        { u1((lambda-phi)/2) t; cx c,t;
  +        { u1((lambda+phi)/2) c; u1((lambda-phi)/2) t; cx c,t;
             u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;
             u3(theta/2,phi,0) t;
           }
  @@ -41,6 +41,7 @@
           definition = []
           q = QuantumRegister(2, "q")
           rule = [
  +            (U1Gate((self.params[2] + self.params[1]) / 2), [q[0]], []),
               (U1Gate((self.params[2] - self.params[1]) / 2), [q[1]], []),
               (CnotGate(), [q[0], q[1]], []),
               (U3Gate(-self.params[0] / 2, 0, -(self.params[1] + self.params[2]) / 2), [q[1]], []),
  
verification_info: {"golden_diff": "diff --git a/qiskit/extensions/standard/cu3.py b/qiskit/extensions/standard/cu3.py\n--- a/qiskit/extensions/standard/cu3.py\n+++ b/qiskit/extensions/standard/cu3.py\n@@ -33,7 +33,7 @@\n     def _define(self):\n         \"\"\"\n         gate cu3(theta,phi,lambda) c, t\n-        { u1((lambda-phi)/2) t; cx c,t;\n+        { u1((lambda+phi)/2) c; u1((lambda-phi)/2) t; cx c,t;\n           u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;\n           u3(theta/2,phi,0) t;\n         }\n@@ -41,6 +41,7 @@\n         definition = []\n         q = QuantumRegister(2, \"q\")\n         rule = [\n+            (U1Gate((self.params[2] + self.params[1]) / 2), [q[0]], []),\n             (U1Gate((self.params[2] - self.params[1]) / 2), [q[1]], []),\n             (CnotGate(), [q[0], q[1]], []),\n             (U3Gate(-self.params[0] / 2, 0, -(self.params[1] + self.params[2]) / 2), [q[1]], []),\n", "issue": "inconsistency between CU1 and CU3 gate definitions\n<!-- \u26a0\ufe0f If you do not respect this template, your issue will be closed -->\r\n<!-- \u26a0\ufe0f Make sure to browse the opened and closed issues to confirm this idea does not exist. -->\r\n\r\n### What is the expected enhancement?\r\n\r\nThis is not a bug or enhancement request as such, but seems like an internal inconsistency in Qiskit's gate definitions.\r\nIn [the gate definitions](https://github.com/Qiskit/qiskit-tutorials/blob/master/qiskit/terra/summary_of_quantum_operations.ipynb), U1 is defined as [1,0,0,e^(i\u03bb)], while an Rz is a [e^(-i\u03bb/2),0,0,e^(i\u03bb/2)].\r\n\r\nU3 is defined in the docs similarly to U1 - ie. a U3 is a U1*Ry*U1. Therefore, a U3(0,0,a) = U1(a). However, CU3 is defined in the docs in such a way that CU3(0,0,a) != CU1(a). CU3 is instead defined using the Rz definition, rather than the U1.\r\n\r\nSo: \r\nU3(0,0,a) = U1(a)\r\nCU3(0,0,a) != CU1(a)\r\n\r\nThis is a confusing set of definitions. I assume that these definitions were a conscious decision, and that you are aware of the inconsistency, but I don't understand why?\r\nI hope this hasn't been asked already - I couldn't find a duplicate.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n\"\"\"\ncontrolled-u3 gate.\n\"\"\"\nfrom qiskit.circuit import Gate\nfrom qiskit.circuit import QuantumCircuit\nfrom qiskit.circuit import QuantumRegister\nfrom qiskit.extensions.standard.u1 import U1Gate\nfrom qiskit.extensions.standard.u3 import U3Gate\nfrom qiskit.extensions.standard.cx import CnotGate\n\n\nclass Cu3Gate(Gate):\n    \"\"\"controlled-u3 gate.\"\"\"\n\n    def __init__(self, theta, phi, lam):\n        \"\"\"Create new cu3 gate.\"\"\"\n        super().__init__(\"cu3\", 2, [theta, phi, lam])\n\n    def _define(self):\n        \"\"\"\n        gate cu3(theta,phi,lambda) c, t\n        { u1((lambda-phi)/2) t; cx c,t;\n          u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;\n          u3(theta/2,phi,0) t;\n        }\n        \"\"\"\n        definition = []\n        q = QuantumRegister(2, \"q\")\n        rule = [\n            (U1Gate((self.params[2] - self.params[1]) / 2), [q[1]], []),\n            (CnotGate(), [q[0], q[1]], []),\n            (U3Gate(-self.params[0] / 2, 0, -(self.params[1] + self.params[2]) / 2), [q[1]], []),\n            (CnotGate(), [q[0], q[1]], []),\n            (U3Gate(self.params[0] / 2, self.params[1], 0), [q[1]], [])\n        ]\n        for inst in rule:\n            definition.append(inst)\n        self.definition = definition\n\n    def inverse(self):\n        \"\"\"Invert this gate.\"\"\"\n        return Cu3Gate(-self.params[0], -self.params[2], -self.params[1])\n\n\ndef cu3(self, theta, phi, lam, ctl, tgt):\n    \"\"\"Apply cu3 from ctl to tgt with angle theta, phi, lam.\"\"\"\n    return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], [])\n\n\nQuantumCircuit.cu3 = cu3\n", "path": "qiskit/extensions/standard/cu3.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n\"\"\"\ncontrolled-u3 gate.\n\"\"\"\nfrom qiskit.circuit import Gate\nfrom qiskit.circuit import QuantumCircuit\nfrom qiskit.circuit import QuantumRegister\nfrom qiskit.extensions.standard.u1 import U1Gate\nfrom qiskit.extensions.standard.u3 import U3Gate\nfrom qiskit.extensions.standard.cx import CnotGate\n\n\nclass Cu3Gate(Gate):\n    \"\"\"controlled-u3 gate.\"\"\"\n\n    def __init__(self, theta, phi, lam):\n        \"\"\"Create new cu3 gate.\"\"\"\n        super().__init__(\"cu3\", 2, [theta, phi, lam])\n\n    def _define(self):\n        \"\"\"\n        gate cu3(theta,phi,lambda) c, t\n        { u1((lambda+phi)/2) c; u1((lambda-phi)/2) t; cx c,t;\n          u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;\n          u3(theta/2,phi,0) t;\n        }\n        \"\"\"\n        definition = []\n        q = QuantumRegister(2, \"q\")\n        rule = [\n            (U1Gate((self.params[2] + self.params[1]) / 2), [q[0]], []),\n            (U1Gate((self.params[2] - self.params[1]) / 2), [q[1]], []),\n            (CnotGate(), [q[0], q[1]], []),\n            (U3Gate(-self.params[0] / 2, 0, -(self.params[1] + self.params[2]) / 2), [q[1]], []),\n            (CnotGate(), [q[0], q[1]], []),\n            (U3Gate(self.params[0] / 2, self.params[1], 0), [q[1]], [])\n        ]\n        for inst in rule:\n            definition.append(inst)\n        self.definition = definition\n\n    def inverse(self):\n        \"\"\"Invert this gate.\"\"\"\n        return Cu3Gate(-self.params[0], -self.params[2], -self.params[1])\n\n\ndef cu3(self, theta, phi, lam, ctl, tgt):\n    \"\"\"Apply cu3 from ctl to tgt with angle theta, phi, lam.\"\"\"\n    return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], [])\n\n\nQuantumCircuit.cu3 = cu3\n", "path": "qiskit/extensions/standard/cu3.py"}]}