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, ExprTuple, Lambda
from proveit.core_expr_types import B_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Iff
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_compressed_outputAm, circuit_expanded_outputBm
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([A, B_1_to_m], Iff(QcircuitEquiv(circuit_compressed_outputAm, circuit_expanded_outputBm), Equals(A, TensorProd(B_1_to_m)))))
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(A, B_{1}, B_{2}, \ldots, B_{m}\right) \mapsto \left(\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qout{A}
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qout{B_{1}} \\
& \qout{B_{2}} \\
& \qout{\vdots} \\
& \qout{B_{m}}
} \end{array}\right)\right) \Leftrightarrow \left(A = \left(B_{1} {\otimes}  B_{2} {\otimes}  \ldots {\otimes}  B_{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
2ExprTuple42, 22
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple42, 14
12Operationoperator: 16
operand: 20
13Operationoperator: 16
operand: 21
14Operationoperator: 18
operands: 19
15ExprTuple20
16Literal
17ExprTuple21
18Literal
19ExprTuple22
20ExprTuple23
21ExprTuple24
22ExprRangelambda_map: 25
start_index: 43
end_index: 44
23ExprRangelambda_map: 26
start_index: 43
end_index: 44
24ExprRangelambda_map: 27
start_index: 43
end_index: 44
25Lambdaparameter: 45
body: 35
26Lambdaparameter: 45
body: 28
27Lambdaparameter: 45
body: 29
28Operationoperator: 30
operands: 31
29Operationoperator: 36
operands: 32
30Literal
31NamedExprselement: 33
targets: 34
32NamedExprsstate: 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35IndexedVarvariable: 40
index: 45
36Literal
37NamedExprsstate: 42
part: 45
38Literal
39ExprTuple43, 44
40Variable
41ExprTuple45
42Variable
43Literal
44Variable
45Variable