logo

Expression of type Lambda

from the theory of proveit.physics.quantum.algebra

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, ExprRange, IndexedVar, Lambda, Variable, b, j
from proveit.core_expr_types import A_1_to_l, C_1_to_n, b_1_to_j
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, one
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([b_1_to_j], Conditional(Forall(instance_param_or_params = [A_1_to_l, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, b_1_to_j, C_1_to_n), Qmult(b_1_to_j, A_1_to_l, C_1_to_n)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l, C_1_to_n), QmultCodomain)), And(ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j))))
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(b_{1}, b_{2}, \ldots, b_{j}\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}, C_{1}, C_{2}, \ldots, C_{n}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \end{array}\right) \textrm{ if } \left(b_{1} \in \mathbb{C}\right) \land  \left(b_{2} \in \mathbb{C}\right) \land  \ldots \land  \left(b_{j} \in \mathbb{C}\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
1ExprTuple31
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10
9Lambdaparameters: 30
body: 11
10ExprRangelambda_map: 12
start_index: 39
end_index: 35
11Conditionalvalue: 13
condition: 14
12Lambdaparameter: 48
body: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operands: 21
16Literal
17ExprTuple22, 23
18Literal
19ExprTuple24, 25
20Literal
21ExprTuple41, 26
22Operationoperator: 29
operands: 27
23Operationoperator: 29
operands: 28
24Operationoperator: 29
operands: 30
25Literal
26Literal
27ExprTuple32, 31, 33
28ExprTuple31, 32, 33
29Literal
30ExprTuple32, 33
31ExprRangelambda_map: 34
start_index: 39
end_index: 35
32ExprRangelambda_map: 36
start_index: 39
end_index: 37
33ExprRangelambda_map: 38
start_index: 39
end_index: 40
34Lambdaparameter: 48
body: 41
35Variable
36Lambdaparameter: 48
body: 42
37Variable
38Lambdaparameter: 48
body: 43
39Literal
40Variable
41IndexedVarvariable: 44
index: 48
42IndexedVarvariable: 45
index: 48
43IndexedVarvariable: 46
index: 48
44Variable
45Variable
46Variable
47ExprTuple48
48Variable