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 Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, a, b, k, m
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, DecimalSequence, Digits, Less, nine, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(a, sub_expr1)
sub_expr3 = ExprRange(sub_expr1, sub_expr2, one, m)
expr = ExprTuple(Lambda([sub_expr3, b], Conditional(Equals(Add(DecimalSequence(sub_expr3, b, ExprRange(sub_expr1, nine, one, k)), one), DecimalSequence(sub_expr3, Add(b, one), ExprRange(sub_expr1, zero, one, k))), And(ExprRange(sub_expr1, InSet(sub_expr2, Digits), one, m), InSet(b, Digits), Less(b, nine)))))
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_{m}, b\right) \mapsto \left\{\left(\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ b ~ 9, 9, ..\left(k - 3\right) \times.., 9) + 1\right) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ \left(b + 1\right) ~ 0, 0, ..\left(k - 3\right) \times.., 0) \textrm{ if } \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) ,  b \in \mathbb{N}^{\leq 9} ,  b < 9\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: 2
body: 3
2ExprTuple32, 34
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10Operationoperator: 27
operands: 15
11Operationoperator: 25
operands: 16
12ExprRangelambda_map: 17
start_index: 40
end_index: 38
13Operationoperator: 30
operands: 18
14Operationoperator: 19
operands: 20
15ExprTuple21, 40
16ExprTuple32, 22, 23
17Lambdaparameter: 46
body: 24
18ExprTuple34, 36
19Literal
20ExprTuple34, 43
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23ExprRangelambda_map: 29
start_index: 40
end_index: 41
24Operationoperator: 30
operands: 31
25Literal
26ExprTuple32, 34, 33
27Literal
28ExprTuple34, 40
29Lambdaparameter: 46
body: 35
30Literal
31ExprTuple42, 36
32ExprRangelambda_map: 37
start_index: 40
end_index: 38
33ExprRangelambda_map: 39
start_index: 40
end_index: 41
34Variable
35Literal
36Literal
37Lambdaparameter: 46
body: 42
38Variable
39Lambdaparameter: 46
body: 43
40Literal
41Variable
42IndexedVarvariable: 44
index: 46
43Literal
44Variable
45ExprTuple46
46Variable