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, e, l
from proveit.logic import InSet
from proveit.numbers import Add, Exp, LessEq, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import Pfail, _diff_l_scaled_delta_floor, _e_domain, _neg_domain, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = ExprTuple(Lambda(e, Conditional(LessEq(Pfail(e), Mult(frac(one, four), Add(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _pos_domain)))), InSet(e, _e_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(e \mapsto \left\{\left[P_{\rm fail}\right]\left(e\right) \leq \left(\frac{1}{4} \cdot \left(\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) + \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right)\right) \textrm{ if } e \in \{1~\ldotp \ldotp~2^{t - 1} - 2\}\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: 63
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 40
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple63, 10
8Operationoperator: 11
operand: 63
9Operationoperator: 66
operands: 13
10Operationoperator: 47
operands: 14
11Literal
12ExprTuple63
13ExprTuple15, 16
14ExprTuple83, 17
15Operationoperator: 38
operands: 18
16Operationoperator: 71
operands: 19
17Operationoperator: 71
operands: 20
18ExprTuple83, 21
19ExprTuple22, 23
20ExprTuple62, 24
21Literal
22Operationoperator: 26
operand: 29
23Operationoperator: 26
operand: 30
24Operationoperator: 81
operand: 78
25ExprTuple29
26Literal
27ExprTuple30
28ExprTuple78
29Lambdaparameter: 57
body: 31
30Lambdaparameter: 57
body: 33
31Conditionalvalue: 35
condition: 34
32ExprTuple57
33Conditionalvalue: 35
condition: 36
34Operationoperator: 40
operands: 37
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37ExprTuple57, 42
38Literal
39ExprTuple83, 43
40Literal
41ExprTuple57, 44
42Operationoperator: 47
operands: 45
43Operationoperator: 73
operands: 46
44Operationoperator: 47
operands: 48
45ExprTuple49, 50
46ExprTuple51, 78
47Literal
48ExprTuple56, 62
49Operationoperator: 71
operands: 52
50Operationoperator: 81
operand: 56
51Operationoperator: 71
operands: 54
52ExprTuple55, 83
53ExprTuple56
54ExprTuple57, 58
55Operationoperator: 81
operand: 62
56Operationoperator: 71
operands: 60
57Variable
58Operationoperator: 81
operand: 64
59ExprTuple62
60ExprTuple63, 83
61ExprTuple64
62Operationoperator: 73
operands: 65
63Variable
64Operationoperator: 66
operands: 67
65ExprTuple78, 68
66Literal
67ExprTuple69, 70
68Operationoperator: 71
operands: 72
69Operationoperator: 73
operands: 74
70Operationoperator: 75
operand: 80
71Literal
72ExprTuple79, 77
73Literal
74ExprTuple78, 79
75Literal
76ExprTuple80
77Operationoperator: 81
operand: 83
78Literal
79Literal
80Literal
81Literal
82ExprTuple83
83Literal