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, 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(Mod(Add(a_1_to_i, Mod(b, L), c_1_to_j), L), Mod(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(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + \left(b ~\textup{mod}~ L\right)+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) ~\textup{mod}~ L\right) =  \\ \left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) ~\textup{mod}~ L\right) \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: 39
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameter: 51
body: 15
11ExprRangelambda_map: 16
start_index: 48
end_index: 46
12Operationoperator: 27
operands: 17
13ExprRangelambda_map: 18
start_index: 48
end_index: 49
14ExprTuple51
15Conditionalvalue: 19
condition: 20
16Lambdaparameter: 57
body: 21
17ExprTuple50, 32
18Lambdaparameter: 57
body: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 27
operands: 25
21Operationoperator: 27
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple29, 30
25ExprTuple51, 31
26ExprTuple52, 32
27Literal
28ExprTuple53, 32
29Operationoperator: 43
operands: 33
30Operationoperator: 43
operands: 34
31Literal
32Literal
33ExprTuple35, 51
34ExprTuple36, 51
35Operationoperator: 38
operands: 37
36Operationoperator: 38
operands: 39
37ExprTuple41, 40, 42
38Literal
39ExprTuple41, 50, 42
40Operationoperator: 43
operands: 44
41ExprRangelambda_map: 45
start_index: 48
end_index: 46
42ExprRangelambda_map: 47
start_index: 48
end_index: 49
43Literal
44ExprTuple50, 51
45Lambdaparameter: 57
body: 52
46Variable
47Lambdaparameter: 57
body: 53
48Literal
49Variable
50Variable
51Variable
52IndexedVarvariable: 54
index: 57
53IndexedVarvariable: 55
index: 57
54Variable
55Variable
56ExprTuple57
57Variable