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, i, j
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, Natural, Real, RealPos
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [i, j], instance_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), domain = Natural)
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_{i, j \in \mathbb{N}}~\left[\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]\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: 18
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple59, 62
4Conditionalvalue: 5
condition: 6
5Operationoperator: 18
operand: 9
6Operationoperator: 20
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 52
body: 12
10Operationoperator: 39
operands: 13
11Operationoperator: 39
operands: 14
12Conditionalvalue: 15
condition: 16
13ExprTuple59, 17
14ExprTuple62, 17
15Operationoperator: 18
operand: 22
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22
20Literal
21ExprTuple23, 24, 25
22Lambdaparameter: 64
body: 27
23ExprRangelambda_map: 28
start_index: 61
end_index: 59
24Operationoperator: 39
operands: 29
25ExprRangelambda_map: 30
start_index: 61
end_index: 62
26ExprTuple64
27Conditionalvalue: 31
condition: 32
28Lambdaparameter: 70
body: 33
29ExprTuple63, 44
30Lambdaparameter: 70
body: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 39
operands: 37
33Operationoperator: 39
operands: 38
34Operationoperator: 39
operands: 40
35Literal
36ExprTuple41, 42
37ExprTuple64, 43
38ExprTuple65, 44
39Literal
40ExprTuple66, 44
41Operationoperator: 46
operands: 45
42Operationoperator: 46
operands: 47
43Literal
44Literal
45ExprTuple48, 64
46Literal
47ExprTuple49, 64
48Operationoperator: 51
operands: 50
49Operationoperator: 51
operands: 52
50ExprTuple54, 53, 55
51Literal
52ExprTuple54, 63, 55
53Operationoperator: 56
operands: 57
54ExprRangelambda_map: 58
start_index: 61
end_index: 59
55ExprRangelambda_map: 60
start_index: 61
end_index: 62
56Literal
57ExprTuple63, 64
58Lambdaparameter: 70
body: 65
59Variable
60Lambdaparameter: 70
body: 66
61Literal
62Variable
63Variable
64Variable
65IndexedVarvariable: 67
index: 70
66IndexedVarvariable: 68
index: 70
67Variable
68Variable
69ExprTuple70
70Variable