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
from proveit.core_expr_types import A_1_to_l, B_1_to_m, C_1_to_n
from proveit.logic import Equals, InClass
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Qmult(A_1_to_l, B_1_to_m, C_1_to_n)
expr = Lambda([A_1_to_l, B_1_to_m, C_1_to_n], Conditional(Equals(Qmult(A_1_to_l, Qmult(B_1_to_m), C_1_to_n), sub_expr1).with_wrapping_at(2), InClass(sub_expr1, QmultCodomain)))
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_{1}, A_{2}, \ldots, A_{l}, B_{1}, B_{2}, \ldots, B_{m}, C_{1}, C_{2}, \ldots, C_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace \left(B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \end{array} \textrm{ if } \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 12
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple9, 10
8Operationoperator: 16
operands: 11
9Operationoperator: 16
operands: 12
10Literal
11ExprTuple14, 13, 15
12ExprTuple14, 22, 15
13Operationoperator: 16
operands: 17
14ExprRangelambda_map: 18
start_index: 26
end_index: 19
15ExprRangelambda_map: 20
start_index: 26
end_index: 21
16Literal
17ExprTuple22
18Lambdaparameter: 33
body: 23
19Variable
20Lambdaparameter: 33
body: 24
21Variable
22ExprRangelambda_map: 25
start_index: 26
end_index: 27
23IndexedVarvariable: 28
index: 33
24IndexedVarvariable: 29
index: 33
25Lambdaparameter: 33
body: 30
26Literal
27Variable
28Variable
29Variable
30IndexedVarvariable: 31
index: 33
31Variable
32ExprTuple33
33Variable