# Gates and Instructions¶

A `Program` is effectively a list of gates and instructions which can be created using the function documented in this section:

```>>> p = Program()
>>> p += H(qubit=0)
>>> p += RY(angle=pi/3, qubit=1)
>>> p += CNOT(0, 1)
...
```

## Native gates for Rigetti QPUs¶

Physical quantum processors can enact a subset of all named gates. Luckily, a small set of gates is universal for quantum computation, so all named gates can be enacted by suitable combinations of physically realizable gates. Rigetti’s superconducting quantum processors can perform `RX()` with `angle=+-pi/2` or `angle=+-pi`, `RZ()` with an arbitrary angle, `CZ()` and parametric `XY()` interactions between neighboring qubits. Rigetti QPUs can natively measure in the computational (Z) basis.

 `RX`(angle, qubit) Produces the RX gate. `RZ`(angle, qubit) Produces the RZ gate. `CZ`(control, target) Produces a controlled-Z gate. `XY`(angle, q1, q2) Produces a parameterized ISWAP gate. `MEASURE`(qubit, classical_reg) Produce a MEASURE instruction.

## Quilt instructions¶

Quilt extends the above “native” operations with several more.

 `PULSE`(frame, waveform[, nonblocking]) Produce a PULSE instruction. `SET_FREQUENCY`(frame, freq) Produce a SET-FREQUENCY instruction. `SHIFT_FREQUENCY`(frame, freq) Produce a SHIFT-FREQUENCY instruction. `SET_PHASE`(frame, phase) Produce a SET-PHASE instruction. `SHIFT_PHASE`(frame, phase) Produce a SHIFT-PHASE instruction. `SWAP_PHASE`(frameA, frameB) Produce a SWAP-PHASE instruction. `SET_SCALE`(frame, scale) Produce a SET-SCALE instruction. `CAPTURE`(frame, kernel, memory_region[, …]) Produce a CAPTURE instruction. `RAW_CAPTURE`(frame, duration, memory_region) Produce a RAW-CAPTURE instruction. `DELAY`(*args) Produce a DELAY instruction. `FENCE`(*qubits) Produce a FENCE instruction.

## All gates and instructions¶

In general, you will write a quantum program using the full suite of Quil gates and instructions and use the Quil compiler to compile programs into the target instruction set (ISA).

Furthermore, Quilt instructions may be executed natively, although are not fully supported by the Quil compiler or QVM.

Single-qubit gates

 `I`(qubit) Produces the I identity gate. `X`(qubit) Produces the X (“NOT”) gate. `Y`(qubit) Produces the Y gate. `Z`(qubit) Produces the Z gate. `H`(qubit) Produces the Hadamard gate. `S`(qubit) Produces the S gate. `T`(qubit) Produces the T gate. `RX`(angle, qubit) Produces the RX gate. `RY`(angle, qubit) Produces the RY gate. `RZ`(angle, qubit) Produces the RZ gate. `PHASE`(angle, qubit) Produces the PHASE gate.

Multi-qubit gates

 `CZ`(control, target) Produces a controlled-Z gate. `XY`(angle, q1, q2) Produces a parameterized ISWAP gate. `CNOT`(control, target) Produces a controlled-NOT (controlled-X) gate. `CCNOT`(control1, control2, target) Produces a doubly-controlled NOT gate. `CPHASE00`(angle, control, target) Produces a controlled-phase gate that phases the `|00>` state. `CPHASE01`(angle, control, target) Produces a controlled-phase gate that phases the `|01>` state. `CPHASE10`(angle, control, target) Produces a controlled-phase gate that phases the `|10>` state. `CPHASE`(angle, control, target) Produces a controlled-phase instruction. `SWAP`(q1, q2) Produces a SWAP gate which swaps the state of two qubits. `CSWAP`(control, target_1, target_2) Produces a controlled-SWAP gate. This gate conditionally swaps the state of two qubits::. `ISWAP`(q1, q2) Produces an ISWAP gate. `PSWAP`(angle, q1, q2) Produces a parameterized SWAP gate.

Quilt instructions

 `PULSE`(frame, waveform[, nonblocking]) Produce a PULSE instruction. `SET_FREQUENCY`(frame, freq) Produce a SET-FREQUENCY instruction. `SHIFT_FREQUENCY`(frame, freq) Produce a SHIFT-FREQUENCY instruction. `SET_PHASE`(frame, phase) Produce a SET-PHASE instruction. `SHIFT_PHASE`(frame, phase) Produce a SHIFT-PHASE instruction. `SWAP_PHASE`(frameA, frameB) Produce a SWAP-PHASE instruction. `SET_SCALE`(frame, scale) Produce a SET-SCALE instruction. `CAPTURE`(frame, kernel, memory_region[, …]) Produce a CAPTURE instruction. `RAW_CAPTURE`(frame, duration, memory_region) Produce a RAW-CAPTURE instruction. `DELAY`(*args) Produce a DELAY instruction. `FENCE`(*qubits) Produce a FENCE instruction.

Other classical instructions

 `WAIT` This instruction tells the quantum computation to halt. `RESET`([qubit_index]) Reset all qubits or just one specific qubit. `NOP` This instruction applies no operation at that timestep. `HALT` This instruction ends the program. `MEASURE`(qubit, classical_reg) Produce a MEASURE instruction. `NEG`(classical_reg) Produce a NEG instruction. `NOT`(classical_reg) Produce a NOT instruction. `AND`(classical_reg1, classical_reg2) Produce an AND instruction. `OR`(classical_reg1, classical_reg2) Produce an OR instruction. `IOR`(classical_reg1, classical_reg2) Produce an inclusive OR instruction. `XOR`(classical_reg1, classical_reg2) Produce an exclusive OR instruction. `MOVE`(classical_reg1, classical_reg2) Produce a MOVE instruction. `EXCHANGE`(classical_reg1, classical_reg2) Produce an EXCHANGE instruction. `LOAD`(target_reg, region_name, offset_reg) Produce a LOAD instruction. `STORE`(region_name, offset_reg, source) Produce a STORE instruction. `CONVERT`(classical_reg1, classical_reg2) Produce a CONVERT instruction. `ADD`(classical_reg, right) Produce an ADD instruction. `SUB`(classical_reg, right) Produce a SUB instruction. `MUL`(classical_reg, right) Produce a MUL instruction. `DIV`(classical_reg, right) Produce an DIV instruction. `EQ`(classical_reg1, classical_reg2, …) Produce an EQ instruction. `LT`(classical_reg1, classical_reg2, …) Produce an LT instruction. `LE`(classical_reg1, classical_reg2, …) Produce an LE instruction. `GT`(classical_reg1, classical_reg2, …) Produce an GT instruction. `GE`(classical_reg1, classical_reg2, …) Produce an GE instruction.

Collections

 `QUANTUM_GATES` Dictionary of quantum gate functions keyed by gate names. `QUILT_INSTRUCTIONS` Dictionary of Quil-T AST construction functions keyed by instruction name. `STANDARD_INSTRUCTIONS` Dictionary of standard instruction functions keyed by instruction names.