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 = [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()
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_{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}
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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 55
body: 5
4ExprTuple55
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 23
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple55, 13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 43
operands: 17
14ExprTuple18, 20
15Literal
16ExprTuple19, 20
17ExprTuple66, 21
18Operationoperator: 23
operands: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operands: 26
21Operationoperator: 60
operands: 27
22ExprTuple40, 28
23Literal
24ExprTuple40, 29
25Literal
26ExprTuple55, 30
27ExprTuple54, 31
28Operationoperator: 32
operands: 33
29Operationoperator: 43
operands: 34
30Operationoperator: 35
operands: 36
31Operationoperator: 64
operand: 58
32Literal
33ExprTuple38, 39
34ExprTuple46, 54
35Literal
36ExprTuple40, 41
37ExprTuple58
38Operationoperator: 43
operands: 42
39Operationoperator: 43
operands: 44
40Variable
41Operationoperator: 56
operands: 45
42ExprTuple46, 47
43Literal
44ExprTuple51, 54
45ExprTuple58, 62
46Operationoperator: 60
operands: 48
47Operationoperator: 64
operand: 51
48ExprTuple50, 66
49ExprTuple51
50Operationoperator: 64
operand: 54
51Operationoperator: 60
operands: 53
52ExprTuple54
53ExprTuple55, 66
54Operationoperator: 56
operands: 57
55Variable
56Literal
57ExprTuple58, 59
58Literal
59Operationoperator: 60
operands: 61
60Literal
61ExprTuple62, 63
62Literal
63Operationoperator: 64
operand: 66
64Literal
65ExprTuple66
66Literal