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, Ceil, Exp, Log, Mult, Neg, frac, one, subtract, two
from proveit.physics.quantum.QPE import _eps, _n
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(subtract(Add(_n, Ceil(Log(two, Add(two, frac(one, Mult(two, _eps)))))), _n), subtract(Add(_n, Ceil(Log(two, Add(two, Mult(frac(one, two), Exp(_eps, Neg(one))))))), _n))
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(n + \left\lceil \textrm{log}_2\left(2 + \frac{1}{2 \cdot \epsilon}\right)\right\rceil\right) - n, \left(n + \left\lceil \textrm{log}_2\left(2 + \left(\frac{1}{2} \cdot \epsilon^{-1}\right)\right)\right\rceil\right) - n\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: 25
operands: 3
2Operationoperator: 25
operands: 4
3ExprTuple5, 7
4ExprTuple6, 7
5Operationoperator: 25
operands: 8
6Operationoperator: 25
operands: 9
7Operationoperator: 43
operand: 13
8ExprTuple13, 11
9ExprTuple13, 12
10ExprTuple13
11Operationoperator: 15
operand: 17
12Operationoperator: 15
operand: 18
13Literal
14ExprTuple17
15Literal
16ExprTuple18
17Operationoperator: 20
operands: 19
18Operationoperator: 20
operands: 21
19ExprTuple40, 22
20Literal
21ExprTuple40, 23
22Operationoperator: 25
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple40, 27
25Literal
26ExprTuple40, 28
27Operationoperator: 36
operands: 29
28Operationoperator: 34
operands: 30
29ExprTuple45, 31
30ExprTuple32, 33
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operands: 39
34Literal
35ExprTuple40, 41
36Literal
37ExprTuple45, 40
38Literal
39ExprTuple41, 42
40Literal
41Literal
42Operationoperator: 43
operand: 45
43Literal
44ExprTuple45
45Literal