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 B, Conditional, Lambda, alpha, l, n
from proveit.core_expr_types import A_1_to_l, C_1_to_n
from proveit.linear_algebra import ScalarMult
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, Natural
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Lambda([alpha, l, n], Conditional(Forall(instance_param_or_params = [A_1_to_l, B, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, ScalarMult(alpha, B), C_1_to_n), Qmult(A_1_to_l, alpha, B, C_1_to_n)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l, B, C_1_to_n), QmultCodomain)), And(InSet(alpha, Complex), InSet(l, Natural), 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(\alpha, l, n\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}, B, C_{1}, C_{2}, \ldots, C_{n}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace B\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(\alpha \cdot B\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 \alpha \thinspace B\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \end{array}\right) \textrm{ if } \alpha \in \mathbb{C} ,  l \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
1ExprTuple44, 40, 43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameters: 33
body: 13
10Operationoperator: 16
operands: 14
11Operationoperator: 16
operands: 15
12Operationoperator: 16
operands: 17
13Conditionalvalue: 18
condition: 19
14ExprTuple44, 20
15ExprTuple40, 21
16Literal
17ExprTuple43, 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operands: 25
20Literal
21Literal
22Literal
23ExprTuple26, 27
24Literal
25ExprTuple28, 29
26Operationoperator: 32
operands: 30
27Operationoperator: 32
operands: 31
28Operationoperator: 32
operands: 33
29Literal
30ExprTuple35, 34, 36
31ExprTuple35, 44, 45, 36
32Literal
33ExprTuple35, 45, 36
34Operationoperator: 37
operands: 38
35ExprRangelambda_map: 39
start_index: 42
end_index: 40
36ExprRangelambda_map: 41
start_index: 42
end_index: 43
37Literal
38ExprTuple44, 45
39Lambdaparameter: 51
body: 46
40Variable
41Lambdaparameter: 51
body: 47
42Literal
43Variable
44Variable
45Variable
46IndexedVarvariable: 48
index: 51
47IndexedVarvariable: 49
index: 51
48Variable
49Variable
50ExprTuple51
51Variable