logo

Expression of type Forall

from the theory of proveit.numbers.modular

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, b
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Mod, ModAbs, Real, RealPos
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_j], instance_expr = Forall(instance_param_or_params = [L], instance_expr = Equals(ModAbs(Add(a_1_to_i, Mod(b, L), c_1_to_j), L), ModAbs(Add(a_1_to_i, b, c_1_to_j), L)).with_wrapping_at(2), domain = RealPos), domain = Real)
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_{a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j} \in \mathbb{R}}~\left[\forall_{L \in \mathbb{R}^+}~\left(\begin{array}{c} \begin{array}{l} \left|a_{1} +  a_{2} +  \ldots +  a_{i} + \left(b ~\textup{mod}~ L\right)+ c_{1} +  c_{2} +  \ldots +  c_{j}\right|_{\textup{mod}\thinspace L} =  \\ \left|a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right|_{\textup{mod}\thinspace L} \end{array} \end{array}\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: 6
operand: 2
1ExprTuple2
2Lambdaparameters: 40
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameter: 52
body: 15
11ExprRangelambda_map: 16
start_index: 49
end_index: 47
12Operationoperator: 27
operands: 17
13ExprRangelambda_map: 18
start_index: 49
end_index: 50
14ExprTuple52
15Conditionalvalue: 19
condition: 20
16Lambdaparameter: 58
body: 21
17ExprTuple51, 32
18Lambdaparameter: 58
body: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 27
operands: 25
21Operationoperator: 27
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple29, 30
25ExprTuple52, 31
26ExprTuple53, 32
27Literal
28ExprTuple54, 32
29Operationoperator: 34
operands: 33
30Operationoperator: 34
operands: 35
31Literal
32Literal
33ExprTuple36, 52
34Literal
35ExprTuple37, 52
36Operationoperator: 39
operands: 38
37Operationoperator: 39
operands: 40
38ExprTuple42, 41, 43
39Literal
40ExprTuple42, 51, 43
41Operationoperator: 44
operands: 45
42ExprRangelambda_map: 46
start_index: 49
end_index: 47
43ExprRangelambda_map: 48
start_index: 49
end_index: 50
44Literal
45ExprTuple51, 52
46Lambdaparameter: 58
body: 53
47Variable
48Lambdaparameter: 58
body: 54
49Literal
50Variable
51Variable
52Variable
53IndexedVarvariable: 55
index: 58
54IndexedVarvariable: 56
index: 58
55Variable
56Variable
57ExprTuple58
58Variable