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, Neg, e, frac, i, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_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)), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_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 \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\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: 46
body: 5
4ExprTuple46
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple46, 13
11Operationoperator: 40
operands: 14
12Literal
13Operationoperator: 15
operands: 16
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Operationoperator: 42
operands: 21
18Operationoperator: 42
operands: 22
19Literal
20Operationoperator: 23
operands: 24
21ExprTuple26, 25
22ExprTuple26, 27
23Literal
24ExprTuple39, 28
25Operationoperator: 40
operands: 29
26Literal
27Operationoperator: 31
operand: 34
28Operationoperator: 31
operand: 35
29ExprTuple48, 44, 45, 33, 46
30ExprTuple34
31Literal
32ExprTuple35
33Literal
34Operationoperator: 36
operands: 37
35Literal
36Literal
37ExprTuple38, 39
38Operationoperator: 40
operands: 41
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple48, 44, 45, 46, 47
42Literal
43ExprTuple48, 49
44Literal
45Literal
46Variable
47Variable
48Literal
49Literal