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
from proveit.linear_algebra import TensorProd
from proveit.logic import And, InSet
from proveit.numbers import Add, Interval, Natural, one, subtract, zero
from proveit.physics.quantum.circuits import Input, MultiQubitElem, N_0_to_m, N_m, 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([N_0_to_m], Conditional(QcircuitEquiv(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, ExprRange(sub_expr2, MultiQubitElem(element = Input(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 = Input(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)]))), And(ExprRange(sub_expr2, InSet(IndexedVar(N, sub_expr2), Natural), zero, m), each_Nk_is_partial_sum))))
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(\left(N_{0}, N_{1}, \ldots, N_{m}\right) \mapsto \left\{\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{A_{1}~\mbox{part}~1~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} & \qw \\
\qin{A_{1}~\mbox{part}~2~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} & \qw \\
\qin{\vdots} & \qw \\
\qin{A_{1}~\mbox{part}~n_{1}~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} & \qw \\
\qin{A_{2}~\mbox{part}~1~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} & \qw \\
\qin{A_{2}~\mbox{part}~2~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} & \qw \\
\qin{\vdots} & \qw \\
\qin{A_{2}~\mbox{part}~n_{2}~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} & \qw \\
\qin{\begin{array}{c}\vdots\\ \vdots\end{array}} & \qw \\
\qin{A_{m}~\mbox{part}~1~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{A_{m}~\mbox{part}~2~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{\vdots} & \qw \\
\qin{A_{m}~\mbox{part}~n_{m}~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1 - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1 - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{\vdots} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2 - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2 - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{\vdots} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{\begin{array}{c}\vdots\\ \vdots\end{array}} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw \\
\qin{\vdots} & \qw \\
\qin{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} & \qw
} \end{array}\right) \textrm{ if } \left(N_{0} \in \mathbb{N}\right) ,  \left(N_{1} \in \mathbb{N}\right) ,  \ldots ,  \left(N_{m} \in \mathbb{N}\right) ,  \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)\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
1Lambdaparameters: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 47
end_index: 94
5Operationoperator: 8
operands: 9
6Operationoperator: 19
operands: 10
7Lambdaparameter: 103
body: 48
8Literal
9ExprTuple11, 12
10ExprTuple13, 14
11Operationoperator: 16
operand: 21
12Operationoperator: 16
operand: 22
13ExprRangelambda_map: 18
start_index: 47
end_index: 94
14Operationoperator: 19
operands: 20
15ExprTuple21
16Literal
17ExprTuple22
18Lambdaparameter: 103
body: 23
19Literal
20ExprTuple24, 25
21ExprTuple26
22ExprTuple27
23Operationoperator: 28
operands: 29
24Operationoperator: 40
operands: 30
25ExprRangelambda_map: 31
start_index: 106
end_index: 94
26ExprRangelambda_map: 32
start_index: 106
end_index: 94
27ExprRangelambda_map: 33
start_index: 106
end_index: 94
28Literal
29ExprTuple48, 34
30ExprTuple35, 47
31Lambdaparameter: 103
body: 36
32Lambdaparameter: 101
body: 37
33Lambdaparameter: 88
body: 38
34Literal
35IndexedVarvariable: 91
index: 47
36Operationoperator: 40
operands: 41
37ExprRangelambda_map: 42
start_index: 106
end_index: 43
38ExprRangelambda_map: 44
start_index: 45
end_index: 46
39ExprTuple47
40Literal
41ExprTuple48, 49
42Lambdaparameter: 103
body: 50
43IndexedVarvariable: 67
index: 101
44Lambdaparameter: 101
body: 51
45Operationoperator: 97
operands: 52
46IndexedVarvariable: 91
index: 88
47Literal
48IndexedVarvariable: 91
index: 103
49Operationoperator: 97
operands: 54
50Operationoperator: 56
operands: 55
51Operationoperator: 56
operands: 57
52ExprTuple58, 106
53ExprTuple88
54ExprTuple59, 60
55NamedExprselement: 61
targets: 62
56Literal
57NamedExprselement: 63
targets: 64
58IndexedVarvariable: 91
index: 74
59IndexedVarvariable: 91
index: 75
60IndexedVarvariable: 67
index: 103
61Operationoperator: 70
operands: 68
62Operationoperator: 72
operands: 69
63Operationoperator: 70
operands: 71
64Operationoperator: 72
operands: 73
65ExprTuple74
66ExprTuple75
67Variable
68NamedExprsstate: 76
part: 103
69ExprTuple77, 78
70Literal
71NamedExprsstate: 79
part: 101
72Literal
73ExprTuple106, 80
74Operationoperator: 97
operands: 81
75Operationoperator: 97
operands: 82
76IndexedVarvariable: 99
index: 101
77Operationoperator: 97
operands: 83
78IndexedVarvariable: 91
index: 101
79Operationoperator: 85
operands: 86
80IndexedVarvariable: 91
index: 94
81ExprTuple88, 102
82ExprTuple103, 102
83ExprTuple89, 106
84ExprTuple101
85Literal
86ExprTuple90
87ExprTuple94
88Variable
89IndexedVarvariable: 91
index: 95
90ExprRangelambda_map: 93
start_index: 106
end_index: 94
91Variable
92ExprTuple95
93Lambdaparameter: 103
body: 96
94Variable
95Operationoperator: 97
operands: 98
96IndexedVarvariable: 99
index: 103
97Literal
98ExprTuple101, 102
99Variable
100ExprTuple103
101Variable
102Operationoperator: 104
operand: 106
103Variable
104Literal
105ExprTuple106
106Literal