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, Q, f, j, m, n
from proveit.core_expr_types import A_1_to_m, C_1_to_n, Q__b_1_to_j, b_1_to_j, f__b_1_to_j
from proveit.linear_algebra import VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import And, Equals, Forall, Implies, 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_m, vec_summation_b1toj_fQ, C_1_to_n)
expr = Lambda([j, m, n], Conditional(Forall(instance_param_or_params = [A_1_to_m, C_1_to_n, f, Q], instance_expr = Implies(InClass(sub_expr1, QmultCodomain), Equals(sub_expr1, VecSum(index_or_indices = [b_1_to_j], summand = Qmult(A_1_to_m, f__b_1_to_j, C_1_to_n), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2)), And(InSet(j, NaturalPos), InSet(m, 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(j, m, n\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{m}, C_{1}, C_{2}, \ldots, C_{n}, f, Q}~\left(\begin{array}{c} \begin{array}{l} \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right) \textrm{ if } j \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
1ExprTuple61, 50, 54
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 17
operands: 15
11Operationoperator: 17
operands: 16
12Operationoperator: 17
operands: 18
13ExprTuple45, 47, 51, 48
14Operationoperator: 19
operands: 20
15ExprTuple61, 21
16ExprTuple50, 22
17Literal
18ExprTuple54, 22
19Literal
20ExprTuple23, 24
21Literal
22Literal
23Operationoperator: 25
operands: 26
24Operationoperator: 27
operands: 28
25Literal
26ExprTuple30, 29
27Literal
28ExprTuple30, 31
29Literal
30Operationoperator: 42
operands: 32
31Operationoperator: 36
operand: 35
32ExprTuple45, 34, 47
33ExprTuple35
34Operationoperator: 36
operand: 39
35Lambdaparameters: 52
body: 38
36Literal
37ExprTuple39
38Conditionalvalue: 40
condition: 44
39Lambdaparameters: 52
body: 41
40Operationoperator: 42
operands: 43
41Conditionalvalue: 46
condition: 44
42Literal
43ExprTuple45, 46, 47
44Operationoperator: 48
operands: 52
45ExprRangelambda_map: 49
start_index: 60
end_index: 50
46Operationoperator: 51
operands: 52
47ExprRangelambda_map: 53
start_index: 60
end_index: 54
48Variable
49Lambdaparameter: 66
body: 55
50Variable
51Variable
52ExprTuple56
53Lambdaparameter: 66
body: 57
54Variable
55IndexedVarvariable: 58
index: 66
56ExprRangelambda_map: 59
start_index: 60
end_index: 61
57IndexedVarvariable: 62
index: 66
58Variable
59Lambdaparameter: 66
body: 63
60Literal
61Variable
62Variable
63IndexedVarvariable: 64
index: 66
64Variable
65ExprTuple66
66Variable