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 Forall, InSet
from proveit.numbers import Complex, Exp, Mult, e, i, 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, _phase, _t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [k], instance_expr = InSet(Mult(Exp(e, Mult(two, pi, i, _phase, k)), Qmult(NumBra(m, _t), InverseFourierTransform(_t), NumKet(k, _t))), Complex), 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(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t}\right)\right) \in \mathbb{C}\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: 49
body: 5
4ExprTuple49
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple49, 13
11Operationoperator: 33
operands: 14
12Literal
13Operationoperator: 15
operands: 16
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Operationoperator: 41
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20Operationoperator: 24
operands: 25
21ExprTuple26, 27
22Literal
23ExprTuple28, 29, 30
24Literal
25ExprTuple31, 32
26Literal
27Operationoperator: 33
operands: 34
28Operationoperator: 35
operands: 36
29Operationoperator: 37
operand: 51
30Operationoperator: 39
operands: 40
31Operationoperator: 41
operands: 42
32Operationoperator: 43
operand: 52
33Literal
34ExprTuple50, 45, 46, 47, 49
35Literal
36ExprTuple48, 51
37Literal
38ExprTuple51
39Literal
40ExprTuple49, 51
41Literal
42ExprTuple50, 51
43Literal
44ExprTuple52
45Literal
46Literal
47Literal
48Variable
49Variable
50Literal
51Literal
52Literal