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, Conditional, Lambda, m
from proveit.core_expr_types import B_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall, Iff, InSet
from proveit.numbers import NaturalPos
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_compressed_inputAm, circuit_expanded_inputBm
In [2]:
# build up the expression from sub-expressions
expr = Lambda(m, Conditional(Forall(instance_param_or_params = [A, B_1_to_m], instance_expr = Iff(QcircuitEquiv(circuit_compressed_inputAm, circuit_expanded_inputBm), Equals(A, TensorProd(B_1_to_m)))), 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())
m \mapsto \left\{\forall_{A, B_{1}, B_{2}, \ldots, B_{m}}~\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) \textrm{ if } m \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 53
body: 2
1ExprTuple53
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple53, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple51, 31
12Operationoperator: 13
operands: 14
13Literal
14ExprTuple15, 16
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple51, 23
21Operationoperator: 25
operand: 29
22Operationoperator: 25
operand: 30
23Operationoperator: 27
operands: 28
24ExprTuple29
25Literal
26ExprTuple30
27Literal
28ExprTuple31
29ExprTuple32
30ExprTuple33
31ExprRangelambda_map: 34
start_index: 52
end_index: 53
32ExprRangelambda_map: 35
start_index: 52
end_index: 53
33ExprRangelambda_map: 36
start_index: 52
end_index: 53
34Lambdaparameter: 54
body: 44
35Lambdaparameter: 54
body: 37
36Lambdaparameter: 54
body: 38
37Operationoperator: 39
operands: 40
38Operationoperator: 45
operands: 41
39Literal
40NamedExprselement: 42
targets: 43
41NamedExprsstate: 44
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operands: 48
44IndexedVarvariable: 49
index: 54
45Literal
46NamedExprsstate: 51
part: 54
47Literal
48ExprTuple52, 53
49Variable
50ExprTuple54
51Variable
52Literal
53Variable
54Variable