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, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [k], instance_expr = Equals(NumKet(k, Add(n, one)), TensorProd(ket0, 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 k \rangle_{n + 1} = \left(\lvert 0 \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: 47
body: 3
2ExprTuple47
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 17
operands: 8
6Literal
7ExprTuple9
8ExprTuple47, 10
9Lambdaparameter: 39
body: 12
10Literal
11ExprTuple39
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple39, 21
19Operationoperator: 34
operands: 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22ExprTuple39, 27
23Literal
24ExprTuple28, 29
25Literal
26ExprTuple38, 30
27Operationoperator: 36
operands: 31
28Operationoperator: 32
operand: 38
29Operationoperator: 34
operands: 35
30Operationoperator: 36
operands: 37
31ExprTuple47, 48
32Literal
33ExprTuple38
34Literal
35ExprTuple39, 47
36Literal
37ExprTuple40, 41
38Literal
39Variable
40Operationoperator: 42
operands: 43
41Operationoperator: 44
operand: 48
42Literal
43ExprTuple46, 47
44Literal
45ExprTuple48
46Literal
47Variable
48Literal