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 InSet
from proveit.numbers import Exp, Mult, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(_diff_l_scaled_delta_floor, two)
sub_expr2 = InSet(l, _pos_domain)
expr = ExprTuple(Lambda(l, Conditional(frac(one, Mult(four, sub_expr1)), sub_expr2)), Lambda(l, Conditional(Mult(frac(one, four), frac(one, sub_expr1)), sub_expr2)))
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(l \mapsto \left\{\frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \textrm{ if } l \in \{e + 1~\ldotp \ldotp~2^{t - 1}\}\right.., 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 \{e + 1~\ldotp \ldotp~2^{t - 1}\}\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
1Lambdaparameter: 36
body: 3
2Lambdaparameter: 36
body: 5
3Conditionalvalue: 6
condition: 8
4ExprTuple36
5Conditionalvalue: 7
condition: 8
6Operationoperator: 19
operands: 9
7Operationoperator: 44
operands: 10
8Operationoperator: 11
operands: 12
9ExprTuple43, 13
10ExprTuple14, 15
11Literal
12ExprTuple36, 16
13Operationoperator: 44
operands: 17
14Operationoperator: 19
operands: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operands: 22
17ExprTuple23, 24
18ExprTuple43, 23
19Literal
20ExprTuple43, 24
21Literal
22ExprTuple25, 26
23Literal
24Operationoperator: 48
operands: 27
25Operationoperator: 34
operands: 28
26Operationoperator: 48
operands: 29
27ExprTuple30, 52
28ExprTuple31, 43
29ExprTuple52, 32
30Operationoperator: 34
operands: 33
31Variable
32Operationoperator: 34
operands: 35
33ExprTuple36, 37
34Literal
35ExprTuple53, 38
36Variable
37Operationoperator: 40
operand: 42
38Operationoperator: 40
operand: 43
39ExprTuple42
40Literal
41ExprTuple43
42Operationoperator: 44
operands: 45
43Literal
44Literal
45ExprTuple46, 47
46Operationoperator: 48
operands: 49
47Operationoperator: 50
operand: 54
48Literal
49ExprTuple52, 53
50Literal
51ExprTuple54
52Literal
53Literal
54Literal