logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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())
\left(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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 39
body: 3
2ExprTuple39
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 32
operands: 8
6Literal
7ExprTuple9
8ExprTuple39, 10
9Lambdaparameters: 30
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20ExprRangelambda_map: 25
start_index: 38
end_index: 39
21Literal
22ExprTuple26, 39
23Literal
24ExprTuple27
25Lambdaparameter: 45
body: 28
26Operationoperator: 29
operands: 30
27ExprRangelambda_map: 31
start_index: 38
end_index: 39
28Operationoperator: 32
operands: 33
29Literal
30ExprTuple34
31Lambdaparameter: 45
body: 35
32Literal
33ExprTuple42, 36
34ExprRangelambda_map: 37
start_index: 38
end_index: 39
35Operationoperator: 40
operand: 42
36Literal
37Lambdaparameter: 45
body: 42
38Literal
39Variable
40Literal
41ExprTuple42
42IndexedVarvariable: 43
index: 45
43Variable
44ExprTuple45
45Variable