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 Conditional, Lambda, k, l
from proveit.core_expr_types.expr_arrays import A11_to_Akl, A11_to_Akl_varray, B11_to_Bkl, B11_to_Bkl_varray
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import NaturalPos
from proveit.physics.quantum.circuits import circuit_Akl, circuit_Bkl
In [2]:
# build up the expression from sub-expressions
expr = Lambda([k, l], Conditional(Forall(instance_param_or_params = [A11_to_Akl, B11_to_Bkl], instance_expr = Implies(Equals(A11_to_Akl_varray, B11_to_Bkl_varray), Equals(circuit_Akl, circuit_Bkl)).with_wrapping_at(2)).with_wrapping(), And(InSet(k, NaturalPos), InSet(l, 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(k, l\right) \mapsto \left\{\begin{array}{l}\forall_{A_{1, 1}, A_{1, 2}, \ldots, A_{1, l}, A_{2, 1}, A_{2, 2}, \ldots, A_{2, l}, \ldots\ldots, A_{k, 1}, A_{k, 2}, \ldots, A_{k, l}, B_{1, 1}, B_{1, 2}, \ldots, B_{1, l}, B_{2, 1}, B_{2, 2}, \ldots, B_{2, l}, \ldots\ldots, B_{k, 1}, B_{k, 2}, \ldots, B_{k, l}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(\begin{array}{cccc} 
 A_{1, 1} & A_{2, 1} & \cdots & A_{k, 1} \\
A_{1, 2} & A_{2, 2} & \cdots & A_{k, 2} \\
\vdots & \vdots & \ddots & \vdots \\
A_{1, l} & A_{2, l} & \cdots & A_{k, l} \\
\end{array}
\right) = \left(\begin{array}{cccc} 
 B_{1, 1} & B_{2, 1} & \cdots & B_{k, 1} \\
B_{1, 2} & B_{2, 2} & \cdots & B_{k, 2} \\
\vdots & \vdots & \ddots & \vdots \\
B_{1, l} & B_{2, l} & \cdots & B_{k, l} \\
\end{array}
\right)\right) \Rightarrow  \\ \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{A_{1, 1}} \qwx[1] & \gate{A_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 1}} \qwx[1] & \qw \\
& \gate{A_{1, 2}} \qwx[1] & \gate{A_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{A_{1, l}} & \gate{A_{2, l}} & \gate{\cdots} & \gate{A_{k, l}} & \qw
} \end{array}\right) = \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{B_{1, 1}} \qwx[1] & \gate{B_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{k, 1}} \qwx[1] & \qw \\
& \gate{B_{1, 2}} \qwx[1] & \gate{B_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{k, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{B_{1, l}} & \gate{B_{2, l}} & \gate{\cdots} & \gate{B_{k, l}} & \qw
} \end{array}\right)\right) \end{array} \end{array}\right)\end{array} \textrm{ if } k \in \mathbb{N}^+ ,  l \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
0Lambdaparameters: 1
body: 2
1ExprTuple38, 47
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple17, 18
13Operationoperator: 19
operands: 20
14ExprTuple38, 21
15Literal
16ExprTuple47, 21
17ExprRangelambda_map: 22
start_index: 46
end_index: 38
18ExprRangelambda_map: 23
start_index: 46
end_index: 38
19Literal
20ExprTuple24, 25
21Literal
22Lambdaparameter: 54
body: 42
23Lambdaparameter: 54
body: 43
24Operationoperator: 27
operands: 26
25Operationoperator: 27
operands: 28
26ExprTuple31, 33
27Literal
28ExprTuple29, 30
29Operationoperator: 32
operands: 31
30Operationoperator: 32
operands: 33
31ExprTuple34
32Literal
33ExprTuple35
34ExprRangelambda_map: 36
start_index: 46
end_index: 38
35ExprRangelambda_map: 37
start_index: 46
end_index: 38
36Lambdaparameter: 54
body: 39
37Lambdaparameter: 54
body: 41
38Variable
39ExprTuple42
40ExprTuple54
41ExprTuple43
42ExprRangelambda_map: 44
start_index: 46
end_index: 47
43ExprRangelambda_map: 45
start_index: 46
end_index: 47
44Lambdaparameter: 55
body: 48
45Lambdaparameter: 55
body: 50
46Literal
47Variable
48IndexedVarvariable: 51
indices: 53
49ExprTuple55
50IndexedVarvariable: 52
indices: 53
51Variable
52Variable
53ExprTuple54, 55
54Variable
55Variable