# from the theory of proveit.physics.quantum¶

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 k, n
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Exp, Interval, NaturalPos, Neg, one, two, zero
from proveit.physics.quantum import RegisterKet, ket0

In [2]:
# build up the expression from sub-expressions
expr = Forall([n], Forall([k], Equals(RegisterKet(k, Add(n, one)), TensorProd(RegisterKet(k, n), ket0)), domain = Interval(zero, Add(Exp(two, n), Neg(one)))), domain = NaturalPos)

Out[2]:
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(expr.latex())

\forall_{n \in \mathbb{N}^+}~\left[\forall_{k \in \{0~\ldotp \ldotp~2^{n} - 1\}}~\left(\lvert k \rangle_{n + 1} = \left(\lvert k \rangle_{n} {\otimes} \lvert 0 \rangle\right)\right)\right]

In [5]:
expr.style_options()

Out[5]:
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
expr.expr_info()

Out[6]:
core typesub-expressionsexpression
0Operationoperator: 6
operand: 2
1ExprTuple2
2Lambdaparameter: 46
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 16
operands: 8
6Literal
7ExprTuple9
8ExprTuple46, 10
9Lambdaparameter: 37
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple37, 20
18Operationoperator: 31
operands: 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21ExprTuple37, 26
22Literal
23ExprTuple27, 28
24Literal
25ExprTuple38, 29
26Operationoperator: 35
operands: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 33
operand: 38
29Operationoperator: 35
operands: 36
30ExprTuple46, 47
31Literal
32ExprTuple37, 46
33Literal
34ExprTuple38
35Literal
36ExprTuple39, 40
37Variable
38Literal
39Operationoperator: 41
operands: 42
40Operationoperator: 43
operand: 47
41Literal
42ExprTuple45, 46
43Literal
44ExprTuple47
45Literal
46Variable
47Literal