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 Conditional, ExprTuple, Lambda, k
from proveit.logic import Equals, InSet
from proveit.numbers import Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr2 = Exp(e, Mult(two, pi, i, _phase, two_pow_t))
expr = ExprTuple(Lambda(k, Conditional(Equals(Mult(sub_expr1, sub_expr2), Mult(sub_expr2, sub_expr1)), InSet(k, Interval(zero, subtract(two_pow_t, one))))))
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(k \mapsto \left\{\left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}}\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\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: 38
body: 3
2ExprTuple38
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple38, 12
10Operationoperator: 30
operands: 13
11Operationoperator: 30
operands: 14
12Operationoperator: 15
operands: 16
13ExprTuple18, 17
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Operationoperator: 40
operands: 21
18Operationoperator: 40
operands: 22
19Literal
20Operationoperator: 23
operands: 24
21ExprTuple26, 25
22ExprTuple26, 27
23Literal
24ExprTuple34, 28
25Operationoperator: 30
operands: 29
26Literal
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operand: 39
29ExprTuple42, 35, 36, 37, 34
30Literal
31ExprTuple42, 35, 36, 37, 38
32Literal
33ExprTuple39
34Operationoperator: 40
operands: 41
35Literal
36Literal
37Literal
38Variable
39Literal
40Literal
41ExprTuple42, 43
42Literal
43Variable