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, c, d, k, m, n
from proveit.core_expr_types import b_1_to_n
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, DecimalSequence, Digits, one
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 = IndexedVar(d, sub_expr1)
sub_expr4 = ExprRange(sub_expr1, sub_expr2, one, m)
sub_expr5 = ExprRange(sub_expr1, sub_expr3, one, k)
sub_expr6 = Add(b_1_to_n)
expr = ExprTuple(Lambda([sub_expr4, b_1_to_n, c, sub_expr5], Conditional(Equals(DecimalSequence(sub_expr4, sub_expr6, sub_expr5), DecimalSequence(sub_expr4, c, sub_expr5)), And(ExprRange(sub_expr1, InSet(sub_expr2, Digits), one, m), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Digits), one, n), InSet(c, Digits), ExprRange(sub_expr1, InSet(sub_expr3, Digits), one, k), Equals(sub_expr6, 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(\left(a_{1}, a_{2}, \ldots, a_{m}, b_{1}, b_{2}, \ldots, b_{n}, c, d_{1}, d_{2}, \ldots, d_{k}\right) \mapsto \left\{\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ \left(b_{1} +  b_{2} +  \ldots +  b_{n}\right) ~ d_{1}, d_{2}, \ldots, d_{k}) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ c ~ d_{1}, d_{2}, \ldots, d_{k}) \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), \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..\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
2ExprTuple25, 45, 31, 26
3Conditionalvalue: 4
condition: 5
4Operationoperator: 23
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14, 15
9Operationoperator: 17
operands: 16
10Operationoperator: 17
operands: 18
11ExprRangelambda_map: 19
start_index: 49
end_index: 33
12ExprRangelambda_map: 20
start_index: 49
end_index: 50
13Operationoperator: 38
operands: 21
14ExprRangelambda_map: 22
start_index: 49
end_index: 35
15Operationoperator: 23
operands: 24
16ExprTuple25, 30, 26
17Literal
18ExprTuple25, 31, 26
19Lambdaparameter: 54
body: 27
20Lambdaparameter: 54
body: 28
21ExprTuple31, 44
22Lambdaparameter: 54
body: 29
23Literal
24ExprTuple30, 31
25ExprRangelambda_map: 32
start_index: 49
end_index: 33
26ExprRangelambda_map: 34
start_index: 49
end_index: 35
27Operationoperator: 38
operands: 36
28Operationoperator: 38
operands: 37
29Operationoperator: 38
operands: 39
30Operationoperator: 40
operands: 41
31Variable
32Lambdaparameter: 54
body: 42
33Variable
34Lambdaparameter: 54
body: 43
35Variable
36ExprTuple42, 44
37ExprTuple51, 44
38Literal
39ExprTuple43, 44
40Literal
41ExprTuple45
42IndexedVarvariable: 46
index: 54
43IndexedVarvariable: 47
index: 54
44Literal
45ExprRangelambda_map: 48
start_index: 49
end_index: 50
46Variable
47Variable
48Lambdaparameter: 54
body: 51
49Literal
50Variable
51IndexedVarvariable: 52
index: 54
52Variable
53ExprTuple54
54Variable