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, l, m, n
from proveit.core_expr_types import A_1_to_l, B_1_to_m, C_1_to_n
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Natural, NaturalPos
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([l, m, n], Conditional(Forall(instance_param_or_params = [A_1_to_l, B_1_to_m, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, Qmult(B_1_to_m), C_1_to_n), sub_expr1).with_wrapping_at(2), condition = InClass(sub_expr1, QmultCodomain)), And(InSet(l, Natural), InSet(m, NaturalPos), InSet(n, 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(l, m, n\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}, B_{1}, B_{2}, \ldots, B_{m}, C_{1}, C_{2}, \ldots, C_{n}~|~\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^*}}~\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}\right) \textrm{ if } l \in \mathbb{N} ,  m \in \mathbb{N}^+ ,  n \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
1ExprTuple37, 45, 39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameters: 30
body: 13
10Operationoperator: 16
operands: 14
11Operationoperator: 16
operands: 15
12Operationoperator: 16
operands: 17
13Conditionalvalue: 18
condition: 19
14ExprTuple37, 21
15ExprTuple45, 20
16Literal
17ExprTuple39, 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operands: 25
20Literal
21Literal
22Literal
23ExprTuple26, 27
24Literal
25ExprTuple27, 28
26Operationoperator: 34
operands: 29
27Operationoperator: 34
operands: 30
28Literal
29ExprTuple32, 31, 33
30ExprTuple32, 40, 33
31Operationoperator: 34
operands: 35
32ExprRangelambda_map: 36
start_index: 44
end_index: 37
33ExprRangelambda_map: 38
start_index: 44
end_index: 39
34Literal
35ExprTuple40
36Lambdaparameter: 51
body: 41
37Variable
38Lambdaparameter: 51
body: 42
39Variable
40ExprRangelambda_map: 43
start_index: 44
end_index: 45
41IndexedVarvariable: 46
index: 51
42IndexedVarvariable: 47
index: 51
43Lambdaparameter: 51
body: 48
44Literal
45Variable
46Variable
47Variable
48IndexedVarvariable: 49
index: 51
49Variable
50ExprTuple51
51Variable