logo

Expression of type ExprTuple

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, ExprTuple, IndexedVar, Variable, a, c, k, m
from proveit.logic import Equals, Forall, InSet
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 = ExprTuple(Forall(instance_param_or_params = sub_expr2, instance_expr = InSet(sub_expr5, Complex), domain = _m_domain), 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())
\left(\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), \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}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 4
operand: 6
2Operationoperator: 4
operand: 7
3ExprTuple6
4Literal
5ExprTuple7
6Lambdaparameter: 85
body: 8
7Lambdaparameters: 9
body: 10
8Conditionalvalue: 11
condition: 40
9ExprTuple41, 43
10Conditionalvalue: 12
condition: 13
11Operationoperator: 44
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple42, 36
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 79
operands: 23
20Operationoperator: 30
operand: 28
21Operationoperator: 44
operands: 25
22ExprRangelambda_map: 26
start_index: 76
end_index: 59
23ExprTuple41, 27, 43
24ExprTuple28
25ExprTuple41, 36
26Lambdaparameter: 64
body: 29
27Operationoperator: 30
operand: 34
28Lambdaparameter: 85
body: 32
29Operationoperator: 44
operands: 33
30Literal
31ExprTuple34
32Conditionalvalue: 35
condition: 40
33ExprTuple52, 36
34Lambdaparameter: 85
body: 38
35Operationoperator: 79
operands: 39
36Literal
37ExprTuple85
38Conditionalvalue: 42
condition: 40
39ExprTuple41, 42, 43
40Operationoperator: 44
operands: 45
41IndexedVarvariable: 46
index: 76
42Operationoperator: 79
operands: 47
43ExprRangelambda_map: 48
start_index: 76
end_index: 59
44Literal
45ExprTuple85, 49
46Variable
47ExprTuple50, 51
48Lambdaparameter: 64
body: 52
49Operationoperator: 53
operands: 54
50Operationoperator: 81
operands: 55
51Operationoperator: 81
operands: 56
52IndexedVarvariable: 57
index: 64
53Literal
54ExprTuple59, 60
55ExprTuple62, 61
56ExprTuple62, 63
57Variable
58ExprTuple64
59Literal
60Operationoperator: 65
operands: 66
61Operationoperator: 79
operands: 67
62Literal
63Operationoperator: 72
operand: 71
64Variable
65Literal
66ExprTuple78, 69
67ExprTuple87, 83, 84, 70, 85
68ExprTuple71
69Operationoperator: 72
operand: 76
70Literal
71Operationoperator: 74
operands: 75
72Literal
73ExprTuple76
74Literal
75ExprTuple77, 78
76Literal
77Operationoperator: 79
operands: 80
78Operationoperator: 81
operands: 82
79Literal
80ExprTuple87, 83, 84, 85, 86
81Literal
82ExprTuple87, 88
83Literal
84Literal
85Variable
86Variable
87Literal
88Literal