# from the theory of proveit.physics.quantum¶

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
# import Expression classes needed to build the expression
from proveit import ExprArray, U, x, y
from proveit.linear_algebra import MatrixProd, SU
from proveit.logic import Equals, Forall, Iff
from proveit.numbers import two
from proveit.physics.quantum import Gate, Input, Output, QubitSpace
from proveit.physics.quantum.circuit import Circuit

In [2]:
# build up the expression from sub-expressions
expr = Forall([U], Forall([x, y], Iff(Circuit(ExprArray([Input(x), Gate(U), Output(y)])), Equals(y, MatrixProd(U, x))), domain = QubitSpace), domain = SU(two))

Out[2]:
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")

Passed sanity check: expr matches stored_expr

In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(expr.latex())

\forall_{U \in SU(2)}~\left[\forall_{x, y \in \mathbb{C}^{2}}~\left(\hspace{2em} \Qcircuit@C=1em @R=.7em{
& \lstick{x} & \gate{U} & \rstick{y} \qw
} \hspace{2em} \Leftrightarrow \left(y = \left(U \thinspace x\right)\right)\right)\right]

In [5]:
expr.style_options()

Out[5]:
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
expr.expr_info()

Out[6]:
core typesub-expressionsexpression
0Operationoperator: 6
operand: 2
1ExprTuple2
2Lambdaparameter: 52
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 30
operands: 8
6Literal
7ExprTuple9
8ExprTuple52, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operand: 44
11ExprTuple51, 53
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple44
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 25
operand: 32
22Operationoperator: 27
operands: 28
23Operationoperator: 30
operands: 29
24Operationoperator: 30
operands: 31
25Literal
26ExprTuple32None
27Literal
28ExprTuple53, 33
29ExprTuple51, 34
30Literal
31ExprTuple53, 34
32ExprTuple35None
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple40, 41, 42
36Literal
37ExprTuple52, 51
38Literal
39ExprTuple43, 44
40Operationoperator: 45
operand: 51
41Operationoperator: 47
operand: 52
42Operationoperator: 49
operand: 53
43Literal
44Literal
45Literal
46ExprTuple51
47Literal
48ExprTuple52
49Literal
50ExprTuple53
51Variable
52Variable
53Variable