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, e, l
from proveit.numbers import Add, Exp, Interval, Sum, frac, one, subtract, two
from proveit.physics.quantum.QPE import _two_pow__t_minus_one
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(frac(one, Exp(e, two)), Sum(index_or_indices = [l], summand = frac(one, Exp(l, two)), domain = Interval(Add(e, one), subtract(_two_pow__t_minus_one, 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(\frac{1}{e^{2}}, \sum_{l = e + 1}^{2^{t - 1} - 1} \frac{1}{l^{2}}\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: 13
operands: 3
2Operationoperator: 4
operand: 7
3ExprTuple39, 6
4Literal
5ExprTuple7
6Operationoperator: 29
operands: 8
7Lambdaparameter: 22
body: 10
8ExprTuple27, 31
9ExprTuple22
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple39, 17
15Literal
16ExprTuple22, 18
17Operationoperator: 29
operands: 19
18Operationoperator: 20
operands: 21
19ExprTuple22, 31
20Literal
21ExprTuple23, 24
22Variable
23Operationoperator: 33
operands: 25
24Operationoperator: 33
operands: 26
25ExprTuple27, 39
26ExprTuple28, 36
27Variable
28Operationoperator: 29
operands: 30
29Literal
30ExprTuple31, 32
31Literal
32Operationoperator: 33
operands: 34
33Literal
34ExprTuple35, 36
35Literal
36Operationoperator: 37
operand: 39
37Literal
38ExprTuple39
39Literal