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 phase_kickback_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Prob(phase_kickback_circuit), 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 + \rangle} & \control{} \qw \qwx[1] & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert u \rangle} & \gate{U} & \qout{\lvert u \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, 83
1Operationoperator: 2
operand: 4
2Literal
3ExprTuple4
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8, 9
7ExprTuple10, 11
8ExprTuple12, 13
9ExprTuple14, 15
10Operationoperator: 47
operands: 16
11ExprRangelambda_map: 17
start_index: 83
end_index: 22
12Operationoperator: 38
operands: 18
13ExprRangelambda_map: 19
start_index: 83
end_index: 22
14Operationoperator: 53
operands: 20
15ExprRangelambda_map: 21
start_index: 83
end_index: 22
16NamedExprsstate: 23
17Lambdaparameter: 62
body: 24
18NamedExprselement: 25
targets: 26
19Lambdaparameter: 62
body: 27
20NamedExprsstate: 28
21Lambdaparameter: 62
body: 30
22Operationoperator: 68
operands: 31
23Operationoperator: 79
operand: 40
24Operationoperator: 38
operands: 33
25Literal
26Operationoperator: 34
operand: 86
27Operationoperator: 38
operands: 36
28Operationoperator: 66
operands: 37
29ExprTuple62
30Operationoperator: 38
operands: 39
31ExprTuple74, 83
32ExprTuple40
33NamedExprselement: 41
targets: 46
34Literal
35ExprTuple86
36NamedExprselement: 42
targets: 46
37ExprTuple43, 44
38Literal
39NamedExprselement: 45
targets: 46
40Literal
41Operationoperator: 47
operands: 54
42Operationoperator: 48
operands: 49
43Operationoperator: 75
operands: 50
44Operationoperator: 51
operands: 52
45Operationoperator: 53
operands: 54
46Operationoperator: 55
operands: 56
47Literal
48Literal
49NamedExprsoperation: 57
part: 62
50ExprTuple83, 58
51Literal
52ExprTuple59, 60
53Literal
54NamedExprsstate: 61
part: 62
55Literal
56ExprTuple86, 63
57Variable
58Operationoperator: 77
operands: 64
59Operationoperator: 79
operand: 71
60Operationoperator: 66
operands: 67
61Variable
62Variable
63Operationoperator: 68
operands: 69
64ExprTuple86, 70
65ExprTuple71
66Literal
67ExprTuple72, 73
68Literal
69ExprTuple74, 86
70Operationoperator: 75
operands: 76
71Literal
72Operationoperator: 77
operands: 78
73Operationoperator: 79
operand: 83
74Variable
75Literal
76ExprTuple83, 86
77Literal
78ExprTuple81, 82
79Literal
80ExprTuple83
81Literal
82Operationoperator: 84
operands: 85
83Literal
84Literal
85ExprTuple86, 87, 88, 89
86Literal
87Literal
88Literal
89Variable