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, t
from proveit.linear_algebra import Norm
from proveit.logic import And, CartExp, Equals, InSet
from proveit.numbers import Complex, NaturalPos, one
from proveit.physics.quantum.QPE import _psi_t_ket, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(t, Conditional(And(InSet(_psi_t_ket, CartExp(Complex, two_pow_t)), Equals(Norm(_psi_t_ket), one)), InSet(t, 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())
t \mapsto \left\{\left(\lvert \psi_{t} \rangle \in \mathbb{C}^{2^{t}}\right) \land \left(\left \|\lvert \psi_{t} \rangle\right \| = 1\right) \textrm{ if } t \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: 29
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 10
operands: 6
4Literal
5ExprTuple7, 8
6ExprTuple29, 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operands: 13
9Literal
10Literal
11ExprTuple23, 14
12Literal
13ExprTuple15, 16
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operand: 23
16Literal
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23
21Literal
22Operationoperator: 24
operands: 25
23Operationoperator: 26
operand: 29
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple29
28Literal
29Variable