logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.circuits

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 A, Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, N, Variable, VertExprArray, m, n
from proveit.core_expr_types import A_1_to_m, n_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.logic import CartExp, Forall, InSet
from proveit.numbers import Add, Complex, Exp, Interval, Natural, NaturalPos, one, subtract, two
from proveit.physics.quantum.circuits import MultiQubitElem, N_0_to_m, N_m, Output, Qcircuit, QcircuitEquiv, each_Nk_is_partial_sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr3 = Variable("_c", latex_format = r"{_{-}c}")
expr = ExprTuple(Lambda(m, Conditional(Forall(instance_param_or_params = [n_1_to_m], instance_expr = Forall(instance_param_or_params = [A_1_to_m], instance_expr = Forall(instance_param_or_params = [N_0_to_m], instance_expr = QcircuitEquiv(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, ExprRange(sub_expr2, MultiQubitElem(element = Output(state = IndexedVar(A, sub_expr1), part = sub_expr2), targets = Interval(Add(IndexedVar(N, subtract(sub_expr1, one)), one), IndexedVar(N, sub_expr1))), one, IndexedVar(n, sub_expr1)).with_wrapping_at(2,6), one, m)])), Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr3, ExprRange(sub_expr1, MultiQubitElem(element = Output(state = TensorProd(A_1_to_m), part = sub_expr1), targets = Interval(one, N_m)), Add(IndexedVar(N, subtract(sub_expr3, one)), one), IndexedVar(N, sub_expr3)).with_wrapping_at(2,6), one, m)]))), domain = Natural, condition = each_Nk_is_partial_sum).with_wrapping(), domains = [ExprRange(sub_expr2, CartExp(Complex, Exp(two, IndexedVar(n, sub_expr2))), one, m)]).with_wrapping(), domain = NaturalPos).with_wrapping(), InSet(m, NaturalPos))))
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(m \mapsto \left\{\begin{array}{l}\forall_{n_{1}, n_{2}, \ldots, n_{m} \in \mathbb{N}^+}~\\
\left[\begin{array}{l}\forall_{\left(A_{1} \in \mathbb{C}^{2^{n_{1}}}\right), \left(A_{2} \in \mathbb{C}^{2^{n_{2}}}\right), \ldots, \left(A_{m} \in \mathbb{C}^{2^{n_{m}}}\right)}~\\
\left[\begin{array}{l}\forall_{N_{0}, N_{1}, \ldots, N_{m} \in \mathbb{N}~|~\left(N_{0} = 0\right)\land \left(N_{1} = \left(N_{1 - 1} + n_{1}\right)\right) \land  \left(N_{2} = \left(N_{2 - 1} + n_{2}\right)\right) \land  \ldots \land  \left(N_{m} = \left(N_{m - 1} + n_{m}\right)\right)}~\\
\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qout{A_{1}~\mbox{part}~1~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} \\
& \qout{A_{1}~\mbox{part}~2~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} \\
& \qout{\vdots} \\
& \qout{A_{1}~\mbox{part}~n_{1}~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} \\
& \qout{A_{2}~\mbox{part}~1~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} \\
& \qout{A_{2}~\mbox{part}~2~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} \\
& \qout{\vdots} \\
& \qout{A_{2}~\mbox{part}~n_{2}~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} \\
& \qout{\begin{array}{c}\vdots\\ \vdots\end{array}} \\
& \qout{A_{m}~\mbox{part}~1~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}} \\
& \qout{A_{m}~\mbox{part}~2~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}} \\
& \qout{\vdots} \\
& \qout{A_{m}~\mbox{part}~n_{m}~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}}
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1 - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1 - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{\vdots} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2 - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2 - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{\vdots} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{\begin{array}{c}\vdots\\ \vdots\end{array}} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} \\
& \qout{\vdots} \\
& \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}}
} \end{array}\right)\right)\end{array}\right]\end{array}\right]\end{array} \textrm{ if } m \in \mathbb{N}^+\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 133
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 23
operand: 7
4Operationoperator: 64
operands: 6
5ExprTuple7
6ExprTuple133, 29
7Lambdaparameters: 8
body: 9
8ExprTuple10
9Conditionalvalue: 11
condition: 12
10ExprRangelambda_map: 13
start_index: 145
end_index: 133
11Operationoperator: 23
operand: 16
12Operationoperator: 51
operands: 15
13Lambdaparameter: 142
body: 99
14ExprTuple16
15ExprTuple17
16Lambdaparameters: 125
body: 18
17ExprRangelambda_map: 19
start_index: 145
end_index: 133
18Conditionalvalue: 20
condition: 21
19Lambdaparameter: 142
body: 22
20Operationoperator: 23
operand: 27
21Operationoperator: 51
operands: 25
22Operationoperator: 64
operands: 26
23Literal
24ExprTuple27
25ExprTuple28
26ExprTuple99, 29
27Lambdaparameters: 30
body: 31
28ExprRangelambda_map: 32
start_index: 145
end_index: 133
29Literal
30ExprTuple33
31Conditionalvalue: 34
condition: 35
32Lambdaparameter: 142
body: 36
33ExprRangelambda_map: 37
start_index: 86
end_index: 133
34Operationoperator: 38
operands: 39
35Operationoperator: 51
operands: 40
36Operationoperator: 64
operands: 41
37Lambdaparameter: 142
body: 87
38Literal
39ExprTuple42, 43
40ExprTuple44, 45
41ExprTuple135, 46
42Operationoperator: 48
operand: 55
43Operationoperator: 48
operand: 56
44ExprRangelambda_map: 50
start_index: 86
end_index: 133
45Operationoperator: 51
operands: 52
46Operationoperator: 53
operands: 54
47ExprTuple55
48Literal
49ExprTuple56
50Lambdaparameter: 142
body: 57
51Literal
52ExprTuple58, 59
53Literal
54ExprTuple60, 61
55ExprTuple62
56ExprTuple63
57Operationoperator: 64
operands: 65
58Operationoperator: 79
operands: 66
59ExprRangelambda_map: 67
start_index: 145
end_index: 133
60Literal
61Operationoperator: 68
operands: 69
62ExprRangelambda_map: 70
start_index: 145
end_index: 133
63ExprRangelambda_map: 71
start_index: 145
end_index: 133
64Literal
65ExprTuple87, 72
66ExprTuple73, 86
67Lambdaparameter: 142
body: 74
68Literal
69ExprTuple75, 99
70Lambdaparameter: 140
body: 76
71Lambdaparameter: 127
body: 77
72Literal
73IndexedVarvariable: 130
index: 86
74Operationoperator: 79
operands: 80
75Literal
76ExprRangelambda_map: 81
start_index: 145
end_index: 82
77ExprRangelambda_map: 83
start_index: 84
end_index: 85
78ExprTuple86
79Literal
80ExprTuple87, 88
81Lambdaparameter: 142
body: 89
82IndexedVarvariable: 106
index: 140
83Lambdaparameter: 140
body: 90
84Operationoperator: 136
operands: 91
85IndexedVarvariable: 130
index: 127
86Literal
87IndexedVarvariable: 130
index: 142
88Operationoperator: 136
operands: 93
89Operationoperator: 95
operands: 94
90Operationoperator: 95
operands: 96
91ExprTuple97, 145
92ExprTuple127
93ExprTuple98, 99
94NamedExprselement: 100
targets: 101
95Literal
96NamedExprselement: 102
targets: 103
97IndexedVarvariable: 130
index: 113
98IndexedVarvariable: 130
index: 114
99IndexedVarvariable: 106
index: 142
100Operationoperator: 109
operands: 107
101Operationoperator: 111
operands: 108
102Operationoperator: 109
operands: 110
103Operationoperator: 111
operands: 112
104ExprTuple113
105ExprTuple114
106Variable
107NamedExprsstate: 115
part: 142
108ExprTuple116, 117
109Literal
110NamedExprsstate: 118
part: 140
111Literal
112ExprTuple145, 119
113Operationoperator: 136
operands: 120
114Operationoperator: 136
operands: 121
115IndexedVarvariable: 138
index: 140
116Operationoperator: 136
operands: 122
117IndexedVarvariable: 130
index: 140
118Operationoperator: 124
operands: 125
119IndexedVarvariable: 130
index: 133
120ExprTuple127, 141
121ExprTuple142, 141
122ExprTuple128, 145
123ExprTuple140
124Literal
125ExprTuple129
126ExprTuple133
127Variable
128IndexedVarvariable: 130
index: 134
129ExprRangelambda_map: 132
start_index: 145
end_index: 133
130Variable
131ExprTuple134
132Lambdaparameter: 142
body: 135
133Variable
134Operationoperator: 136
operands: 137
135IndexedVarvariable: 138
index: 142
136Literal
137ExprTuple140, 141
138Variable
139ExprTuple142
140Variable
141Operationoperator: 143
operand: 145
142Variable
143Literal
144ExprTuple145
145Literal