# 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.
# 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, ket1

In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(two, n)
expr = Forall([n], Forall([k], Equals(RegisterKet(Add(k, sub_expr1), Add(n, one)), TensorProd(RegisterKet(k, n), ket1)), domain = Interval(zero, Add(sub_expr1, 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 + 2^{n} \rangle_{n + 1} = \left(\lvert k \rangle_{n} {\otimes} \lvert 1 \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: 47
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 16
operands: 8
6Literal
7ExprTuple9
8ExprTuple47, 10
9Lambdaparameter: 39
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple39, 20
18Operationoperator: 34
operands: 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21ExprTuple26, 27
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30, 31
26Operationoperator: 37
operands: 32
27Operationoperator: 37
operands: 33
28Operationoperator: 34
operands: 35
29Operationoperator: 36
operand: 48
30Literal
31Operationoperator: 37
operands: 38
32ExprTuple39, 40
33ExprTuple47, 48
34Literal
35ExprTuple39, 47
36Literal
37Literal
38ExprTuple40, 41
39Variable
40Operationoperator: 42
operands: 43
41Operationoperator: 44
operand: 48
42Literal
43ExprTuple46, 47
44Literal
45ExprTuple48
46Literal
47Variable
48Literal