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, a, j
from proveit.core_expr_types import B_1_to_j
from proveit.linear_algebra import ScalarMult
from proveit.logic import Equals, Forall, InClass, InSet
from proveit.numbers import Complex, NaturalPos
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Qmult(B_1_to_j)
expr = Lambda(j, Conditional(Forall(instance_param_or_params = [a], instance_expr = Forall(instance_param_or_params = [B_1_to_j], instance_expr = Equals(Qmult(a, B_1_to_j), ScalarMult(a, sub_expr1)).with_wrapping_at(2), condition = InClass(sub_expr1, QmultCodomain)), domain = Complex), InSet(j, NaturalPos)))
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())
j \mapsto \left\{\forall_{a \in \mathbb{C}}~\left[\forall_{B_{1}, B_{2}, \ldots, B_{j}~|~\left(B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{j}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(a\thinspace B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{j}\right) =  \\ \left(a \cdot \left(B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{j}\right)\right) \end{array} \end{array}\right)\right] \textrm{ if } j \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
0Lambdaparameter: 39
body: 2
1ExprTuple39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 13
operand: 7
4Operationoperator: 15
operands: 6
5ExprTuple7
6ExprTuple39, 8
7Lambdaparameter: 32
body: 10
8Literal
9ExprTuple32
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 17
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17
15Literal
16ExprTuple32, 18
17Lambdaparameters: 35
body: 19
18Literal
19Conditionalvalue: 20
condition: 21
20Operationoperator: 22
operands: 23
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple26, 27
24Literal
25ExprTuple33, 28
26Operationoperator: 34
operands: 29
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32, 36
30Literal
31ExprTuple32, 33
32Variable
33Operationoperator: 34
operands: 35
34Literal
35ExprTuple36
36ExprRangelambda_map: 37
start_index: 38
end_index: 39
37Lambdaparameter: 43
body: 40
38Literal
39Variable
40IndexedVarvariable: 41
index: 43
41Variable
42ExprTuple43
43Variable