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, NaturalPos, one
from proveit.physics.quantum import NumKet, ket0
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(k, Add(n, one)), TensorProd(ket0, 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 k \rangle_{n + 1} = \left(\lvert 0 \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: 46
body: 2
1ExprTuple46
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 16
operands: 7
5Literal
6ExprTuple8
7ExprTuple46, 9
8Lambdaparameter: 38
body: 11
9Literal
10ExprTuple38
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple38, 20
18Operationoperator: 33
operands: 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21ExprTuple38, 26
22Literal
23ExprTuple27, 28
24Literal
25ExprTuple37, 29
26Operationoperator: 35
operands: 30
27Operationoperator: 31
operand: 37
28Operationoperator: 33
operands: 34
29Operationoperator: 35
operands: 36
30ExprTuple46, 47
31Literal
32ExprTuple37
33Literal
34ExprTuple38, 46
35Literal
36ExprTuple39, 40
37Literal
38Variable
39Operationoperator: 41
operands: 42
40Operationoperator: 43
operand: 47
41Literal
42ExprTuple45, 46
43Literal
44ExprTuple47
45Literal
46Variable
47Literal