logo

Expression of type Conditional

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, 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 = 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\{\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()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 38
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple61, 8
6Operationoperator: 9
operand: 61
7Operationoperator: 64
operands: 11
8Operationoperator: 45
operands: 12
9Literal
10ExprTuple61
11ExprTuple13, 14
12ExprTuple81, 15
13Operationoperator: 36
operands: 16
14Operationoperator: 69
operands: 17
15Operationoperator: 69
operands: 18
16ExprTuple81, 19
17ExprTuple20, 21
18ExprTuple60, 22
19Literal
20Operationoperator: 24
operand: 27
21Operationoperator: 24
operand: 28
22Operationoperator: 79
operand: 76
23ExprTuple27
24Literal
25ExprTuple28
26ExprTuple76
27Lambdaparameter: 55
body: 29
28Lambdaparameter: 55
body: 31
29Conditionalvalue: 33
condition: 32
30ExprTuple55
31Conditionalvalue: 33
condition: 34
32Operationoperator: 38
operands: 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple55, 40
36Literal
37ExprTuple81, 41
38Literal
39ExprTuple55, 42
40Operationoperator: 45
operands: 43
41Operationoperator: 71
operands: 44
42Operationoperator: 45
operands: 46
43ExprTuple47, 48
44ExprTuple49, 76
45Literal
46ExprTuple54, 60
47Operationoperator: 69
operands: 50
48Operationoperator: 79
operand: 54
49Operationoperator: 69
operands: 52
50ExprTuple53, 81
51ExprTuple54
52ExprTuple55, 56
53Operationoperator: 79
operand: 60
54Operationoperator: 69
operands: 58
55Variable
56Operationoperator: 79
operand: 62
57ExprTuple60
58ExprTuple61, 81
59ExprTuple62
60Operationoperator: 71
operands: 63
61Variable
62Operationoperator: 64
operands: 65
63ExprTuple76, 66
64Literal
65ExprTuple67, 68
66Operationoperator: 69
operands: 70
67Operationoperator: 71
operands: 72
68Operationoperator: 73
operand: 78
69Literal
70ExprTuple77, 75
71Literal
72ExprTuple76, 77
73Literal
74ExprTuple78
75Operationoperator: 79
operand: 81
76Literal
77Literal
78Literal
79Literal
80ExprTuple81
81Literal