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 e, l
from proveit.logic import And, Forall, Iff, InSet, Union
from proveit.numbers import ModAbs, greater
from proveit.physics.quantum.QPE import _e_domain, _full_domain, _neg_domain, _pos_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = greater(ModAbs(l, _two_pow_t), e)
expr = Forall(instance_param_or_params = [l], instance_expr = Forall(instance_param_or_params = [e], instance_expr = Iff(And(InSet(l, Union(_neg_domain, _pos_domain)), sub_expr1), And(InSet(l, _full_domain), sub_expr1)).with_wrapping_at(1), domain = _e_domain).with_wrapping()).with_wrapping()
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())
\begin{array}{l}\forall_{l}~\\
\left[\begin{array}{l}\forall_{e \in \{1~\ldotp \ldotp~2^{t - 1} - 2\}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(l \in \left(\{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\} \cup \{e + 1~\ldotp \ldotp~2^{t - 1}\}\right)\right) \land \left(\left|l\right|_{\textup{mod}\thinspace 2^{t}} > e\right)\right) \\  \Leftrightarrow \left(\left(l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\}\right) \land \left(\left|l\right|_{\textup{mod}\thinspace 2^{t}} > e\right)\right) \end{array} \end{array}\right)\end{array}\right]\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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: 5
operand: 2
1ExprTuple2
2Lambdaparameter: 44
body: 4
3ExprTuple44
4Operationoperator: 5
operand: 7
5Literal
6ExprTuple7
7Lambdaparameter: 59
body: 9
8ExprTuple59
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 27
operands: 14
12Literal
13ExprTuple15, 16
14ExprTuple59, 17
15Operationoperator: 19
operands: 18
16Operationoperator: 19
operands: 20
17Operationoperator: 47
operands: 21
18ExprTuple22, 24
19Literal
20ExprTuple23, 24
21ExprTuple70, 25
22Operationoperator: 27
operands: 26
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Operationoperator: 64
operands: 31
26ExprTuple44, 32
27Literal
28ExprTuple44, 33
29Literal
30ExprTuple59, 34
31ExprTuple58, 35
32Operationoperator: 36
operands: 37
33Operationoperator: 47
operands: 38
34Operationoperator: 39
operands: 40
35Operationoperator: 68
operand: 62
36Literal
37ExprTuple42, 43
38ExprTuple50, 58
39Literal
40ExprTuple44, 45
41ExprTuple62
42Operationoperator: 47
operands: 46
43Operationoperator: 47
operands: 48
44Variable
45Operationoperator: 60
operands: 49
46ExprTuple50, 51
47Literal
48ExprTuple55, 58
49ExprTuple62, 66
50Operationoperator: 64
operands: 52
51Operationoperator: 68
operand: 55
52ExprTuple54, 70
53ExprTuple55
54Operationoperator: 68
operand: 58
55Operationoperator: 64
operands: 57
56ExprTuple58
57ExprTuple59, 70
58Operationoperator: 60
operands: 61
59Variable
60Literal
61ExprTuple62, 63
62Literal
63Operationoperator: 64
operands: 65
64Literal
65ExprTuple66, 67
66Literal
67Operationoperator: 68
operand: 70
68Literal
69ExprTuple70
70Literal