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
from proveit.numbers import Exp, Mult, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(_diff_l_scaled_delta_floor, two)
expr = Forall(instance_param_or_params = [l], instance_expr = Equals(frac(one, Mult(four, sub_expr1)), Mult(frac(one, four), frac(one, sub_expr1))), domain = _pos_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())
\forall_{l \in \{e + 1~\ldotp \ldotp~2^{t - 1}\}}~\left(\frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} = \left(\frac{1}{4} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\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: 41
body: 5
4ExprTuple41
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple41, 14
12Operationoperator: 26
operands: 15
13Operationoperator: 47
operands: 16
14Operationoperator: 17
operands: 18
15ExprTuple43, 19
16ExprTuple20, 21
17Literal
18ExprTuple22, 23
19Operationoperator: 47
operands: 24
20Operationoperator: 26
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 38
operands: 28
23Operationoperator: 51
operands: 29
24ExprTuple30, 31
25ExprTuple43, 30
26Literal
27ExprTuple43, 31
28ExprTuple32, 43
29ExprTuple55, 33
30Literal
31Operationoperator: 51
operands: 34
32Variable
33Operationoperator: 38
operands: 35
34ExprTuple36, 55
35ExprTuple56, 37
36Operationoperator: 38
operands: 39
37Operationoperator: 44
operand: 43
38Literal
39ExprTuple41, 42
40ExprTuple43
41Variable
42Operationoperator: 44
operand: 46
43Literal
44Literal
45ExprTuple46
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Operationoperator: 51
operands: 52
50Operationoperator: 53
operand: 57
51Literal
52ExprTuple55, 56
53Literal
54ExprTuple57
55Literal
56Literal
57Literal