logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.QPE

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, k, t
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Exp, Interval, Mult, NaturalPos, e, frac, i, one, pi, sqrt, subtract, two, zero
from proveit.physics.quantum import Ket, NumKet
from proveit.physics.quantum.QPE import SubIndexed, _phase, _psi, _psi_t_ket, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Add(t, one)
sub_expr3 = Exp(e, Mult(two, pi, i, _phase, k))
expr = ExprTuple(Equals(SubIndexed(_psi, [one]), ScalarMult(frac(one, sqrt(two)), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr3, Ket(k)), domain = Interval(zero, one)))), Forall(instance_param_or_params = [t], instance_expr = Equals(SubIndexed(_psi, [sub_expr2]), ScalarMult(frac(one, Exp(two, frac(sub_expr2, two))), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr3, NumKet(k, sub_expr2)), domain = Interval(zero, subtract(Mult(two, two_pow_t), one))))), domain = NaturalPos, condition = Equals(_psi_t_ket, ScalarMult(frac(one, Exp(two, frac(t, two))), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr3, NumKet(k, t)), domain = Interval(zero, subtract(two_pow_t, 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(\lvert \psi_{1} \rangle = \left(\frac{1}{\sqrt{2}} \cdot \left(\sum_{k=0}^{1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle\right)\right)\right), \forall_{t \in \mathbb{N}^+~|~\lvert \psi_{t} \rangle = \left(\frac{1}{2^{\frac{t}{2}}} \cdot \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right)\right)}~\left(\lvert \psi_{t + 1} \rangle = \left(\frac{1}{2^{\frac{t + 1}{2}}} \cdot \left(\sum_{k=0}^{\left(2 \cdot 2^{t}\right) - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\right)\right)\right)\right)\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, 2
1Operationoperator: 31
operands: 3
2Operationoperator: 4
operand: 8
3ExprTuple6, 7
4Literal
5ExprTuple8
6Operationoperator: 46
operand: 120
7Operationoperator: 82
operands: 9
8Lambdaparameter: 119
body: 10
9ExprTuple11, 12
10Conditionalvalue: 13
condition: 14
11Operationoperator: 80
operands: 15
12Operationoperator: 60
operand: 21
13Operationoperator: 31
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple120, 20
16ExprTuple21
17ExprTuple22, 23
18Literal
19ExprTuple24, 25
20Operationoperator: 114
operands: 26
21Lambdaparameter: 111
body: 27
22Operationoperator: 46
operand: 86
23Operationoperator: 82
operands: 29
24Operationoperator: 84
operands: 30
25Operationoperator: 31
operands: 32
26ExprTuple118, 33
27Conditionalvalue: 34
condition: 35
28ExprTuple86
29ExprTuple36, 37
30ExprTuple119, 38
31Literal
32ExprTuple39, 40
33Operationoperator: 80
operands: 41
34Operationoperator: 82
operands: 42
35Operationoperator: 84
operands: 43
36Operationoperator: 80
operands: 44
37Operationoperator: 60
operand: 52
38Literal
39Operationoperator: 46
operand: 119
40Operationoperator: 82
operands: 48
41ExprTuple120, 118
42ExprTuple88, 49
43ExprTuple111, 50
44ExprTuple120, 51
45ExprTuple52
46Literal
47ExprTuple119
48ExprTuple53, 54
49Operationoperator: 55
operand: 111
50Operationoperator: 96
operands: 56
51Operationoperator: 114
operands: 57
52Lambdaparameter: 111
body: 58
53Operationoperator: 80
operands: 59
54Operationoperator: 60
operand: 66
55Literal
56ExprTuple101, 120
57ExprTuple118, 62
58Conditionalvalue: 63
condition: 64
59ExprTuple120, 65
60Literal
61ExprTuple66
62Operationoperator: 80
operands: 67
63Operationoperator: 82
operands: 68
64Operationoperator: 84
operands: 69
65Operationoperator: 114
operands: 70
66Lambdaparameter: 111
body: 72
67ExprTuple86, 118
68ExprTuple88, 73
69ExprTuple111, 74
70ExprTuple118, 75
71ExprTuple111
72Conditionalvalue: 76
condition: 77
73Operationoperator: 94
operands: 78
74Operationoperator: 96
operands: 79
75Operationoperator: 80
operands: 81
76Operationoperator: 82
operands: 83
77Operationoperator: 84
operands: 85
78ExprTuple111, 86
79ExprTuple101, 87
80Literal
81ExprTuple119, 118
82Literal
83ExprTuple88, 89
84Literal
85ExprTuple111, 90
86Operationoperator: 106
operands: 91
87Operationoperator: 106
operands: 92
88Operationoperator: 114
operands: 93
89Operationoperator: 94
operands: 95
90Operationoperator: 96
operands: 97
91ExprTuple119, 120
92ExprTuple98, 113
93ExprTuple99, 100
94Literal
95ExprTuple111, 119
96Literal
97ExprTuple101, 102
98Operationoperator: 104
operands: 103
99Literal
100Operationoperator: 104
operands: 105
101Literal
102Operationoperator: 106
operands: 107
103ExprTuple118, 112
104Literal
105ExprTuple118, 108, 109, 110, 111
106Literal
107ExprTuple112, 113
108Literal
109Literal
110Literal
111Variable
112Operationoperator: 114
operands: 115
113Operationoperator: 116
operand: 120
114Literal
115ExprTuple118, 119
116Literal
117ExprTuple120
118Literal
119Variable
120Literal