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
import proveit
import proveit.numbers
from proveit import ExprTuple
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.numbers import Exp, Interval, Mult, e, one, pi, two
from proveit.physics.quantum import Ket, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(VecSum(index_or_indices = [proveit.i], summand = ScalarMult(Exp(e, Mult(two, pi, proveit.numbers.i, _phase, proveit.i)), Ket(proveit.i)), domain = Interval(one, one)), ScalarMult(Exp(e, Mult(two, pi, proveit.numbers.i, _phase)), ket1))
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(\sum_{i=1}^{1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot i} \cdot \lvert i \rangle\right), \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert 1 \rangle\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: 3
operand: 6
2Operationoperator: 15
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 38
body: 9
7Operationoperator: 23
operands: 10
8Operationoperator: 25
operand: 31
9Conditionalvalue: 12
condition: 13
10ExprTuple29, 14
11ExprTuple31
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 32
operands: 19
15Literal
16ExprTuple20, 21
17Literal
18ExprTuple38, 22
19ExprTuple34, 35, 36, 37
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operand: 38
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple29, 30
25Literal
26ExprTuple38
27Literal
28ExprTuple31, 31
29Literal
30Operationoperator: 32
operands: 33
31Literal
32Literal
33ExprTuple34, 35, 36, 37, 38
34Literal
35Literal
36Literal
37Literal
38Variable