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, Exp, 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 = ExprTuple(Lambda(k, Conditional(Equals(NumKet(Add(Exp(two, n), k), Add(n, one)), TensorProd(ket1, 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 2^{n} + k \rangle_{n + 1} = \left(\lvert 1 \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: 31
body: 3
2ExprTuple31
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple31, 12
10Operationoperator: 27
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple18, 19
14Literal
15ExprTuple20, 21
16Literal
17ExprTuple22, 23
18Operationoperator: 29
operands: 24
19Operationoperator: 29
operands: 25
20Operationoperator: 26
operand: 40
21Operationoperator: 27
operands: 28
22Literal
23Operationoperator: 29
operands: 30
24ExprTuple32, 31
25ExprTuple39, 40
26Literal
27Literal
28ExprTuple31, 39
29Literal
30ExprTuple32, 33
31Variable
32Operationoperator: 34
operands: 35
33Operationoperator: 36
operand: 40
34Literal
35ExprTuple38, 39
36Literal
37ExprTuple40
38Literal
39Variable
40Literal