logo

Expression of type Lambda

from the theory of proveit.physics.quantum.circuits

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 IndexedVar, Lambda, U, Variable
from proveit.linear_algebra import MatrixMult, ScalarMult
from proveit.logic import Equals
from proveit.numbers import Exp, Mult, e, i, pi, two
from proveit.physics.quantum import var_ket_u, varphi
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(sub_expr1, Equals(MatrixMult(IndexedVar(U, sub_expr1), var_ket_u), ScalarMult(Exp(e, Mult(two, pi, i, IndexedVar(varphi, sub_expr1))), var_ket_u)))
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(\left(U_{{_{-}a}} \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi_{{_{-}a}}} \cdot \lvert u \rangle\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: 26
body: 1
1Operationoperator: 2
operands: 3
2Literal
3ExprTuple4, 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 12
8Literal
9ExprTuple11, 12
10IndexedVarvariable: 13
index: 26
11Operationoperator: 14
operands: 15
12Variable
13Variable
14Literal
15ExprTuple16, 17
16Literal
17Operationoperator: 18
operands: 19
18Literal
19ExprTuple20, 21, 22, 23
20Literal
21Literal
22Literal
23IndexedVarvariable: 24
index: 26
24Variable
25ExprTuple26
26Variable