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 ExprRange, IndexedVar, Variable, a, c, k, m
from proveit.logic import Equals, Forall
from proveit.numbers import Complex, Exp, Mult, Neg, Sum, e, frac, i, one, pi, two, zero
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [k]
sub_expr3 = IndexedVar(a, one)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)
sub_expr5 = Mult(Exp(e, Mult(two, pi, i, _phase, k)), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))))
expr = Forall(instance_param_or_params = [sub_expr3, sub_expr4], instance_expr = Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr2, summand = sub_expr5, domain = _m_domain), sub_expr4), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr3, sub_expr5, sub_expr4), domain = _m_domain)).with_wrapping_at(2), domain = Complex).with_wrapping()
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())
\begin{array}{l}\forall_{a_{1}, c_{1}, c_{2}, \ldots, c_{0} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \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)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right) =  \\ \left(\sum_{k = 0}^{2^{t} - 1} \left(a_{1} \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)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right)\right) \end{array} \end{array}\right)\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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
3Lambdaparameters: 4
body: 5
4ExprTuple34, 36
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 72
operands: 16
13Operationoperator: 23
operand: 21
14Operationoperator: 37
operands: 18
15ExprRangelambda_map: 19
start_index: 69
end_index: 52
16ExprTuple34, 20, 36
17ExprTuple21
18ExprTuple34, 29
19Lambdaparameter: 57
body: 22
20Operationoperator: 23
operand: 27
21Lambdaparameter: 78
body: 25
22Operationoperator: 37
operands: 26
23Literal
24ExprTuple27
25Conditionalvalue: 28
condition: 33
26ExprTuple45, 29
27Lambdaparameter: 78
body: 31
28Operationoperator: 72
operands: 32
29Literal
30ExprTuple78
31Conditionalvalue: 35
condition: 33
32ExprTuple34, 35, 36
33Operationoperator: 37
operands: 38
34IndexedVarvariable: 39
index: 69
35Operationoperator: 72
operands: 40
36ExprRangelambda_map: 41
start_index: 69
end_index: 52
37Literal
38ExprTuple78, 42
39Variable
40ExprTuple43, 44
41Lambdaparameter: 57
body: 45
42Operationoperator: 46
operands: 47
43Operationoperator: 74
operands: 48
44Operationoperator: 74
operands: 49
45IndexedVarvariable: 50
index: 57
46Literal
47ExprTuple52, 53
48ExprTuple55, 54
49ExprTuple55, 56
50Variable
51ExprTuple57
52Literal
53Operationoperator: 58
operands: 59
54Operationoperator: 72
operands: 60
55Literal
56Operationoperator: 65
operand: 64
57Variable
58Literal
59ExprTuple71, 62
60ExprTuple80, 76, 77, 63, 78
61ExprTuple64
62Operationoperator: 65
operand: 69
63Literal
64Operationoperator: 67
operands: 68
65Literal
66ExprTuple69
67Literal
68ExprTuple70, 71
69Literal
70Operationoperator: 72
operands: 73
71Operationoperator: 74
operands: 75
72Literal
73ExprTuple80, 76, 77, 78, 79
74Literal
75ExprTuple80, 81
76Literal
77Literal
78Variable
79Variable
80Literal
81Literal