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, 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)))
expr = Forall(instance_param_or_params = [k], instance_expr = Equals(Mult(sub_expr1, sub_expr2, sub_expr3), Mult(sub_expr2, Mult(sub_expr1, sub_expr3))), 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 \frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right) = \left(\frac{1}{2^{\frac{t}{2}}} \cdot \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)\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: 56
body: 5
4ExprTuple56
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple56, 14
12Operationoperator: 50
operands: 15
13Operationoperator: 50
operands: 16
14Operationoperator: 17
operands: 18
15ExprTuple28, 19, 29
16ExprTuple19, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 46
operands: 23
20Operationoperator: 50
operands: 24
21Literal
22Operationoperator: 25
operands: 26
23ExprTuple39, 27
24ExprTuple28, 29
25Literal
26ExprTuple49, 30
27Operationoperator: 52
operands: 31
28Operationoperator: 52
operands: 32
29Operationoperator: 52
operands: 33
30Operationoperator: 42
operand: 39
31ExprTuple58, 35
32ExprTuple37, 36
33ExprTuple37, 38
34ExprTuple39
35Operationoperator: 46
operands: 40
36Operationoperator: 50
operands: 41
37Literal
38Operationoperator: 42
operand: 45
39Literal
40ExprTuple59, 58
41ExprTuple58, 54, 55, 44, 56
42Literal
43ExprTuple45
44Literal
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Operationoperator: 50
operands: 51
49Operationoperator: 52
operands: 53
50Literal
51ExprTuple58, 54, 55, 56, 57
52Literal
53ExprTuple58, 59
54Literal
55Literal
56Variable
57Variable
58Literal
59Literal