logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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(\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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 39
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameter: 51
body: 14
10ExprRangelambda_map: 15
start_index: 48
end_index: 46
11Operationoperator: 26
operands: 16
12ExprRangelambda_map: 17
start_index: 48
end_index: 49
13ExprTuple51
14Conditionalvalue: 18
condition: 19
15Lambdaparameter: 57
body: 20
16ExprTuple50, 31
17Lambdaparameter: 57
body: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 26
operands: 24
20Operationoperator: 26
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28, 29
24ExprTuple51, 30
25ExprTuple52, 31
26Literal
27ExprTuple53, 31
28Operationoperator: 33
operands: 32
29Operationoperator: 33
operands: 34
30Literal
31Literal
32ExprTuple35, 51
33Literal
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