logo

Expression of type Lambda

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 Conditional, L, Lambda, b, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Mod, Natural, Real, RealPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j], Conditional(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), And(InSet(i, Natural), InSet(j, 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())
\left(i, j\right) \mapsto \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(\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] \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple56, 59
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 7
4Operationoperator: 18
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 49
body: 10
8Operationoperator: 37
operands: 11
9Operationoperator: 37
operands: 12
10Conditionalvalue: 13
condition: 14
11ExprTuple56, 15
12ExprTuple59, 15
13Operationoperator: 16
operand: 20
14Operationoperator: 18
operands: 19
15Literal
16Literal
17ExprTuple20
18Literal
19ExprTuple21, 22, 23
20Lambdaparameter: 61
body: 25
21ExprRangelambda_map: 26
start_index: 58
end_index: 56
22Operationoperator: 37
operands: 27
23ExprRangelambda_map: 28
start_index: 58
end_index: 59
24ExprTuple61
25Conditionalvalue: 29
condition: 30
26Lambdaparameter: 67
body: 31
27ExprTuple60, 42
28Lambdaparameter: 67
body: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 37
operands: 35
31Operationoperator: 37
operands: 36
32Operationoperator: 37
operands: 38
33Literal
34ExprTuple39, 40
35ExprTuple61, 41
36ExprTuple62, 42
37Literal
38ExprTuple63, 42
39Operationoperator: 53
operands: 43
40Operationoperator: 53
operands: 44
41Literal
42Literal
43ExprTuple45, 61
44ExprTuple46, 61
45Operationoperator: 48
operands: 47
46Operationoperator: 48
operands: 49
47ExprTuple51, 50, 52
48Literal
49ExprTuple51, 60, 52
50Operationoperator: 53
operands: 54
51ExprRangelambda_map: 55
start_index: 58
end_index: 56
52ExprRangelambda_map: 57
start_index: 58
end_index: 59
53Literal
54ExprTuple60, 61
55Lambdaparameter: 67
body: 62
56Variable
57Lambdaparameter: 67
body: 63
58Literal
59Variable
60Variable
61Variable
62IndexedVarvariable: 64
index: 67
63IndexedVarvariable: 65
index: 67
64Variable
65Variable
66ExprTuple67
67Variable