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.numbers import one
from proveit.physics.quantum.circuits import unitary_gate_op
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Prob(unitary_gate_op), one)
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(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{U} & \qout{U \thinspace \lvert \psi \rangle}
} \end{array}\right), 1\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 38
1Operationoperator: 2
operand: 4
2Literal
3ExprTuple4
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8, 9
7ExprTuple10
8ExprTuple11
9ExprTuple12
10ExprRangelambda_map: 13
start_index: 38
end_index: 39
11ExprRangelambda_map: 14
start_index: 38
end_index: 39
12ExprRangelambda_map: 15
start_index: 38
end_index: 39
13Lambdaparameter: 37
body: 16
14Lambdaparameter: 37
body: 17
15Lambdaparameter: 37
body: 19
16Operationoperator: 22
operands: 20
17Operationoperator: 22
operands: 21
18ExprTuple37
19Operationoperator: 22
operands: 23
20NamedExprselement: 24
targets: 27
21NamedExprselement: 25
targets: 27
22Literal
23NamedExprselement: 26
targets: 27
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Operationoperator: 32
operands: 33
27Operationoperator: 34
operands: 35
28Literal
29NamedExprsstate: 43
part: 37
30Literal
31NamedExprsoperation: 42
part: 37
32Literal
33NamedExprsstate: 36
part: 37
34Literal
35ExprTuple38, 39
36Operationoperator: 40
operands: 41
37Variable
38Literal
39Variable
40Literal
41ExprTuple42, 43
42Variable
43Variable