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, ExprTuple, Lambda, k, n
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, InSet
from proveit.numbers import Add, 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 = ExprTuple(Lambda(k, Conditional(Equals(NumKet(k, Add(n, one)), TensorProd(ket0, NumKet(k, n))), InSet(k, n_bit_interval))))
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\{\lvert k \rangle_{n + 1} = \left(\lvert 0 \rangle {\otimes} \lvert k \rangle_{n}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{n} - 1\}\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: 30
body: 3
2ExprTuple30
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple30, 12
10Operationoperator: 25
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple30, 18
14Literal
15ExprTuple19, 20
16Literal
17ExprTuple29, 21
18Operationoperator: 27
operands: 22
19Operationoperator: 23
operand: 29
20Operationoperator: 25
operands: 26
21Operationoperator: 27
operands: 28
22ExprTuple38, 39
23Literal
24ExprTuple29
25Literal
26ExprTuple30, 38
27Literal
28ExprTuple31, 32
29Literal
30Variable
31Operationoperator: 33
operands: 34
32Operationoperator: 35
operand: 39
33Literal
34ExprTuple37, 38
35Literal
36ExprTuple39
37Literal
38Variable
39Literal