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 Equals, InSet
from proveit.numbers import Abs, Add, Exp, Sum, two
from proveit.physics.quantum.QPE import Pfail, _e_domain, _neg_domain, _pos_domain, _rel_indexed_alpha
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = Exp(Abs(_rel_indexed_alpha), two)
expr = ExprTuple(Lambda(e, Conditional(Equals(Pfail(e), 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) = \left(\left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\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: 59
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 34
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple59, 10
8Operationoperator: 11
operand: 59
9Operationoperator: 66
operands: 13
10Operationoperator: 42
operands: 14
11Literal
12ExprTuple59
13ExprTuple15, 16
14ExprTuple72, 17
15Operationoperator: 19
operand: 22
16Operationoperator: 19
operand: 23
17Operationoperator: 66
operands: 21
18ExprTuple22
19Literal
20ExprTuple23
21ExprTuple58, 24
22Lambdaparameter: 61
body: 25
23Lambdaparameter: 61
body: 27
24Operationoperator: 70
operand: 64
25Conditionalvalue: 30
condition: 29
26ExprTuple61
27Conditionalvalue: 30
condition: 31
28ExprTuple64
29Operationoperator: 34
operands: 32
30Operationoperator: 62
operands: 33
31Operationoperator: 34
operands: 35
32ExprTuple61, 36
33ExprTuple37, 64
34Literal
35ExprTuple61, 38
36Operationoperator: 42
operands: 39
37Operationoperator: 40
operand: 46
38Operationoperator: 42
operands: 43
39ExprTuple44, 45
40Literal
41ExprTuple46
42Literal
43ExprTuple52, 58
44Operationoperator: 66
operands: 47
45Operationoperator: 70
operand: 52
46Operationoperator: 49
operand: 53
47ExprTuple51, 72
48ExprTuple52
49Literal
50ExprTuple53
51Operationoperator: 70
operand: 58
52Operationoperator: 66
operands: 55
53Operationoperator: 56
operands: 57
54ExprTuple58
55ExprTuple59, 72
56Literal
57ExprTuple60, 61
58Operationoperator: 62
operands: 63
59Variable
60Literal
61Variable
62Literal
63ExprTuple64, 65
64Literal
65Operationoperator: 66
operands: 67
66Literal
67ExprTuple68, 69
68Literal
69Operationoperator: 70
operand: 72
70Literal
71ExprTuple72
72Literal