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, Mod, Mult, Neg, e, frac, i, pi, two
from proveit.physics.quantum.QPE import _m_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [k], instance_expr = Equals(Exp(e, Neg(frac(Mult(two, pi, i, k, Mod(m, _two_pow_t)), _two_pow_t))), 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(\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot \left(m ~\textup{mod}~ 2^{t}\right)}{2^{t}}} = \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\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: 45
body: 5
4ExprTuple45
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple45, 14
12Operationoperator: 50
operands: 15
13Operationoperator: 50
operands: 16
14Operationoperator: 17
operands: 18
15ExprTuple20, 19
16ExprTuple20, 21
17Literal
18ExprTuple22, 23
19Operationoperator: 34
operand: 28
20Literal
21Operationoperator: 34
operand: 29
22Literal
23Operationoperator: 26
operands: 27
24ExprTuple28
25ExprTuple29
26Literal
27ExprTuple49, 30
28Operationoperator: 32
operands: 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operand: 38
31ExprTuple36, 49
32Literal
33ExprTuple37, 49
34Literal
35ExprTuple38
36Operationoperator: 40
operands: 39
37Operationoperator: 40
operands: 41
38Literal
39ExprTuple52, 43, 44, 45, 42
40Literal
41ExprTuple52, 43, 44, 45, 48
42Operationoperator: 46
operands: 47
43Literal
44Literal
45Variable
46Literal
47ExprTuple48, 49
48Variable
49Operationoperator: 50
operands: 51
50Literal
51ExprTuple52, 53
52Literal
53Literal