Skip to content

Identity gate #1292

@viathor

Description

@viathor

Identity is a unitary. We probably want an explicit representation for it in cirq.

Rationale:

  1. Many expressions evaluate to the identity exactly (e.g. composition of H with H) or up to global phase (e.g. composition of X, Y and Z). Code that detects and optimizes such expressions may need to return identity explicitly.
  2. Identity is a convenient initializer for reduce-like operations on gates.
  3. It's directly useful in expressions for quantum channels (see e.g. Powering vector of pauli components #1037).
  4. It's one of the basis elements in the Pauli basis of the space of hermitian operators. Having explicit representation for it simplifies code for Representing Hamiltonians #491.
  5. There are currently multiple hacky ways of specifying the identity (e.g. cirq.Y**0). If an explicit, elegant way (e.g. cirq.I or cirq.Identity) is provided, the users are more likely to eschew the hacky expressions.

Some things to consider in implementation:

  1. It should be removed by all decompositions.
  2. It should compare equal to expressions such as cirq.Z**0 or cirq.Rx(rads=0).
  3. Do we need a gate for changing global phase? If so, that gate should probably be implemented simply as a phase factor for identity.
  4. Circuits such as
0: ───X^0───

1: ───Y─────

should display as

0: ─────────

1: ───Y─────

or

1: ───Y───

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions