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, Forall, InSet
from proveit.numbers import Add, DecimalSequence, Digits, Less, Natural, nine, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = ExprRange(sub_expr1, IndexedVar(a, sub_expr1), one, m)
expr = ExprTuple(Lambda([m, k], Conditional(Forall(instance_param_or_params = [sub_expr2, b], instance_expr = Equals(Add(DecimalSequence(sub_expr2, b, ExprRange(sub_expr1, nine, one, k)), one), DecimalSequence(sub_expr2, Add(b, one), ExprRange(sub_expr1, zero, one, k))), domain = Digits, condition = Less(b, nine)), And(InSet(m, Natural), InSet(k, Natural)))))
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(m, k\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{m}, b \in \mathbb{N}^{\leq 9}~|~b < 9}~\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)\right) \textrm{ if } m \in \mathbb{N} ,  k \in \mathbb{N}\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
2ExprTuple51, 54
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 21
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 43
operands: 14
11Operationoperator: 43
operands: 15
12ExprTuple45, 47
13Conditionalvalue: 16
condition: 17
14ExprTuple51, 18
15ExprTuple54, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27
23Operationoperator: 40
operands: 28
24Operationoperator: 38
operands: 29
25ExprRangelambda_map: 30
start_index: 53
end_index: 51
26Operationoperator: 43
operands: 31
27Operationoperator: 32
operands: 33
28ExprTuple34, 53
29ExprTuple45, 35, 36
30Lambdaparameter: 59
body: 37
31ExprTuple47, 49
32Literal
33ExprTuple47, 56
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operands: 41
36ExprRangelambda_map: 42
start_index: 53
end_index: 54
37Operationoperator: 43
operands: 44
38Literal
39ExprTuple45, 47, 46
40Literal
41ExprTuple47, 53
42Lambdaparameter: 59
body: 48
43Literal
44ExprTuple55, 49
45ExprRangelambda_map: 50
start_index: 53
end_index: 51
46ExprRangelambda_map: 52
start_index: 53
end_index: 54
47Variable
48Literal
49Literal
50Lambdaparameter: 59
body: 55
51Variable
52Lambdaparameter: 59
body: 56
53Literal
54Variable
55IndexedVarvariable: 57
index: 59
56Literal
57Variable
58ExprTuple59
59Variable