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, Integer, Mult, Sum, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _alpha_m_mod_two_pow_t, _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [m], instance_expr = Equals(_alpha_m_mod_two_pow_t, Mult(frac(one, _two_pow_t), Sum(index_or_indices = [k], summand = Exp(Exp(e, Mult(two, pi, i, subtract(_phase, frac(m, _two_pow_t)))), k), domain = _m_domain))), domain = Integer)
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_{m \in \mathbb{Z}}~\left(\alpha_{m ~\textup{mod}~ 2^{t}} = \left(\frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\varphi - \frac{m}{2^{t}}\right)})^{k}\right)\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: 60
body: 5
4ExprTuple60
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 30
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple60, 13
11Operationoperator: 14
operand: 17
12Operationoperator: 42
operands: 16
13Literal
14Literal
15ExprTuple17
16ExprTuple18, 19
17Operationoperator: 20
operands: 59
18Operationoperator: 58
operands: 21
19Operationoperator: 22
operand: 24
20Literal
21ExprTuple54, 61
22Literal
23ExprTuple24
24Lambdaparameter: 33
body: 26
25ExprTuple33
26Conditionalvalue: 27
condition: 28
27Operationoperator: 62
operands: 29
28Operationoperator: 30
operands: 31
29ExprTuple32, 33
30Literal
31ExprTuple33, 34
32Operationoperator: 62
operands: 35
33Variable
34Operationoperator: 36
operands: 37
35ExprTuple38, 39
36Literal
37ExprTuple40, 41
38Literal
39Operationoperator: 42
operands: 43
40Literal
41Operationoperator: 49
operands: 44
42Literal
43ExprTuple64, 45, 46, 47
44ExprTuple61, 48
45Literal
46Literal
47Operationoperator: 49
operands: 50
48Operationoperator: 55
operand: 54
49Literal
50ExprTuple52, 53
51ExprTuple54
52Literal
53Operationoperator: 55
operand: 57
54Literal
55Literal
56ExprTuple57
57Operationoperator: 58
operands: 59
58Literal
59ExprTuple60, 61
60Variable
61Operationoperator: 62
operands: 63
62Literal
63ExprTuple64, 65
64Literal
65Literal