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
from proveit.numbers import Add, Exp, Mult, Neg, four, frac, one, subtract, two
from proveit.physics.quantum.QPE import _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, two)
expr = ExprTuple(Add(Add(Mult(sub_expr1, sub_expr1), frac(one, four)), subtract(Neg(sub_expr1), Mult(sub_expr1, frac(one, _two_pow_t)))), Neg(frac(one, Exp(two, Add(one, _t)))))
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(\left(\left(\frac{1}{2} \cdot \frac{1}{2}\right) + \frac{1}{4}\right) + \left(-\frac{1}{2} - \left(\frac{1}{2} \cdot \frac{1}{2^{t}}\right)\right), -\frac{1}{2^{1 + t}}\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: 27
operands: 3
2Operationoperator: 19
operand: 7
3ExprTuple5, 6
4ExprTuple7
5Operationoperator: 27
operands: 8
6Operationoperator: 27
operands: 9
7Operationoperator: 32
operands: 10
8ExprTuple11, 12
9ExprTuple13, 14
10ExprTuple34, 15
11Operationoperator: 25
operands: 16
12Operationoperator: 32
operands: 17
13Operationoperator: 19
operand: 29
14Operationoperator: 19
operand: 23
15Operationoperator: 36
operands: 21
16ExprTuple29, 29
17ExprTuple34, 22
18ExprTuple29
19Literal
20ExprTuple23
21ExprTuple38, 24
22Literal
23Operationoperator: 25
operands: 26
24Operationoperator: 27
operands: 28
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple34, 39
29Operationoperator: 32
operands: 31
30Operationoperator: 32
operands: 33
31ExprTuple34, 38
32Literal
33ExprTuple34, 35
34Literal
35Operationoperator: 36
operands: 37
36Literal
37ExprTuple38, 39
38Literal
39Literal