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, ExprRange, IndexedVar, L, Lambda, Variable, a, b, c, 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, Real, RealPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, b, c_1_to_j], Conditional(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), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Real), one, i), InSet(b, Real), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), Real), one, j))))
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(a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j}\right) \mapsto \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) \textrm{ if } \left(a_{1} \in \mathbb{R}\right) ,  \left(a_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}\right) ,  b \in \mathbb{R}, \left(c_{1} \in \mathbb{R}\right) ,  \left(c_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{R}\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 38
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8
6Literal
7ExprTuple9, 10, 11
8Lambdaparameter: 50
body: 13
9ExprRangelambda_map: 14
start_index: 47
end_index: 45
10Operationoperator: 25
operands: 15
11ExprRangelambda_map: 16
start_index: 47
end_index: 48
12ExprTuple50
13Conditionalvalue: 17
condition: 18
14Lambdaparameter: 56
body: 19
15ExprTuple49, 30
16Lambdaparameter: 56
body: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 25
operands: 23
19Operationoperator: 25
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22ExprTuple27, 28
23ExprTuple50, 29
24ExprTuple51, 30
25Literal
26ExprTuple52, 30
27Operationoperator: 32
operands: 31
28Operationoperator: 32
operands: 33
29Literal
30Literal
31ExprTuple34, 50
32Literal
33ExprTuple35, 50
34Operationoperator: 37
operands: 36
35Operationoperator: 37
operands: 38
36ExprTuple40, 39, 41
37Literal
38ExprTuple40, 49, 41
39Operationoperator: 42
operands: 43
40ExprRangelambda_map: 44
start_index: 47
end_index: 45
41ExprRangelambda_map: 46
start_index: 47
end_index: 48
42Literal
43ExprTuple49, 50
44Lambdaparameter: 56
body: 51
45Variable
46Lambdaparameter: 56
body: 52
47Literal
48Variable
49Variable
50Variable
51IndexedVarvariable: 53
index: 56
52IndexedVarvariable: 54
index: 56
53Variable
54Variable
55ExprTuple56
56Variable