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, M, m, n, x
from proveit.linear_algebra import MatrixMult, MatrixSpace
from proveit.logic import And, CartExp, Equals, Forall, InSet
from proveit.numbers import Complex, NaturalPos
from proveit.physics.quantum import Qmult
In [2]:
# build up the expression from sub-expressions
expr = Lambda([m, n], Conditional(Forall(instance_param_or_params = [M], instance_expr = Equals(Qmult(M), Lambda(x, Conditional(MatrixMult(M, x), InSet(x, CartExp(Complex, n))))), domain = MatrixSpace(field = Complex, rows = m, columns = n)), And(InSet(m, NaturalPos), InSet(n, 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())
\left(m, n\right) \mapsto \left\{\forall_{M \in \mathbb{C}^{m \times n}}~\left(\left[M\right] = \left[x \mapsto \left\{M \thinspace x \textrm{ if } x \in \mathbb{C}^{n}\right..\right]\right) \textrm{ if } 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
1ExprTuple32, 43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 37
body: 12
10Operationoperator: 35
operands: 13
11Operationoperator: 35
operands: 14
12Conditionalvalue: 15
condition: 16
13ExprTuple32, 17
14ExprTuple43, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 35
operands: 20
17Literal
18Literal
19ExprTuple21, 22
20ExprTuple37, 23
21Operationoperator: 24
operand: 37
22Lambdaparameter: 38
body: 27
23Operationoperator: 28
operands: 29
24Literal
25ExprTuple37
26ExprTuple38
27Conditionalvalue: 30
condition: 31
28Literal
29NamedExprsfield: 42
rows: 32
columns: 43
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Variable
33Literal
34ExprTuple37, 38
35Literal
36ExprTuple38, 39
37Variable
38Variable
39Operationoperator: 40
operands: 41
40Literal
41ExprTuple42, 43
42Literal
43Variable