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, _neg_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 = _neg_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 \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}}~\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: 42
body: 5
4ExprTuple42
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple42, 14
12Operationoperator: 26
operands: 15
13Operationoperator: 50
operands: 16
14Operationoperator: 17
operands: 18
15ExprTuple56, 19
16ExprTuple20, 21
17Literal
18ExprTuple22, 23
19Operationoperator: 50
operands: 24
20Operationoperator: 26
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 46
operands: 28
23Operationoperator: 52
operand: 33
24ExprTuple30, 31
25ExprTuple56, 30
26Literal
27ExprTuple56, 31
28ExprTuple32, 56
29ExprTuple33
30Literal
31Operationoperator: 57
operands: 34
32Operationoperator: 52
operand: 38
33Operationoperator: 46
operands: 36
34ExprTuple37, 61
35ExprTuple38
36ExprTuple39, 56
37Operationoperator: 46
operands: 40
38Operationoperator: 57
operands: 41
39Variable
40ExprTuple42, 43
41ExprTuple61, 44
42Variable
43Operationoperator: 52
operand: 48
44Operationoperator: 46
operands: 47
45ExprTuple48
46Literal
47ExprTuple62, 49
48Operationoperator: 50
operands: 51
49Operationoperator: 52
operand: 56
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple56
54Operationoperator: 57
operands: 58
55Operationoperator: 59
operand: 63
56Literal
57Literal
58ExprTuple61, 62
59Literal
60ExprTuple63
61Literal
62Literal
63Literal