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, ExprRange, IndexedVar, Lambda, Variable, a, k
from proveit.core_expr_types import a_1_to_k
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import BinarySequence, Bit, NaturalPos, one
from proveit.physics.quantum import Ket, NumKet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(k, Conditional(Forall(instance_param_or_params = [a_1_to_k], instance_expr = Equals(NumKet(BinarySequence(a_1_to_k), k), TensorProd(ExprRange(sub_expr1, Ket(IndexedVar(a, sub_expr1)), one, k))), domain = Bit), InSet(k, 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())
k \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{k} \in \mathbb{N}^{\leq 1}}~\left(\lvert \texttt{\#}\texttt{b}(a_{1}, a_{2}, \ldots, a_{k}) \rangle_{k} = \left(\lvert a_{1} \rangle {\otimes}  \lvert a_{2} \rangle {\otimes}  \ldots {\otimes}  \lvert a_{k} \rangle\right)\right) \textrm{ if } k \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: 38
body: 2
1ExprTuple38
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 31
operands: 7
5Literal
6ExprTuple8
7ExprTuple38, 9
8Lambdaparameters: 29
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19ExprRangelambda_map: 24
start_index: 37
end_index: 38
20Literal
21ExprTuple25, 38
22Literal
23ExprTuple26
24Lambdaparameter: 44
body: 27
25Operationoperator: 28
operands: 29
26ExprRangelambda_map: 30
start_index: 37
end_index: 38
27Operationoperator: 31
operands: 32
28Literal
29ExprTuple33
30Lambdaparameter: 44
body: 34
31Literal
32ExprTuple41, 35
33ExprRangelambda_map: 36
start_index: 37
end_index: 38
34Operationoperator: 39
operand: 41
35Literal
36Lambdaparameter: 44
body: 41
37Literal
38Variable
39Literal
40ExprTuple41
41IndexedVarvariable: 42
index: 44
42Variable
43ExprTuple44
44Variable