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, Forall, InSet
from proveit.numbers import Add, Exp, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [k], instance_expr = Equals(NumKet(Add(Exp(two, n), k), Add(n, one)), TensorProd(ket1, 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())
\left(n \mapsto \left\{\forall_{k \in \{0~\ldotp \ldotp~2^{n} - 1\}}~\left(\lvert 2^{n} + k \rangle_{n + 1} = \left(\lvert 1 \rangle {\otimes} \lvert k \rangle_{n}\right)\right) \textrm{ if } n \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: 48
body: 3
2ExprTuple48
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 17
operands: 8
6Literal
7ExprTuple9
8ExprTuple48, 10
9Lambdaparameter: 40
body: 12
10Literal
11ExprTuple40
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple40, 21
19Operationoperator: 36
operands: 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22ExprTuple27, 28
23Literal
24ExprTuple29, 30
25Literal
26ExprTuple31, 32
27Operationoperator: 38
operands: 33
28Operationoperator: 38
operands: 34
29Operationoperator: 35
operand: 49
30Operationoperator: 36
operands: 37
31Literal
32Operationoperator: 38
operands: 39
33ExprTuple41, 40
34ExprTuple48, 49
35Literal
36Literal
37ExprTuple40, 48
38Literal
39ExprTuple41, 42
40Variable
41Operationoperator: 43
operands: 44
42Operationoperator: 45
operand: 49
43Literal
44ExprTuple47, 48
45Literal
46ExprTuple49
47Literal
48Variable
49Literal