logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.circuits

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.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import ExprTuple
from proveit.physics.quantum.circuits import unitary_gate_op
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(unitary_gate_op)
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(stored_expr.latex())
\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{U} & \qout{U \thinspace \lvert \psi \rangle}
} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Operationoperator: 2
operands: 3
2Literal
3ExprTuple4, 5, 6
4ExprTuple7
5ExprTuple8
6ExprTuple9
7ExprRangelambda_map: 10
start_index: 35
end_index: 36
8ExprRangelambda_map: 11
start_index: 35
end_index: 36
9ExprRangelambda_map: 12
start_index: 35
end_index: 36
10Lambdaparameter: 34
body: 13
11Lambdaparameter: 34
body: 14
12Lambdaparameter: 34
body: 16
13Operationoperator: 19
operands: 17
14Operationoperator: 19
operands: 18
15ExprTuple34
16Operationoperator: 19
operands: 20
17NamedExprselement: 21
targets: 24
18NamedExprselement: 22
targets: 24
19Literal
20NamedExprselement: 23
targets: 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operands: 30
24Operationoperator: 31
operands: 32
25Literal
26NamedExprsstate: 40
part: 34
27Literal
28NamedExprsoperation: 39
part: 34
29Literal
30NamedExprsstate: 33
part: 34
31Literal
32ExprTuple35, 36
33Operationoperator: 37
operands: 38
34Variable
35Literal
36Variable
37Literal
38ExprTuple39, 40
39Variable
40Variable