# Time Crystal Circuit Generation

This notebook covers how Many Body Local Discrete Time Crystal circuit lists are created, from the paper: Observation of Time-Crystalline Eigenstate Order on a Quantum Processor (Nature).

Quantum computers and gate-based quantum circuits turn out to be well suited for crafting systems that exhibit time-crystalline behavior. Behavior is crystalline with respect to time if it has some consistent and stable pattern over time. This system's pattern must be resilient against perturbation in the same way that a space-crystalline object, like a diamond, maintains its structure (is still a diamond) if moved or heated.

The quantum computer supplies a system of many qubits, locally connected to each other in a chain. A many-body local (MBL) system like this is critical for the existence of a time crystal. Without an MBL system, it is expected that the system's state would decay into a maximum entropy state that is incompatible with the goal of stable and consistent time structure.

The time-crystalline behavior that the discrete time crystal (DTC) circuits demonstrate is perhaps the simplest kind of time-structured behavior, oscillation. Each circuit is built with some number of identical $$U$$-cycles. Time is represented by a circuit list where each circuit is ordered with increasingly many $$U$$-cycles; each cycle is considered a discrete time step. The eventual effect of these $$U$$-cycles is consistent oscillations of each qubits' polarizations. The experiments performed demonstrate that this time-crystalline oscillation behavior is stable in spite of different initial states and introduced random potentials.

## Setup

!pip install cirq --quiet
try:
import recirq
except ImportError:
!pip install --quiet git+https://github.com/quantumlib/ReCirq

import cirq
import recirq.time_crystals as time_crystals


## Circuit Construction

Each DTC circuit is created with symbolic parameters. Parameter values are supplied near run/simulation time with a cirq.ParamResolver, which means the circuit list needs to be generated only once for potentially many different experimental parameter configurations.

The code below uses an IPython-specific utility to inspect the code of the key function that creates the symbolic circuit list, recirq.time_crystals.symbolic_dtc_circuit_list().

import inspect
from IPython.display import Code

Code(inspect.getsource(time_crystals.symbolic_dtc_circuit_list), language="python")


The construction of each circuit is surprisingly succinct.

The circuit expects the quantum computer to be in the all-zeros state, and starts with a sequence of cirq.Y gates conditioned on the provided initial state parameter, after initializing the necessary symbolic variables.

Each $$U$$-cycle consists of three moments. First, a moment of cirq.PhasedXZGates, with one for each qubit. Each cirq.PhasedXZGate takes the control parameter g as its X-exponent, and the random potentials necessary for many-body localization provided by local_fields for its Y-exponent.

The second and third moments together both cause the oscillation behavior and compensate for the first disorder moment. The qubits are connected in a chain, and each qubit pair connection in that chain is coupled with a cirq.PhasedFSimGate that uses the parameters [theta, zetas, chi, gamma, phi]. To keep gates from overlapping on the same qubit, this chain of gates is split into the second and third moments, such that no two gates share a qubit within each moment.

Finally, symbolic_dtc_circuit_list() builds and returns a list of circuits with $$0,1,2,..., cycles$$ many $$U$$-cycles in them.

qubits = [cirq.GridQubit(0, i) for i in range(4)]
circuit_list = time_crystals.symbolic_dtc_circuit_list(qubits, 2)
for circuit in circuit_list:
print("\ncircuit of length " + str(len(circuit)) + "\n")
print(circuit)

circuit of length 1

(0, 0): ───Y^initial_state_0───

(0, 1): ───Y^initial_state_1───

(0, 2): ───Y^initial_state_2───

(0, 3): ───Y^initial_state_3───

circuit of length 4

(0, 0): ───Y^initial_state_0───PhXZ(a=0,x=g,z=local_field_0)────────────────────────────────────────────────────PhFSim(theta_0, zeta_0, chi_0, gamma_0, phi_0)───
│
(0, 1): ───Y^initial_state_1───PhXZ(a=0,x=g,z=local_field_1)───PhFSim(theta_1, zeta_1, chi_1, gamma_1, phi_1)───PhFSim(theta_0, zeta_0, chi_0, gamma_0, phi_0)───
│
(0, 2): ───Y^initial_state_2───PhXZ(a=0,x=g,z=local_field_2)───PhFSim(theta_1, zeta_1, chi_1, gamma_1, phi_1)───PhFSim(theta_2, zeta_2, chi_2, gamma_2, phi_2)───
│
(0, 3): ───Y^initial_state_3───PhXZ(a=0,x=g,z=local_field_3)────────────────────────────────────────────────────PhFSim(theta_2, zeta_2, chi_2, gamma_2, phi_2)───

circuit of length 7

(0, 0): ───Y^initial_state_0───PhXZ(a=0,x=g,z=local_field_0)────────────────────────────────────────────────────PhFSim(theta_0, zeta_0, chi_0, gamma_0, phi_0)───PhXZ(a=0,x=g,z=local_field_0)────────────────────────────────────────────────────PhFSim(theta_0, zeta_0, chi_0, gamma_0, phi_0)───
│                                                                                                                                 │
(0, 1): ───Y^initial_state_1───PhXZ(a=0,x=g,z=local_field_1)───PhFSim(theta_1, zeta_1, chi_1, gamma_1, phi_1)───PhFSim(theta_0, zeta_0, chi_0, gamma_0, phi_0)───PhXZ(a=0,x=g,z=local_field_1)───PhFSim(theta_1, zeta_1, chi_1, gamma_1, phi_1)───PhFSim(theta_0, zeta_0, chi_0, gamma_0, phi_0)───
│                                                                                                                                 │
(0, 2): ───Y^initial_state_2───PhXZ(a=0,x=g,z=local_field_2)───PhFSim(theta_1, zeta_1, chi_1, gamma_1, phi_1)───PhFSim(theta_2, zeta_2, chi_2, gamma_2, phi_2)───PhXZ(a=0,x=g,z=local_field_2)───PhFSim(theta_1, zeta_1, chi_1, gamma_1, phi_1)───PhFSim(theta_2, zeta_2, chi_2, gamma_2, phi_2)───
│                                                                                                                                 │
(0, 3): ───Y^initial_state_3───PhXZ(a=0,x=g,z=local_field_3)────────────────────────────────────────────────────PhFSim(theta_2, zeta_2, chi_2, gamma_2, phi_2)───PhXZ(a=0,x=g,z=local_field_3)────────────────────────────────────────────────────PhFSim(theta_2, zeta_2, chi_2, gamma_2, phi_2)───


After the initial line of cirq.Y gates, each consecutive circuit in the list has an additional cycle of cirq.PhasedXZGates, followed by the chain of cirq.PhasedFSimGates on alternating qubit pairs. Each cycle of three moments becomes one time step in the later analysis of stable oscillations over time.

The next step is to perform experiments to collect evidence of the time-crystalline behavior of the quantum state's polarizations. See the Time Crystal Data Collection notebook for the experiments, and the Time Crystal Data Analysis notebook for the graphed data and results.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]