logo

Expression of type Forall

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 k, m
from proveit.logic import Equals, Forall
from proveit.numbers import Exp, Mult, Neg, e, frac, i, one, pi, two
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _m_domain, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [k], instance_expr = Equals(Qmult(NumBra(m, _t), InverseFourierTransform(_t), NumKet(k, _t)), Mult(frac(one, Exp(two, frac(_t, two))), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))))), domain = _m_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())
\forall_{k \in \{0~\ldotp \ldotp~2^{t} - 1\}}~\left(\left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t}\right) = \left(\frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 59
body: 5
4ExprTuple59
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple59, 14
12Operationoperator: 15
operands: 16
13Operationoperator: 53
operands: 17
14Operationoperator: 18
operands: 19
15Literal
16ExprTuple20, 21, 22
17ExprTuple23, 24
18Literal
19ExprTuple25, 26
20Operationoperator: 27
operands: 28
21Operationoperator: 29
operand: 62
22Operationoperator: 31
operands: 32
23Operationoperator: 49
operands: 33
24Operationoperator: 55
operands: 34
25Literal
26Operationoperator: 35
operands: 36
27Literal
28ExprTuple60, 62
29Literal
30ExprTuple62
31Literal
32ExprTuple59, 62
33ExprTuple47, 37
34ExprTuple38, 39
35Literal
36ExprTuple52, 40
37Operationoperator: 55
operands: 41
38Literal
39Operationoperator: 43
operand: 46
40Operationoperator: 43
operand: 47
41ExprTuple61, 45
42ExprTuple46
43Literal
44ExprTuple47
45Operationoperator: 49
operands: 48
46Operationoperator: 49
operands: 50
47Literal
48ExprTuple62, 61
49Literal
50ExprTuple51, 52
51Operationoperator: 53
operands: 54
52Operationoperator: 55
operands: 56
53Literal
54ExprTuple61, 57, 58, 59, 60
55Literal
56ExprTuple61, 62
57Literal
58Literal
59Variable
60Variable
61Literal
62Literal