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, Variable
from proveit.numbers import Add, Exp, Mult, Neg, four, frac, one, subtract, two
from proveit.physics.quantum.QPE import _eps, _n, _t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = subtract(Exp(two, subtract(_t, _n)), one)
expr = ExprTuple(Add(one, Neg(Variable("_a", latex_format = r"{_{-}a}")), Neg(frac(one, Exp(Add(two, frac(one, _eps)), two)))), Add(one, Neg(frac(one, Mult(two, sub_expr1))), Neg(frac(one, Mult(four, Exp(sub_expr1, two))))))
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(1 - {_{-}a} - \frac{1}{\left(2 + \frac{1}{\epsilon}\right)^{2}}, 1 - \frac{1}{2 \cdot \left(2^{t - n} - 1\right)} - \frac{1}{4 \cdot \left(2^{t - n} - 1\right)^{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: 46
operands: 3
2Operationoperator: 46
operands: 4
3ExprTuple45, 5, 6
4ExprTuple45, 7, 8
5Operationoperator: 50
operand: 13
6Operationoperator: 50
operand: 14
7Operationoperator: 50
operand: 15
8Operationoperator: 50
operand: 16
9ExprTuple13
10ExprTuple14
11ExprTuple15
12ExprTuple16
13Variable
14Operationoperator: 34
operands: 17
15Operationoperator: 34
operands: 18
16Operationoperator: 34
operands: 19
17ExprTuple45, 20
18ExprTuple45, 21
19ExprTuple45, 22
20Operationoperator: 40
operands: 23
21Operationoperator: 25
operands: 24
22Operationoperator: 25
operands: 26
23ExprTuple27, 43
24ExprTuple43, 33
25Literal
26ExprTuple28, 29
27Operationoperator: 46
operands: 30
28Literal
29Operationoperator: 40
operands: 31
30ExprTuple43, 32
31ExprTuple33, 43
32Operationoperator: 34
operands: 35
33Operationoperator: 46
operands: 36
34Literal
35ExprTuple45, 37
36ExprTuple38, 39
37Literal
38Operationoperator: 40
operands: 41
39Operationoperator: 50
operand: 45
40Literal
41ExprTuple43, 44
42ExprTuple45
43Literal
44Operationoperator: 46
operands: 47
45Literal
46Literal
47ExprTuple48, 49
48Literal
49Operationoperator: 50
operand: 52
50Literal
51ExprTuple52
52Literal