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, Unitary
from proveit.logic import Equals, InSet
from proveit.numbers import sqrt
from proveit.physics.quantum import Qmult
In [2]:
# build up the expression from sub-expressions
expr = Lambda(U, Conditional(Equals(A, Qmult(U, sqrt(Qmult(Adj(A), A)))), InSet(U, Unitary(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())
U \mapsto \left\{A = \left(U \thinspace \sqrt{\left(A^{\dagger} \thinspace A\right)}\right) \textrm{ if } U \in \textrm{U}\left(n\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 14
body: 2
1ExprTuple14
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple30, 9
7Literal
8ExprTuple14, 10
9Operationoperator: 21
operands: 11
10Operationoperator: 12
operand: 16
11ExprTuple14, 15
12Literal
13ExprTuple16
14Variable
15Operationoperator: 17
operands: 18
16Variable
17Literal
18ExprTuple19, 20
19Operationoperator: 21
operands: 22
20Operationoperator: 23
operands: 24
21Literal
22ExprTuple25, 30
23Literal
24ExprTuple26, 27
25Operationoperator: 28
operand: 30
26Literal
27Literal
28Literal
29ExprTuple30
30Variable