logo

Expression of type Lambda

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, 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_inputAm, circuit_expanded_inputBm
In [2]:
# build up the expression from sub-expressions
expr = Lambda([A, B_1_to_m], Iff(QcircuitEquiv(circuit_compressed_inputAm, circuit_expanded_inputBm), 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(A, B_{1}, B_{2}, \ldots, B_{m}\right) \mapsto \left(\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{A} & { /^{m} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{B_{1}} & \qw \\
\qin{B_{2}} & \qw \\
\qin{\vdots} & \qw \\
\qin{B_{m}} & \qw
} \end{array}\right)\right) \Leftrightarrow \left(A = \left(B_{1} {\otimes}  B_{2} {\otimes}  \ldots {\otimes}  B_{m}\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
0Lambdaparameters: 1
body: 2
1ExprTuple41, 21
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple41, 13
11Operationoperator: 15
operand: 19
12Operationoperator: 15
operand: 20
13Operationoperator: 17
operands: 18
14ExprTuple19
15Literal
16ExprTuple20
17Literal
18ExprTuple21
19ExprTuple22
20ExprTuple23
21ExprRangelambda_map: 24
start_index: 42
end_index: 43
22ExprRangelambda_map: 25
start_index: 42
end_index: 43
23ExprRangelambda_map: 26
start_index: 42
end_index: 43
24Lambdaparameter: 44
body: 34
25Lambdaparameter: 44
body: 27
26Lambdaparameter: 44
body: 28
27Operationoperator: 29
operands: 30
28Operationoperator: 35
operands: 31
29Literal
30NamedExprselement: 32
targets: 33
31NamedExprsstate: 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34IndexedVarvariable: 39
index: 44
35Literal
36NamedExprsstate: 41
part: 44
37Literal
38ExprTuple42, 43
39Variable
40ExprTuple44
41Variable
42Literal
43Variable
44Variable