logo

Expression of type Lambda

from the theory of proveit.physics.quantum.QPE

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, Variable, t
from proveit.linear_algebra import MatrixExp, Unitary
from proveit.logic import InSet
from proveit.numbers import Add, Exp, Interval, Neg, one, two, zero
from proveit.physics.quantum.QPE import _U, _s
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(sub_expr1, Conditional(InSet(MatrixExp(_U, Exp(two, Neg(sub_expr1))), Unitary(Exp(two, _s))), InSet(sub_expr1, Interval(Add(Neg(t), one), zero))))
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\{U^{2^{-{_{-}a}}} \in \textrm{U}\left(2^{s}\right) \textrm{ if } {_{-}a} \in \{-t + 1~\ldotp \ldotp~0\}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 34
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 5
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple34, 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operand: 18
9Operationoperator: 14
operands: 15
10Literal
11ExprTuple16, 17
12Literal
13ExprTuple18
14Literal
15ExprTuple19, 20
16Literal
17Operationoperator: 22
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operands: 25
20Literal
21ExprTuple27, 26
22Literal
23ExprTuple27, 28
24Literal
25ExprTuple29, 30
26Operationoperator: 32
operand: 34
27Literal
28Literal
29Operationoperator: 32
operand: 35
30Literal
31ExprTuple34
32Literal
33ExprTuple35
34Variable
35Variable