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, k
from proveit.logic import InSet
from proveit.numbers import Exp, LessEq, Mult, frac, one, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _pos_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(k, Conditional(LessEq(frac(one, Exp(subtract(k, Mult(_two_pow_t, _delta_b_floor)), two)), frac(one, Exp(subtract(k, one), two))), InSet(k, _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(k \mapsto \left\{\frac{1}{\left(k - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \leq \frac{1}{\left(k - 1\right)^{2}} \textrm{ if } k \in \{e + 1~\ldotp \ldotp~2^{t - 1}\}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 35
body: 3
2ExprTuple35
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple35, 12
10Operationoperator: 14
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple41, 18
14Literal
15ExprTuple41, 19
16Literal
17ExprTuple20, 21
18Operationoperator: 46
operands: 22
19Operationoperator: 46
operands: 23
20Operationoperator: 32
operands: 24
21Operationoperator: 46
operands: 25
22ExprTuple26, 50
23ExprTuple27, 50
24ExprTuple28, 41
25ExprTuple50, 29
26Operationoperator: 32
operands: 30
27Operationoperator: 32
operands: 31
28Variable
29Operationoperator: 32
operands: 33
30ExprTuple35, 34
31ExprTuple35, 36
32Literal
33ExprTuple51, 36
34Operationoperator: 38
operand: 40
35Variable
36Operationoperator: 38
operand: 41
37ExprTuple40
38Literal
39ExprTuple41
40Operationoperator: 42
operands: 43
41Literal
42Literal
43ExprTuple44, 45
44Operationoperator: 46
operands: 47
45Operationoperator: 48
operand: 52
46Literal
47ExprTuple50, 51
48Literal
49ExprTuple52
50Literal
51Literal
52Literal