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, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, k))), 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}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \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: 32
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple38, 8
6Operationoperator: 34
operands: 9
7Operationoperator: 34
operands: 10
8Operationoperator: 11
operands: 12
9ExprTuple14, 13
10ExprTuple14, 15
11Literal
12ExprTuple16, 17
13Operationoperator: 27
operand: 22
14Literal
15Operationoperator: 32
operands: 19
16Literal
17Operationoperator: 20
operands: 21
18ExprTuple22
19ExprTuple40, 36, 37, 23, 38
20Literal
21ExprTuple30, 24
22Operationoperator: 25
operands: 26
23Literal
24Operationoperator: 27
operand: 31
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31Literal
32Literal
33ExprTuple40, 36, 37, 38, 39
34Literal
35ExprTuple40, 41
36Literal
37Literal
38Variable
39Variable
40Literal
41Literal