logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.QPE

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 ExprTuple
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd
from proveit.numbers import Exp, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, sqrt(two))
expr = ExprTuple(TensorProd(ScalarMult(sub_expr1, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(zero)), _phase)), ket1)))), ScalarMult(sub_expr1, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase)), ket1))))
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(\left[{\otimes}\right]\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right), \frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 6
2Operationoperator: 22
operands: 5
3Literal
4ExprTuple6
5ExprTuple10, 7
6Operationoperator: 22
operands: 8
7Operationoperator: 14
operands: 9
8ExprTuple10, 11
9ExprTuple18, 12
10Operationoperator: 29
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 22
operands: 16
13ExprTuple37, 17
14Literal
15ExprTuple18, 19
16ExprTuple20, 27
17Operationoperator: 44
operands: 21
18Operationoperator: 32
operand: 50
19Operationoperator: 22
operands: 23
20Operationoperator: 44
operands: 24
21ExprTuple46, 25
22Literal
23ExprTuple26, 27
24ExprTuple35, 28
25Operationoperator: 29
operands: 30
26Operationoperator: 44
operands: 31
27Operationoperator: 32
operand: 37
28Operationoperator: 38
operands: 34
29Literal
30ExprTuple37, 46
31ExprTuple35, 36
32Literal
33ExprTuple37
34ExprTuple46, 40, 41, 43
35Literal
36Operationoperator: 38
operands: 39
37Literal
38Literal
39ExprTuple46, 40, 41, 42, 43
40Literal
41Literal
42Operationoperator: 44
operands: 45
43Literal
44Literal
45ExprTuple46, 47
46Literal
47Operationoperator: 48
operand: 50
48Literal
49ExprTuple50
50Literal