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 Equals, InSet
from proveit.numbers import Abs, Add, Exp, Interval, Neg, one, subtract, two
from proveit.physics.quantum.QPE import _neg_domain, _rel_indexed_alpha, _two_pow__t_minus_one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(Abs(_rel_indexed_alpha), two)
expr = Lambda(l, Equals(Conditional(sub_expr1, InSet(l, _neg_domain)), Conditional(sub_expr1, InSet(l, Interval(Add(Neg(_two_pow__t_minus_one), one), subtract(Neg(e), one))))).with_wrapping_at(1))
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())
l \mapsto \left(\begin{array}{c} \begin{array}{l} \left\{\left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}\right.. \\  = \left\{\left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-e - 1\}\right.. \end{array} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 41
body: 2
1ExprTuple41
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Conditionalvalue: 8
condition: 7
6Conditionalvalue: 8
condition: 9
7Operationoperator: 12
operands: 10
8Operationoperator: 44
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple41, 14
11ExprTuple15, 46
12Literal
13ExprTuple41, 16
14Operationoperator: 20
operands: 17
15Operationoperator: 18
operand: 23
16Operationoperator: 20
operands: 21
17ExprTuple24, 22
18Literal
19ExprTuple23
20Literal
21ExprTuple24, 25
22Operationoperator: 52
operand: 31
23Operationoperator: 27
operand: 32
24Operationoperator: 48
operands: 29
25Operationoperator: 48
operands: 30
26ExprTuple31
27Literal
28ExprTuple32
29ExprTuple33, 54
30ExprTuple34, 51
31Operationoperator: 48
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 52
operand: 42
34Operationoperator: 52
operand: 43
35ExprTuple43, 54
36Literal
37ExprTuple40, 41
38ExprTuple42
39ExprTuple43
40Literal
41Variable
42Operationoperator: 44
operands: 45
43Variable
44Literal
45ExprTuple46, 47
46Literal
47Operationoperator: 48
operands: 49
48Literal
49ExprTuple50, 51
50Literal
51Operationoperator: 52
operand: 54
52Literal
53ExprTuple54
54Literal