logo

Expression of type Forall

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 l
from proveit.logic import Equals, Forall, 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 = Forall(instance_param_or_params = [l], instance_expr = 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)))))))), domain = _full_domain, condition = 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())
\forall_{l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\}~|~l \neq 0}~\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)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 83
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11Operationoperator: 15
operand: 22
12Operationoperator: 71
operands: 17
13Operationoperator: 18
operands: 19
14Operationoperator: 20
operands: 21
15Literal
16ExprTuple22
17ExprTuple23, 24
18Literal
19ExprTuple83, 25
20Literal
21ExprTuple83, 26
22Operationoperator: 27
operands: 28
23Operationoperator: 80
operands: 29
24Operationoperator: 80
operands: 30
25Operationoperator: 31
operands: 32
26Literal
27Literal
28ExprTuple82, 83
29ExprTuple70, 84
30ExprTuple33, 34
31Literal
32ExprTuple35, 47
33Operationoperator: 64
operands: 36
34Operationoperator: 64
operands: 37
35Operationoperator: 64
operands: 38
36ExprTuple70, 39
37ExprTuple70, 40
38ExprTuple41, 70
39Operationoperator: 74
operand: 45
40Operationoperator: 74
operand: 46
41Operationoperator: 74
operand: 47
42ExprTuple45
43ExprTuple46
44ExprTuple47
45Operationoperator: 85
operands: 48
46Operationoperator: 85
operands: 49
47Operationoperator: 85
operands: 50
48ExprTuple52, 51
49ExprTuple52, 53
50ExprTuple87, 54
51Operationoperator: 71
operands: 55
52Literal
53Operationoperator: 71
operands: 56
54Operationoperator: 64
operands: 57
55ExprTuple87, 59, 60, 58
56ExprTuple87, 59, 60, 61
57ExprTuple88, 62
58Operationoperator: 64
operands: 63
59Literal
60Literal
61Operationoperator: 64
operands: 65
62Operationoperator: 74
operand: 70
63ExprTuple67, 68
64Literal
65ExprTuple76, 69
66ExprTuple70
67Operationoperator: 71
operands: 72
68Operationoperator: 74
operand: 83
69Operationoperator: 74
operand: 77
70Literal
71Literal
72ExprTuple84, 76
73ExprTuple83
74Literal
75ExprTuple77
76Operationoperator: 78
operand: 82
77Operationoperator: 80
operands: 81
78Literal
79ExprTuple82
80Literal
81ExprTuple83, 84
82Literal
83Variable
84Operationoperator: 85
operands: 86
85Literal
86ExprTuple87, 88
87Literal
88Literal