logo

Expression of type Lambda

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, 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 = 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())
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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 62
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 39
operands: 6
4Literal
5ExprTuple7, 8
6ExprTuple62, 9
7Operationoperator: 10
operand: 62
8Operationoperator: 65
operands: 12
9Operationoperator: 46
operands: 13
10Literal
11ExprTuple62
12ExprTuple14, 15
13ExprTuple82, 16
14Operationoperator: 37
operands: 17
15Operationoperator: 70
operands: 18
16Operationoperator: 70
operands: 19
17ExprTuple82, 20
18ExprTuple21, 22
19ExprTuple61, 23
20Literal
21Operationoperator: 25
operand: 28
22Operationoperator: 25
operand: 29
23Operationoperator: 80
operand: 77
24ExprTuple28
25Literal
26ExprTuple29
27ExprTuple77
28Lambdaparameter: 56
body: 30
29Lambdaparameter: 56
body: 32
30Conditionalvalue: 34
condition: 33
31ExprTuple56
32Conditionalvalue: 34
condition: 35
33Operationoperator: 39
operands: 36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36ExprTuple56, 41
37Literal
38ExprTuple82, 42
39Literal
40ExprTuple56, 43
41Operationoperator: 46
operands: 44
42Operationoperator: 72
operands: 45
43Operationoperator: 46
operands: 47
44ExprTuple48, 49
45ExprTuple50, 77
46Literal
47ExprTuple55, 61
48Operationoperator: 70
operands: 51
49Operationoperator: 80
operand: 55
50Operationoperator: 70
operands: 53
51ExprTuple54, 82
52ExprTuple55
53ExprTuple56, 57
54Operationoperator: 80
operand: 61
55Operationoperator: 70
operands: 59
56Variable
57Operationoperator: 80
operand: 63
58ExprTuple61
59ExprTuple62, 82
60ExprTuple63
61Operationoperator: 72
operands: 64
62Variable
63Operationoperator: 65
operands: 66
64ExprTuple77, 67
65Literal
66ExprTuple68, 69
67Operationoperator: 70
operands: 71
68Operationoperator: 72
operands: 73
69Operationoperator: 74
operand: 79
70Literal
71ExprTuple78, 76
72Literal
73ExprTuple77, 78
74Literal
75ExprTuple79
76Operationoperator: 80
operand: 82
77Literal
78Literal
79Literal
80Literal
81ExprTuple82
82Literal