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, l
from proveit.logic import And, Equals, InSet, NotEquals
from proveit.numbers import Exp, Mult, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _rel_indexed_alpha, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Equals(_rel_indexed_alpha, Mult(frac(one, _two_pow_t), frac(subtract(one, Exp(e, Mult(two, pi, i, subtract(Mult(_two_pow_t, _delta_b_floor), l)))), subtract(one, Exp(e, Mult(two, pi, i, subtract(_delta_b_floor, frac(l, _two_pow_t)))))))), And(InSet(l, _full_domain), NotEquals(l, zero)))
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_{b_{\textit{f}} \oplus l} = \left(\frac{1}{2^{t}} \cdot \frac{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\left(2^{t} \cdot \delta_{b_{\textit{f}}}\right) - l\right)}}{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right)}}\right) \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\} ,  l \neq 0\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
6ExprTuple9, 10
7Operationoperator: 11
operand: 18
8Operationoperator: 67
operands: 13
9Operationoperator: 14
operands: 15
10Operationoperator: 16
operands: 17
11Literal
12ExprTuple18
13ExprTuple19, 20
14Literal
15ExprTuple79, 21
16Literal
17ExprTuple79, 22
18Operationoperator: 23
operands: 24
19Operationoperator: 76
operands: 25
20Operationoperator: 76
operands: 26
21Operationoperator: 27
operands: 28
22Literal
23Literal
24ExprTuple78, 79
25ExprTuple66, 80
26ExprTuple29, 30
27Literal
28ExprTuple31, 43
29Operationoperator: 60
operands: 32
30Operationoperator: 60
operands: 33
31Operationoperator: 60
operands: 34
32ExprTuple66, 35
33ExprTuple66, 36
34ExprTuple37, 66
35Operationoperator: 70
operand: 41
36Operationoperator: 70
operand: 42
37Operationoperator: 70
operand: 43
38ExprTuple41
39ExprTuple42
40ExprTuple43
41Operationoperator: 81
operands: 44
42Operationoperator: 81
operands: 45
43Operationoperator: 81
operands: 46
44ExprTuple48, 47
45ExprTuple48, 49
46ExprTuple83, 50
47Operationoperator: 67
operands: 51
48Literal
49Operationoperator: 67
operands: 52
50Operationoperator: 60
operands: 53
51ExprTuple83, 55, 56, 54
52ExprTuple83, 55, 56, 57
53ExprTuple84, 58
54Operationoperator: 60
operands: 59
55Literal
56Literal
57Operationoperator: 60
operands: 61
58Operationoperator: 70
operand: 66
59ExprTuple63, 64
60Literal
61ExprTuple72, 65
62ExprTuple66
63Operationoperator: 67
operands: 68
64Operationoperator: 70
operand: 79
65Operationoperator: 70
operand: 73
66Literal
67Literal
68ExprTuple80, 72
69ExprTuple79
70Literal
71ExprTuple73
72Operationoperator: 74
operand: 78
73Operationoperator: 76
operands: 77
74Literal
75ExprTuple78
76Literal
77ExprTuple79, 80
78Literal
79Variable
80Operationoperator: 81
operands: 82
81Literal
82ExprTuple83, 84
83Literal
84Literal