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, Lambda, j, l
from proveit.core_expr_types import A_1_to_l, b_1_to_j
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, Mult, Natural, NaturalPos
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Lambda([j, l], Conditional(Forall(instance_param_or_params = [b_1_to_j], instance_expr = Forall(instance_param_or_params = [A_1_to_l], instance_expr = Equals(Qmult(b_1_to_j, A_1_to_l), Qmult(Mult(b_1_to_j), A_1_to_l)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l), QmultCodomain)), domain = Complex), And(InSet(j, NaturalPos), InSet(l, Natural))))
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(j, l\right) \mapsto \left\{\forall_{b_{1}, b_{2}, \ldots, b_{j} \in \mathbb{C}}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{l}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) =  \\ \left(\left(b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \end{array} \end{array}\right)\right] \textrm{ if } j \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
1ExprTuple53, 48
2Conditionalvalue: 3
condition: 4
3Operationoperator: 17
operand: 7
4Operationoperator: 19
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 46
body: 10
8Operationoperator: 32
operands: 11
9Operationoperator: 32
operands: 12
10Conditionalvalue: 13
condition: 14
11ExprTuple53, 15
12ExprTuple48, 16
13Operationoperator: 17
operand: 21
14Operationoperator: 19
operands: 20
15Literal
16Literal
17Literal
18ExprTuple21
19Literal
20ExprTuple22
21Lambdaparameters: 42
body: 23
22ExprRangelambda_map: 24
start_index: 52
end_index: 53
23Conditionalvalue: 25
condition: 26
24Lambdaparameter: 58
body: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28Literal
29ExprTuple34, 35
30Literal
31ExprTuple36, 37
32Literal
33ExprTuple55, 38
34Operationoperator: 41
operands: 39
35Operationoperator: 41
operands: 40
36Operationoperator: 41
operands: 42
37Literal
38Literal
39ExprTuple49, 44
40ExprTuple43, 44
41Literal
42ExprTuple44
43Operationoperator: 45
operands: 46
44ExprRangelambda_map: 47
start_index: 52
end_index: 48
45Literal
46ExprTuple49
47Lambdaparameter: 58
body: 50
48Variable
49ExprRangelambda_map: 51
start_index: 52
end_index: 53
50IndexedVarvariable: 54
index: 58
51Lambdaparameter: 58
body: 55
52Literal
53Variable
54Variable
55IndexedVarvariable: 56
index: 58
56Variable
57ExprTuple58
58Variable