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, ModAbs, 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(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), 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|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] \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
1ExprTuple57, 60
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 7
4Operationoperator: 18
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 50
body: 10
8Operationoperator: 37
operands: 11
9Operationoperator: 37
operands: 12
10Conditionalvalue: 13
condition: 14
11ExprTuple57, 15
12ExprTuple60, 15
13Operationoperator: 16
operand: 20
14Operationoperator: 18
operands: 19
15Literal
16Literal
17ExprTuple20
18Literal
19ExprTuple21, 22, 23
20Lambdaparameter: 62
body: 25
21ExprRangelambda_map: 26
start_index: 59
end_index: 57
22Operationoperator: 37
operands: 27
23ExprRangelambda_map: 28
start_index: 59
end_index: 60
24ExprTuple62
25Conditionalvalue: 29
condition: 30
26Lambdaparameter: 68
body: 31
27ExprTuple61, 42
28Lambdaparameter: 68
body: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 37
operands: 35
31Operationoperator: 37
operands: 36
32Operationoperator: 37
operands: 38
33Literal
34ExprTuple39, 40
35ExprTuple62, 41
36ExprTuple63, 42
37Literal
38ExprTuple64, 42
39Operationoperator: 44
operands: 43
40Operationoperator: 44
operands: 45
41Literal
42Literal
43ExprTuple46, 62
44Literal
45ExprTuple47, 62
46Operationoperator: 49
operands: 48
47Operationoperator: 49
operands: 50
48ExprTuple52, 51, 53
49Literal
50ExprTuple52, 61, 53
51Operationoperator: 54
operands: 55
52ExprRangelambda_map: 56
start_index: 59
end_index: 57
53ExprRangelambda_map: 58
start_index: 59
end_index: 60
54Literal
55ExprTuple61, 62
56Lambdaparameter: 68
body: 63
57Variable
58Lambdaparameter: 68
body: 64
59Literal
60Variable
61Variable
62Variable
63IndexedVarvariable: 65
index: 68
64IndexedVarvariable: 66
index: 68
65Variable
66Variable
67ExprTuple68
68Variable