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, ExprTuple, L, Lambda, b
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Mod, ModAbs, RealPos
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(L, Conditional(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), InSet(L, RealPos))))
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(L \mapsto \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} \textrm{ if } L \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
0ExprTuple1
1Lambdaparameter: 32
body: 3
2ExprTuple32
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple32, 12
10Operationoperator: 14
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 32
14Literal
15ExprTuple17, 32
16Operationoperator: 19
operands: 18
17Operationoperator: 19
operands: 20
18ExprTuple22, 21, 23
19Literal
20ExprTuple22, 31, 23
21Operationoperator: 24
operands: 25
22ExprRangelambda_map: 26
start_index: 29
end_index: 27
23ExprRangelambda_map: 28
start_index: 29
end_index: 30
24Literal
25ExprTuple31, 32
26Lambdaparameter: 38
body: 33
27Variable
28Lambdaparameter: 38
body: 34
29Literal
30Variable
31Variable
32Variable
33IndexedVarvariable: 35
index: 38
34IndexedVarvariable: 36
index: 38
35Variable
36Variable
37ExprTuple38
38Variable