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 Conditional, k, m
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Exp, Mult, Neg, e, frac, i, one, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr2 = frac(one, Exp(two, frac(_t, two)))
sub_expr3 = Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))
sub_expr4 = InSet(k, _m_domain)
expr = Forall(instance_param_or_params = [k], instance_expr = Equals(Conditional(Mult(sub_expr1, Mult(sub_expr2, sub_expr3)), sub_expr4), Conditional(Mult(sub_expr1, sub_expr2, sub_expr3), sub_expr4)))
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}~\left(\left\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right.. = \left\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\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: 57
body: 5
4ExprTuple57
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Conditionalvalue: 10
condition: 12
9Conditionalvalue: 11
condition: 12
10Operationoperator: 51
operands: 13
11Operationoperator: 51
operands: 14
12Operationoperator: 15
operands: 16
13ExprTuple18, 17
14ExprTuple18, 24, 25
15Literal
16ExprTuple57, 19
17Operationoperator: 51
operands: 20
18Operationoperator: 53
operands: 21
19Operationoperator: 22
operands: 23
20ExprTuple24, 25
21ExprTuple35, 26
22Literal
23ExprTuple27, 28
24Operationoperator: 47
operands: 29
25Operationoperator: 53
operands: 30
26Operationoperator: 51
operands: 31
27Literal
28Operationoperator: 32
operands: 33
29ExprTuple45, 34
30ExprTuple35, 36
31ExprTuple59, 55, 56, 37, 57
32Literal
33ExprTuple50, 38
34Operationoperator: 53
operands: 39
35Literal
36Operationoperator: 41
operand: 44
37Literal
38Operationoperator: 41
operand: 45
39ExprTuple59, 43
40ExprTuple44
41Literal
42ExprTuple45
43Operationoperator: 47
operands: 46
44Operationoperator: 47
operands: 48
45Literal
46ExprTuple60, 59
47Literal
48ExprTuple49, 50
49Operationoperator: 51
operands: 52
50Operationoperator: 53
operands: 54
51Literal
52ExprTuple59, 55, 56, 57, 58
53Literal
54ExprTuple59, 60
55Literal
56Literal
57Variable
58Variable
59Literal
60Literal