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 A, Conditional, Lambda, U, n
from proveit.linear_algebra import Adj, MatrixSpace, Unitary
from proveit.logic import Equals, Exists, InSet
from proveit.numbers import Complex, sqrt
from proveit.physics.quantum import Qmult
In [2]:
# build up the expression from sub-expressions
expr = Lambda(A, Conditional(Exists(instance_param_or_params = [U], instance_expr = Equals(A, Qmult(U, sqrt(Qmult(Adj(A), A)))), domain = Unitary(n)), InSet(A, MatrixSpace(field = Complex, rows = n, columns = n))))
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())
A \mapsto \left\{\exists_{U \in \textrm{U}\left(n\right)}~\left(A = \left(U \thinspace \sqrt{\left(A^{\dagger} \thinspace A\right)}\right)\right) \textrm{ if } A \in \mathbb{C}^{n \times 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: 41
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 18
operands: 6
4Literal
5ExprTuple7
6ExprTuple41, 8
7Lambdaparameter: 25
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple25
10Conditionalvalue: 13
condition: 14
11Literal
12NamedExprsfield: 15
rows: 27
columns: 27
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Literal
16Literal
17ExprTuple41, 20
18Literal
19ExprTuple25, 21
20Operationoperator: 32
operands: 22
21Operationoperator: 23
operand: 27
22ExprTuple25, 26
23Literal
24ExprTuple27
25Variable
26Operationoperator: 28
operands: 29
27Variable
28Literal
29ExprTuple30, 31
30Operationoperator: 32
operands: 33
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36, 41
34Literal
35ExprTuple37, 38
36Operationoperator: 39
operand: 41
37Literal
38Literal
39Literal
40ExprTuple41
41Variable