Function Repository Resource:

ZXDiagramToQuantumDiscreteState

Source Notebook

Convert a ZX-diagram into a pure quantum discrete state

Contributed by: Jonathan Gorard

ResourceFunction["ZXDiagramToQuantumDiscreteState"][ZXDiagramObject[]]

converts the specified ZXDiagramObject into an equivalent (pure) QuantumDiscreteState.

Details

If ResourceFunction["ZXDiagramToQuantumDiscreteState"] succeeds in converting the specified ZXDiagramObject into a pure discrete quantum state, it will return a QuantumDiscreteState object.
ResourceFunction["ZXDiagramToQuantumDiscreteState"] works by converting each Z-spider generator in the specified ZXDiagramObject into a qubit of the general form {1,α}, and each X-spider generator in the specified ZXDiagramObject into a qubit of the general form , before taking a tensor product of all such qubits to yield the desired QuantumDiscreteState.
Since it is representing a (pure) QuantumDiscreteState, every generator/spider within the specified ZXDiagramObject should have an input arity of 0 and an output arity of 1.
In the resulting QuantumDiscreteState, the following properties are supported:
"Amplitudes"association <|b1amp1,b2amp2,|> of basis names and amplitudes
"Basis"which QuantumBasis the state is defined with respect to
"Picture"which quantum mechanical picture the state is defined with respect to
"BasisElements"list of basis elements bi
"StateVector"state vector {amp1,amp2,} (for pure states only)
"DensityMatrix"density matrix mat (for both pure and mxied states)
"VonNeumannEntropy"Von Neumann entropy (entanglement entropy) of the state
"Purity"purity of the quantum state, specified as a real number
"PureStateQ"whether the state is pure (purity equals 1)
"MixedStateQ"whether the state is mixed (purity is not equal to 1)
"Qudits"number of qudits (subsystems) within the state
"Dimensions"dimensionality of each qudit (subsystem)
"BlochSphericalCoordinates"spherical coordinates of the state on the Bloch sphere (qubits only)
"BlochCartesianCoordinates"Cartesian coordinates of the state on the Bloch sphere (qubits only)
"Properties"list of all property names
The default convention is to name Z-spiders as z1,z2,; X-spiders as x1,x2,; black diamonds as d1,d2,; outputs as o1,o2,; etc.

Examples

Basic Examples (2) 

Convert a single-spider ZX-diagram into a single-qubit pure discrete quantum state:

In[1]:=
diagram = ResourceFunction[
   "MakeZXDiagram"][{\[FormalCapitalZ][z, 0, 1, Pi], \[FormalCapitalW][z, o]}]
Out[1]=
In[2]:=
diagram["LabeledGraph"]
Out[2]=
In[3]:=
state = ResourceFunction["ZXDiagramToQuantumDiscreteState"][diagram]
Out[3]=
In[4]:=
state["Amplitudes"]
Out[4]=

Convert a different single-spider ZX-diagram into a single-qubit pure discrete quantum state:

In[5]:=
diagram2 = ResourceFunction[
   "MakeZXDiagram"][{\[FormalCapitalX][x, 0, 1, Pi/2], \[FormalCapitalW][x, o]}]
Out[5]=
In[6]:=
diagram2["LabeledGraph"]
Out[6]=
In[7]:=
state2 = ResourceFunction["ZXDiagramToQuantumDiscreteState"][diagram2]
Out[7]=
In[8]:=
state2["Amplitudes"]
Out[8]=

Convert a more complicated three-spider ZX-diagram into a three-qubit pure discrete quantum state:

In[9]:=
diagram = ResourceFunction[
    "MakeZXDiagram"][{\[FormalCapitalX][x1, 0, 1, Pi/2], \[FormalCapitalX][x2, 0, 1, Pi], \[FormalCapitalZ][z, 0, 1, 3 Pi/2], \[FormalCapitalW][x1, o1], \[FormalCapitalW][x2, o2], \[FormalCapitalW][z, o3]}];
diagram["LabeledGraph"]
Out[9]=
In[10]:=
state = ResourceFunction["ZXDiagramToQuantumDiscreteState"][diagram]
Out[10]=
In[11]:=
state["Amplitudes"]
Out[11]=

Convert a different four-spider ZX-diagram into a four-qubit pure discrete quantum state:

In[12]:=
diagram2 = ResourceFunction[
    "MakeZXDiagram"][{\[FormalCapitalZ][z1, 0, 1, Pi/6], \[FormalCapitalZ][z2, 0, 1, Pi/4], \[FormalCapitalZ][z3, 0, 1, 3 Pi/5], \[FormalCapitalX][x, 0, 1, Pi/3], \[FormalCapitalW][z1, o1], \[FormalCapitalW][z2, o2], \[FormalCapitalW][z3, o3], \[FormalCapitalW][x, o4]}];
diagram2["LabeledGraph"]
Out[12]=
In[13]:=
state = ResourceFunction["ZXDiagramToQuantumDiscreteState"][diagram2]
Out[13]=
In[14]:=
state["Amplitudes"]
Out[14]=

Publisher

Jonathan Gorard

Version History

  • 1.0.0 – 26 April 2021

Source Metadata

Related Resources

License Information