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