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, l
from proveit.logic import And, Equals, InSet, NotEquals
from proveit.numbers import Exp, Mult, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _rel_indexed_alpha, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(l, Conditional(Equals(_rel_indexed_alpha, Mult(frac(one, _two_pow_t), frac(subtract(one, Exp(e, Mult(two, pi, i, subtract(Mult(_two_pow_t, _delta_b_floor), l)))), subtract(one, Exp(e, Mult(two, pi, i, subtract(_delta_b_floor, frac(l, _two_pow_t)))))))), And(InSet(l, _full_domain), NotEquals(l, zero))))
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\{\alpha_{b_{\textit{f}} \oplus l} = \left(\frac{1}{2^{t}} \cdot \frac{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\left(2^{t} \cdot \delta_{b_{\textit{f}}}\right) - l\right)}}{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right)}}\right) \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\} ,  l \neq 0\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 80
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 12
operand: 19
9Operationoperator: 68
operands: 14
10Operationoperator: 15
operands: 16
11Operationoperator: 17
operands: 18
12Literal
13ExprTuple19
14ExprTuple20, 21
15Literal
16ExprTuple80, 22
17Literal
18ExprTuple80, 23
19Operationoperator: 24
operands: 25
20Operationoperator: 77
operands: 26
21Operationoperator: 77
operands: 27
22Operationoperator: 28
operands: 29
23Literal
24Literal
25ExprTuple79, 80
26ExprTuple67, 81
27ExprTuple30, 31
28Literal
29ExprTuple32, 44
30Operationoperator: 61
operands: 33
31Operationoperator: 61
operands: 34
32Operationoperator: 61
operands: 35
33ExprTuple67, 36
34ExprTuple67, 37
35ExprTuple38, 67
36Operationoperator: 71
operand: 42
37Operationoperator: 71
operand: 43
38Operationoperator: 71
operand: 44
39ExprTuple42
40ExprTuple43
41ExprTuple44
42Operationoperator: 82
operands: 45
43Operationoperator: 82
operands: 46
44Operationoperator: 82
operands: 47
45ExprTuple49, 48
46ExprTuple49, 50
47ExprTuple84, 51
48Operationoperator: 68
operands: 52
49Literal
50Operationoperator: 68
operands: 53
51Operationoperator: 61
operands: 54
52ExprTuple84, 56, 57, 55
53ExprTuple84, 56, 57, 58
54ExprTuple85, 59
55Operationoperator: 61
operands: 60
56Literal
57Literal
58Operationoperator: 61
operands: 62
59Operationoperator: 71
operand: 67
60ExprTuple64, 65
61Literal
62ExprTuple73, 66
63ExprTuple67
64Operationoperator: 68
operands: 69
65Operationoperator: 71
operand: 80
66Operationoperator: 71
operand: 74
67Literal
68Literal
69ExprTuple81, 73
70ExprTuple80
71Literal
72ExprTuple74
73Operationoperator: 75
operand: 79
74Operationoperator: 77
operands: 78
75Literal
76ExprTuple79
77Literal
78ExprTuple80, 81
79Literal
80Variable
81Operationoperator: 82
operands: 83
82Literal
83ExprTuple84, 85
84Literal
85Literal