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 Conditional, ExprTuple, Lambda, l
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Exp, Mult, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(_diff_l_scaled_delta_floor, two)
sub_expr2 = frac(one, Mult(four, sub_expr1))
sub_expr3 = Mult(frac(one, four), frac(one, sub_expr1))
sub_expr4 = InSet(l, _neg_domain)
expr = ExprTuple(Forall(instance_param_or_params = [l], instance_expr = Equals(sub_expr2, sub_expr3), domain = _neg_domain), Equals(Lambda(l, Conditional(sub_expr2, sub_expr4)), Lambda(l, Conditional(sub_expr3, sub_expr4))).with_wrapping_at(2))
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}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} = \left(\frac{1}{4} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right), \begin{array}{c} \begin{array}{l} \left[l \mapsto \left\{\frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}\right..\right] =  \\ \left[l \mapsto \left\{\frac{1}{4} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}\right..\right] \end{array} \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: 3
operand: 6
2Operationoperator: 15
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 49
body: 9
7Lambdaparameter: 49
body: 10
8Lambdaparameter: 49
body: 12
9Conditionalvalue: 13
condition: 14
10Conditionalvalue: 19
condition: 14
11ExprTuple49
12Conditionalvalue: 20
condition: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple49, 21
19Operationoperator: 33
operands: 22
20Operationoperator: 57
operands: 23
21Operationoperator: 24
operands: 25
22ExprTuple63, 26
23ExprTuple27, 28
24Literal
25ExprTuple29, 30
26Operationoperator: 57
operands: 31
27Operationoperator: 33
operands: 32
28Operationoperator: 33
operands: 34
29Operationoperator: 53
operands: 35
30Operationoperator: 59
operand: 40
31ExprTuple37, 38
32ExprTuple63, 37
33Literal
34ExprTuple63, 38
35ExprTuple39, 63
36ExprTuple40
37Literal
38Operationoperator: 64
operands: 41
39Operationoperator: 59
operand: 45
40Operationoperator: 53
operands: 43
41ExprTuple44, 68
42ExprTuple45
43ExprTuple46, 63
44Operationoperator: 53
operands: 47
45Operationoperator: 64
operands: 48
46Variable
47ExprTuple49, 50
48ExprTuple68, 51
49Variable
50Operationoperator: 59
operand: 55
51Operationoperator: 53
operands: 54
52ExprTuple55
53Literal
54ExprTuple69, 56
55Operationoperator: 57
operands: 58
56Operationoperator: 59
operand: 63
57Literal
58ExprTuple61, 62
59Literal
60ExprTuple63
61Operationoperator: 64
operands: 65
62Operationoperator: 66
operand: 70
63Literal
64Literal
65ExprTuple68, 69
66Literal
67ExprTuple70
68Literal
69Literal
70Literal