logo

Expression of type Conditional

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, k, m
from proveit.logic import InSet
from proveit.numbers import Exp, Mult, Neg, e, frac, i, one, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Mult(Exp(e, Mult(two, pi, i, _phase, k)), Mult(frac(one, Exp(two, frac(_t, two))), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))))), InSet(k, _m_domain))
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\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 40
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple46, 8
6Operationoperator: 42
operands: 9
7Operationoperator: 40
operands: 10
8Operationoperator: 11
operands: 12
9ExprTuple25, 13
10ExprTuple14, 15
11Literal
12ExprTuple16, 17
13Operationoperator: 40
operands: 18
14Operationoperator: 36
operands: 19
15Operationoperator: 42
operands: 20
16Literal
17Operationoperator: 21
operands: 22
18ExprTuple48, 44, 45, 23, 46
19ExprTuple34, 24
20ExprTuple25, 26
21Literal
22ExprTuple39, 27
23Literal
24Operationoperator: 42
operands: 28
25Literal
26Operationoperator: 30
operand: 33
27Operationoperator: 30
operand: 34
28ExprTuple48, 32
29ExprTuple33
30Literal
31ExprTuple34
32Operationoperator: 36
operands: 35
33Operationoperator: 36
operands: 37
34Literal
35ExprTuple49, 48
36Literal
37ExprTuple38, 39
38Operationoperator: 40
operands: 41
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple48, 44, 45, 46, 47
42Literal
43ExprTuple48, 49
44Literal
45Literal
46Variable
47Variable
48Literal
49Literal