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 Equals, InSet
from proveit.numbers import Exp, Mod, Mult, Neg, e, frac, i, pi, two
from proveit.physics.quantum.QPE import _m_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Equals(Exp(e, Neg(frac(Mult(two, pi, i, k, Mod(m, _two_pow_t)), _two_pow_t))), 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}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot \left(m ~\textup{mod}~ 2^{t}\right)}{2^{t}}} = \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \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: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple40, 9
7Operationoperator: 45
operands: 10
8Operationoperator: 45
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple15, 14
11ExprTuple15, 16
12Literal
13ExprTuple17, 18
14Operationoperator: 29
operand: 23
15Literal
16Operationoperator: 29
operand: 24
17Literal
18Operationoperator: 21
operands: 22
19ExprTuple23
20ExprTuple24
21Literal
22ExprTuple44, 25
23Operationoperator: 27
operands: 26
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operand: 33
26ExprTuple31, 44
27Literal
28ExprTuple32, 44
29Literal
30ExprTuple33
31Operationoperator: 35
operands: 34
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple47, 38, 39, 40, 37
35Literal
36ExprTuple47, 38, 39, 40, 43
37Operationoperator: 41
operands: 42
38Literal
39Literal
40Variable
41Literal
42ExprTuple43, 44
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Literal
48Literal