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, Neg, Sum, e, frac, i, one, pi, 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 = Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, 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} \left(\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\right)\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: 66
body: 5
4ExprTuple66
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 31
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple66, 13
11Operationoperator: 14
operand: 17
12Operationoperator: 59
operands: 16
13Literal
14Literal
15ExprTuple17
16ExprTuple18, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 52
operands: 22
19Operationoperator: 23
operand: 25
20Literal
21ExprTuple66, 57
22ExprTuple58, 57
23Literal
24ExprTuple25
25Lambdaparameter: 65
body: 27
26ExprTuple65
27Conditionalvalue: 28
condition: 29
28Operationoperator: 59
operands: 30
29Operationoperator: 31
operands: 32
30ExprTuple33, 34
31Literal
32ExprTuple65, 35
33Operationoperator: 61
operands: 36
34Operationoperator: 61
operands: 37
35Operationoperator: 38
operands: 39
36ExprTuple41, 40
37ExprTuple41, 42
38Literal
39ExprTuple43, 44
40Operationoperator: 54
operand: 49
41Literal
42Operationoperator: 59
operands: 46
43Literal
44Operationoperator: 47
operands: 48
45ExprTuple49
46ExprTuple67, 63, 64, 50, 65
47Literal
48ExprTuple57, 51
49Operationoperator: 52
operands: 53
50Literal
51Operationoperator: 54
operand: 58
52Literal
53ExprTuple56, 57
54Literal
55ExprTuple58
56Operationoperator: 59
operands: 60
57Operationoperator: 61
operands: 62
58Literal
59Literal
60ExprTuple67, 63, 64, 65, 66
61Literal
62ExprTuple67, 68
63Literal
64Literal
65Variable
66Variable
67Literal
68Literal