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, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import Pfail, _diff_l_scaled_delta_floor, _neg_domain, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = ExprTuple(Pfail(e), Mult(frac(one, four), Add(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _pos_domain))))
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[P_{\rm fail}\right]\left(e\right), \frac{1}{4} \cdot \left(\left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right)\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: 50
2Operationoperator: 53
operands: 5
3Literal
4ExprTuple50
5ExprTuple6, 7
6Operationoperator: 25
operands: 8
7Operationoperator: 58
operands: 9
8ExprTuple70, 10
9ExprTuple11, 12
10Literal
11Operationoperator: 14
operand: 16
12Operationoperator: 14
operand: 17
13ExprTuple16
14Literal
15ExprTuple17
16Lambdaparameter: 44
body: 18
17Lambdaparameter: 44
body: 20
18Conditionalvalue: 22
condition: 21
19ExprTuple44
20Conditionalvalue: 22
condition: 23
21Operationoperator: 27
operands: 24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24ExprTuple44, 29
25Literal
26ExprTuple70, 30
27Literal
28ExprTuple44, 31
29Operationoperator: 34
operands: 32
30Operationoperator: 60
operands: 33
31Operationoperator: 34
operands: 35
32ExprTuple36, 37
33ExprTuple38, 65
34Literal
35ExprTuple43, 49
36Operationoperator: 58
operands: 39
37Operationoperator: 68
operand: 43
38Operationoperator: 58
operands: 41
39ExprTuple42, 70
40ExprTuple43
41ExprTuple44, 45
42Operationoperator: 68
operand: 49
43Operationoperator: 58
operands: 47
44Variable
45Operationoperator: 68
operand: 51
46ExprTuple49
47ExprTuple50, 70
48ExprTuple51
49Operationoperator: 60
operands: 52
50Variable
51Operationoperator: 53
operands: 54
52ExprTuple65, 55
53Literal
54ExprTuple56, 57
55Operationoperator: 58
operands: 59
56Operationoperator: 60
operands: 61
57Operationoperator: 62
operand: 67
58Literal
59ExprTuple66, 64
60Literal
61ExprTuple65, 66
62Literal
63ExprTuple67
64Operationoperator: 68
operand: 70
65Literal
66Literal
67Literal
68Literal
69ExprTuple70
70Literal