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 ExprRange, ExprTuple, IndexedVar, Variable, a, c, l
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Complex, Exp, Mult, Sum, frac, one, two, zero
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = IndexedVar(a, one)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)
sub_expr5 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = ExprTuple(Forall(instance_param_or_params = sub_expr2, instance_expr = InSet(sub_expr5, Complex), domain = _neg_domain), Forall(instance_param_or_params = [sub_expr3, sub_expr4], instance_expr = Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr2, summand = sub_expr5, domain = _neg_domain), sub_expr4), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr3, sub_expr5, sub_expr4), domain = _neg_domain)).with_wrapping_at(2), domain = Complex).with_wrapping())
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_{l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}}~\left(\frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \in \mathbb{C}\right), \begin{array}{l}\forall_{a_{1}, c_{1}, c_{2}, \ldots, c_{0} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot \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)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right) =  \\ \left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \left(a_{1} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right)\right) \end{array} \end{array}\right)\end{array}\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: 4
operand: 6
2Operationoperator: 4
operand: 7
3ExprTuple6
4Literal
5ExprTuple7
6Lambdaparameter: 68
body: 8
7Lambdaparameters: 9
body: 10
8Conditionalvalue: 11
condition: 40
9ExprTuple41, 43
10Conditionalvalue: 12
condition: 13
11Operationoperator: 44
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple42, 36
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 77
operands: 23
20Operationoperator: 30
operand: 28
21Operationoperator: 44
operands: 25
22ExprRangelambda_map: 26
start_index: 94
end_index: 50
23ExprTuple41, 27, 43
24ExprTuple28
25ExprTuple41, 36
26Lambdaparameter: 62
body: 29
27Operationoperator: 30
operand: 34
28Lambdaparameter: 68
body: 32
29Operationoperator: 44
operands: 33
30Literal
31ExprTuple34
32Conditionalvalue: 35
condition: 40
33ExprTuple53, 36
34Lambdaparameter: 68
body: 38
35Operationoperator: 77
operands: 39
36Literal
37ExprTuple68
38Conditionalvalue: 42
condition: 40
39ExprTuple41, 42, 43
40Operationoperator: 44
operands: 45
41IndexedVarvariable: 46
index: 94
42Operationoperator: 47
operands: 48
43ExprRangelambda_map: 49
start_index: 94
end_index: 50
44Literal
45ExprTuple68, 51
46Variable
47Literal
48ExprTuple94, 52
49Lambdaparameter: 62
body: 53
50Literal
51Operationoperator: 54
operands: 55
52Operationoperator: 84
operands: 56
53IndexedVarvariable: 57
index: 62
54Literal
55ExprTuple59, 60
56ExprTuple61, 89
57Variable
58ExprTuple62
59Operationoperator: 82
operands: 63
60Operationoperator: 92
operand: 67
61Operationoperator: 82
operands: 65
62Variable
63ExprTuple66, 94
64ExprTuple67
65ExprTuple68, 69
66Operationoperator: 92
operand: 73
67Operationoperator: 82
operands: 71
68Variable
69Operationoperator: 92
operand: 75
70ExprTuple73
71ExprTuple74, 94
72ExprTuple75
73Operationoperator: 84
operands: 76
74Variable
75Operationoperator: 77
operands: 78
76ExprTuple89, 79
77Literal
78ExprTuple80, 81
79Operationoperator: 82
operands: 83
80Operationoperator: 84
operands: 85
81Operationoperator: 86
operand: 91
82Literal
83ExprTuple90, 88
84Literal
85ExprTuple89, 90
86Literal
87ExprTuple91
88Operationoperator: 92
operand: 94
89Literal
90Literal
91Literal
92Literal
93ExprTuple94
94Literal