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, Integer, Mult, Sum, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _alpha_m_mod_two_pow_t, _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Equals(_alpha_m_mod_two_pow_t, Mult(frac(one, _two_pow_t), Sum(index_or_indices = [k], summand = Exp(Exp(e, Mult(two, pi, i, subtract(_phase, frac(m, _two_pow_t)))), k), domain = _m_domain))), InSet(m, Integer))
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\{\alpha_{m ~\textup{mod}~ 2^{t}} = \left(\frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\varphi - \frac{m}{2^{t}}\right)})^{k}\right)\right) \textrm{ if } m \in \mathbb{Z}\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: 25
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple55, 8
6Operationoperator: 9
operand: 12
7Operationoperator: 37
operands: 11
8Literal
9Literal
10ExprTuple12
11ExprTuple13, 14
12Operationoperator: 15
operands: 54
13Operationoperator: 53
operands: 16
14Operationoperator: 17
operand: 19
15Literal
16ExprTuple49, 56
17Literal
18ExprTuple19
19Lambdaparameter: 28
body: 21
20ExprTuple28
21Conditionalvalue: 22
condition: 23
22Operationoperator: 57
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple27, 28
25Literal
26ExprTuple28, 29
27Operationoperator: 57
operands: 30
28Variable
29Operationoperator: 31
operands: 32
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Literal
34Operationoperator: 37
operands: 38
35Literal
36Operationoperator: 44
operands: 39
37Literal
38ExprTuple59, 40, 41, 42
39ExprTuple56, 43
40Literal
41Literal
42Operationoperator: 44
operands: 45
43Operationoperator: 50
operand: 49
44Literal
45ExprTuple47, 48
46ExprTuple49
47Literal
48Operationoperator: 50
operand: 52
49Literal
50Literal
51ExprTuple52
52Operationoperator: 53
operands: 54
53Literal
54ExprTuple55, 56
55Variable
56Operationoperator: 57
operands: 58
57Literal
58ExprTuple59, 60
59Literal
60Literal