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_on_register_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Prob(phase_kickback_on_register_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] & \qw & \gate{\cdots} \qwx[1] & \qw & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{1}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert + \rangle} & \qw \qwx[1] & \control{} \qw \qwx[1] & \gate{\cdots} \qwx[1] & \qw & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{2}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} & \qout{\vdots} \\
\qin{\lvert + \rangle} & \qw \qwx[1] & \qw \qwx[1] & \gate{\cdots} \qwx[1] & \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_{t}} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert u \rangle} & \gate{U_{1}} & \gate{U_{2}} & \gate{\cdots} & \gate{U_{t}} & \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, 106
1Operationoperator: 2
operand: 4
2Literal
3ExprTuple4
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8, 9
7ExprTuple10, 11
8ExprRangelambda_map: 12
start_index: 106
end_index: 105
9ExprTuple13, 14
10ExprRangelambda_map: 15
start_index: 106
end_index: 105
11ExprRangelambda_map: 16
start_index: 106
end_index: 89
12Lambdaparameter: 88
body: 17
13ExprRangelambda_map: 18
start_index: 106
end_index: 105
14ExprRangelambda_map: 19
start_index: 106
end_index: 89
15Lambdaparameter: 115
body: 20
16Lambdaparameter: 115
body: 21
17ExprTuple22, 23
18Lambdaparameter: 115
body: 24
19Lambdaparameter: 115
body: 25
20Operationoperator: 39
operands: 26
21Operationoperator: 64
operands: 27
22ExprRangelambda_map: 28
start_index: 106
end_index: 105
23ExprRangelambda_map: 29
start_index: 106
end_index: 89
24Operationoperator: 44
operands: 30
25Operationoperator: 64
operands: 31
26NamedExprsstate: 32
27NamedExprselement: 33
targets: 50
28Lambdaparameter: 115
body: 34
29Lambdaparameter: 115
body: 35
30NamedExprsstate: 36
31NamedExprselement: 37
targets: 50
32Operationoperator: 99
operand: 46
33Operationoperator: 39
operands: 45
34Operationoperator: 40
operands: 41
35Operationoperator: 64
operands: 42
36Operationoperator: 84
operands: 43
37Operationoperator: 44
operands: 45
38ExprTuple46
39Literal
40Literal
41ExprTuple47, 48
42NamedExprselement: 49
targets: 50
43ExprTuple51, 52
44Literal
45NamedExprsstate: 53
part: 115
46Literal
47Conditionalvalue: 54
condition: 55
48Conditionalvalue: 56
condition: 57
49Operationoperator: 67
operands: 58
50Operationoperator: 59
operands: 60
51Operationoperator: 95
operands: 61
52Operationoperator: 62
operands: 63
53Variable
54Operationoperator: 64
operands: 65
55Operationoperator: 66
operands: 70
56Operationoperator: 67
operands: 68
57Operationoperator: 69
operands: 70
58NamedExprsoperation: 71
part: 115
59Literal
60ExprTuple94, 72
61ExprTuple106, 73
62Literal
63ExprTuple74, 75
64Literal
65NamedExprselement: 76
targets: 77
66Literal
67Literal
68NamedExprsoperation: 78
69Literal
70ExprTuple88, 115
71IndexedVarvariable: 79
index: 88
72Operationoperator: 101
operands: 81
73Operationoperator: 97
operands: 82
74Operationoperator: 99
operand: 91
75Operationoperator: 84
operands: 85
76Literal
77Operationoperator: 86
operand: 94
78Literal
79Variable
80ExprTuple88
81ExprTuple105, 89
82ExprTuple109, 90
83ExprTuple91
84Literal
85ExprTuple92, 93
86Literal
87ExprTuple94
88Variable
89Variable
90Operationoperator: 95
operands: 96
91Literal
92Operationoperator: 97
operands: 98
93Operationoperator: 99
operand: 106
94Operationoperator: 101
operands: 102
95Literal
96ExprTuple106, 109
97Literal
98ExprTuple103, 104
99Literal
100ExprTuple106
101Literal
102ExprTuple105, 106
103Literal
104Operationoperator: 107
operands: 108
105Variable
106Literal
107Literal
108ExprTuple109, 110, 111, 112
109Literal
110Literal
111Literal
112IndexedVarvariable: 113
index: 115
113Variable
114ExprTuple115
115Variable