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, C_1_to_n, b_1_to_j
from proveit.logic import Equals, InClass
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Lambda([A_1_to_l, C_1_to_n], Conditional(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), InClass(Qmult(A_1_to_l, C_1_to_n), 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}, 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 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} \textrm{ if } \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^*}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 15
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 14
operands: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11Literal
12ExprTuple17, 16, 18
13ExprTuple16, 17, 18
14Literal
15ExprTuple17, 18
16ExprRangelambda_map: 19
start_index: 24
end_index: 20
17ExprRangelambda_map: 21
start_index: 24
end_index: 22
18ExprRangelambda_map: 23
start_index: 24
end_index: 25
19Lambdaparameter: 33
body: 26
20Variable
21Lambdaparameter: 33
body: 27
22Variable
23Lambdaparameter: 33
body: 28
24Literal
25Variable
26IndexedVarvariable: 29
index: 33
27IndexedVarvariable: 30
index: 33
28IndexedVarvariable: 31
index: 33
29Variable
30Variable
31Variable
32ExprTuple33
33Variable