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, Neg, Sum, e, frac, i, one, pi, 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 = Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, 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} \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}\right)\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: 26
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple61, 8
6Operationoperator: 9
operand: 12
7Operationoperator: 54
operands: 11
8Literal
9Literal
10ExprTuple12
11ExprTuple13, 14
12Operationoperator: 15
operands: 16
13Operationoperator: 47
operands: 17
14Operationoperator: 18
operand: 20
15Literal
16ExprTuple61, 52
17ExprTuple53, 52
18Literal
19ExprTuple20
20Lambdaparameter: 60
body: 22
21ExprTuple60
22Conditionalvalue: 23
condition: 24
23Operationoperator: 54
operands: 25
24Operationoperator: 26
operands: 27
25ExprTuple28, 29
26Literal
27ExprTuple60, 30
28Operationoperator: 56
operands: 31
29Operationoperator: 56
operands: 32
30Operationoperator: 33
operands: 34
31ExprTuple36, 35
32ExprTuple36, 37
33Literal
34ExprTuple38, 39
35Operationoperator: 49
operand: 44
36Literal
37Operationoperator: 54
operands: 41
38Literal
39Operationoperator: 42
operands: 43
40ExprTuple44
41ExprTuple62, 58, 59, 45, 60
42Literal
43ExprTuple52, 46
44Operationoperator: 47
operands: 48
45Literal
46Operationoperator: 49
operand: 53
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple53
51Operationoperator: 54
operands: 55
52Operationoperator: 56
operands: 57
53Literal
54Literal
55ExprTuple62, 58, 59, 60, 61
56Literal
57ExprTuple62, 63
58Literal
59Literal
60Variable
61Variable
62Literal
63Literal