logo

Expression of type ExprTuple

from the theory of proveit.numbers.numerals.decimals

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 ExprRange, ExprTuple, IndexedVar, Variable, a, b, c, d, k, m, n
from proveit.core_expr_types import b_1_to_n
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Digits, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(InSet(m, Natural), InSet(n, Natural), InSet(k, Natural), ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Digits), one, m), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Digits), one, n), InSet(c, Digits), ExprRange(sub_expr1, InSet(IndexedVar(d, sub_expr1), Digits), one, k), Equals(Add(b_1_to_n), c))
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(m \in \mathbb{N}, n \in \mathbb{N}, k \in \mathbb{N},\left(a_{1} \in \mathbb{N}^{\leq 9}\right), \left(a_{2} \in \mathbb{N}^{\leq 9}\right), \ldots, \left(a_{m} \in \mathbb{N}^{\leq 9}\right),\left(b_{1} \in \mathbb{N}^{\leq 9}\right), \left(b_{2} \in \mathbb{N}^{\leq 9}\right), \ldots, \left(b_{n} \in \mathbb{N}^{\leq 9}\right), c \in \mathbb{N}^{\leq 9},\left(d_{1} \in \mathbb{N}^{\leq 9}\right), \left(d_{2} \in \mathbb{N}^{\leq 9}\right), \ldots, \left(d_{k} \in \mathbb{N}^{\leq 9}\right), \left(b_{1} +  b_{2} +  \ldots +  b_{n}\right) = c\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2, 3, 4, 5, 6, 7, 8
1Operationoperator: 28
operands: 9
2Operationoperator: 28
operands: 10
3Operationoperator: 28
operands: 11
4ExprRangelambda_map: 12
start_index: 39
end_index: 18
5ExprRangelambda_map: 13
start_index: 39
end_index: 40
6Operationoperator: 28
operands: 14
7ExprRangelambda_map: 15
start_index: 39
end_index: 19
8Operationoperator: 16
operands: 17
9ExprTuple18, 20
10ExprTuple40, 20
11ExprTuple19, 20
12Lambdaparameter: 44
body: 21
13Lambdaparameter: 44
body: 22
14ExprTuple25, 34
15Lambdaparameter: 44
body: 23
16Literal
17ExprTuple24, 25
18Variable
19Variable
20Literal
21Operationoperator: 28
operands: 26
22Operationoperator: 28
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 30
operands: 31
25Variable
26ExprTuple32, 34
27ExprTuple41, 34
28Literal
29ExprTuple33, 34
30Literal
31ExprTuple35
32IndexedVarvariable: 36
index: 44
33IndexedVarvariable: 37
index: 44
34Literal
35ExprRangelambda_map: 38
start_index: 39
end_index: 40
36Variable
37Variable
38Lambdaparameter: 44
body: 41
39Literal
40Variable
41IndexedVarvariable: 42
index: 44
42Variable
43ExprTuple44
44Variable