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 Conditional, Lambda, k, n
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Add, Exp, NaturalPos, one, two
from proveit.physics.quantum import NumKet, ket1
from proveit.physics.quantum.algebra import n_bit_interval
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [k], instance_expr = Equals(NumKet(Add(Exp(two, n), k), Add(n, one)), TensorProd(ket1, NumKet(k, n))), domain = n_bit_interval), 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_{k \in \{0~\ldotp \ldotp~2^{n} - 1\}}~\left(\lvert 2^{n} + k \rangle_{n + 1} = \left(\lvert 1 \rangle {\otimes} \lvert k \rangle_{n}\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: 47
body: 2
1ExprTuple47
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 16
operands: 7
5Literal
6ExprTuple8
7ExprTuple47, 9
8Lambdaparameter: 39
body: 11
9Literal
10ExprTuple39
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple39, 20
18Operationoperator: 35
operands: 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21ExprTuple26, 27
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30, 31
26Operationoperator: 37
operands: 32
27Operationoperator: 37
operands: 33
28Operationoperator: 34
operand: 48
29Operationoperator: 35
operands: 36
30Literal
31Operationoperator: 37
operands: 38
32ExprTuple40, 39
33ExprTuple47, 48
34Literal
35Literal
36ExprTuple39, 47
37Literal
38ExprTuple40, 41
39Variable
40Operationoperator: 42
operands: 43
41Operationoperator: 44
operand: 48
42Literal
43ExprTuple46, 47
44Literal
45ExprTuple48
46Literal
47Variable
48Literal