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, k, l
from proveit.logic import Forall
from proveit.numbers import Exp, LessEq, Mult, Sum, frac, one, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _diff_l_scaled_delta_floor, _pos_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
expr = ExprTuple(Forall(instance_param_or_params = [k], instance_expr = LessEq(frac(one, Exp(subtract(k, Mult(_two_pow_t, _delta_b_floor)), two)), frac(one, Exp(subtract(k, one), two))), domain = _pos_domain), LessEq(Sum(index_or_indices = sub_expr1, summand = frac(one, Exp(_diff_l_scaled_delta_floor, two)), domain = _pos_domain), Sum(index_or_indices = sub_expr1, summand = frac(one, Exp(subtract(l, one), two)), 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(\forall_{k \in \{e + 1~\ldotp \ldotp~2^{t - 1}\}}~\left(\frac{1}{\left(k - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \leq \frac{1}{\left(k - 1\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) \leq \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{\left(l - 1\right)^{2}}\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: 6
2Operationoperator: 18
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 59
body: 10
7Operationoperator: 12
operand: 16
8Operationoperator: 12
operand: 17
9ExprTuple59
10Conditionalvalue: 14
condition: 15
11ExprTuple16
12Literal
13ExprTuple17
14Operationoperator: 18
operands: 19
15Operationoperator: 34
operands: 20
16Lambdaparameter: 61
body: 21
17Lambdaparameter: 61
body: 23
18Literal
19ExprTuple24, 25
20ExprTuple59, 40
21Conditionalvalue: 26
condition: 28
22ExprTuple61
23Conditionalvalue: 27
condition: 28
24Operationoperator: 32
operands: 29
25Operationoperator: 32
operands: 30
26Operationoperator: 32
operands: 31
27Operationoperator: 32
operands: 33
28Operationoperator: 34
operands: 35
29ExprTuple75, 36
30ExprTuple75, 37
31ExprTuple75, 38
32Literal
33ExprTuple75, 39
34Literal
35ExprTuple61, 40
36Operationoperator: 76
operands: 41
37Operationoperator: 76
operands: 42
38Operationoperator: 76
operands: 43
39Operationoperator: 76
operands: 44
40Operationoperator: 45
operands: 46
41ExprTuple47, 80
42ExprTuple48, 80
43ExprTuple49, 80
44ExprTuple50, 80
45Literal
46ExprTuple51, 52
47Operationoperator: 65
operands: 53
48Operationoperator: 65
operands: 54
49Operationoperator: 65
operands: 55
50Operationoperator: 65
operands: 56
51Operationoperator: 65
operands: 57
52Operationoperator: 76
operands: 58
53ExprTuple59, 60
54ExprTuple59, 68
55ExprTuple61, 60
56ExprTuple61, 68
57ExprTuple62, 75
58ExprTuple80, 63
59Variable
60Operationoperator: 71
operand: 67
61Variable
62Variable
63Operationoperator: 65
operands: 66
64ExprTuple67
65Literal
66ExprTuple81, 68
67Operationoperator: 69
operands: 70
68Operationoperator: 71
operand: 75
69Literal
70ExprTuple73, 74
71Literal
72ExprTuple75
73Operationoperator: 76
operands: 77
74Operationoperator: 78
operand: 82
75Literal
76Literal
77ExprTuple80, 81
78Literal
79ExprTuple82
80Literal
81Literal
82Literal