# QIDE JSON Circuit Definition

A QIDE JSON document defines a quantum computing circuit - any circuit diagram can be represented in QIDE JSON. The document consists of a top level set of properties that describe the quantum circuit (i.e. the qubit count) along with an array of gate objects. Here's a simple example of a Bell state circuit with two qubits:

```
{
"qubit_count": 2,
"gates": [
{
"gate_type": "H",
"target_qubits": [ 0 ]
},
{
"gate_type": "CNOT",
"control_qubits": [ 0 ],
"target_qubits": [ 1 ]
},
{
"gate_type": "M",
"target_qubits": [ 0, 1 ]
}
]
}
```

## Top Level Properties

`qubit_count`

: (Number) The number of qubits in the circuit.`ignore_danger`

: (Boolean) If the`qubit_count`

is greater than the warning default (currently 16), then this flag must be set to`true`

in order for the circuit to be run. State vectors grow exponentially based on the`qubit_count`

therefore it is easy to use up all memory simply by setting the number of qubits too large.`gates`

: (Array) The list of Gates in the circuit.`use_2_bit`

: (Boolean) Only used for Bloch diagrams as it provides qubit state values prior to being entangled.`parameters`

: (Object) User defined properties that can be used in rvalue expressions (the`rvalue_expr`

property of a gate object). For example:`{ "qubit_count": 2, "parameters": { "param1": 1.14159 }, "gates": [ { "gate_type": "R1", "target_qubits": [ 1 ], "rvalue_expr": "1.0 * param1 / 2.0", } ] }`

## Gate Object Properties

The following properties define the basics of a gate - the type and any control or target qubits.

`gate_type`

: (String) One of any of the documented gate types such as standard gates.`target_qubits`

: (Array) List of qubits to which the gate is applied.`control_qubits`

: (Array) List of qubits that act as the controlling qubits. Note that only a single qubit can be specified as a`target_qubit`

when control qubits are specified.

### R-value Options

The following properties are used in gates that require and r-value.

`rvalue`

: (Number) A radian value used in`R`

r-value gates. For example:`{ "gate_type": "R1", "target_qubits": [ 1 ], "rvalue": 3.14 }`

`rvalue_dyadic_denom`

: (Number) Used in conjunction with`rvalue`

, this sets the r-value to the computation (`rvalue`

* pi / 2 ^`rvalue_dyadic_denom`

)`rvalue_expr`

: (String) A mathematical expression that defines the r-value and can use parameters or built-in constants such as`pi`

. These expressions are implemented using the meval Rust crate and its documentation can be referred to for more information.`{ "gate_type": "Rx", "target_qubits": [ 1 ], "rvalue_expr": "pi / 2.0", }`

### Advanced Properties

`adjoint`

: (Boolean) If`true`

then the adjoint (conjugated transpose) of the gate matrix is applied. This is used in "undo-ing" prior gates used to potentially measure a qubit in a different basis, and are set automatically in conjugate composite gates.`rand_source_type`

: (String) Used in measurement gates to determine the source of the random numbers used to collapse a qubit's state. If set to`RandRng`

, a software random number generator is used. If set to`RandomSeed`

the RDS Random Seed service is used.`within_gates`

,`apply_gates`

: (Array) Both arrays contain a list of gate objects and are used in composite gates.

### Informational Properties

The following gates are used to document a circuit within the json document. They are not used in any calculations and may be set to whatever the designer wishes.

`gate_name`

: (String) Can be used to name a gate.`comment`

: (String) Can be used to describe or document a gate or block.