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, c, d, k, m, n
from proveit.core_expr_types import b_1_to_n
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, DecimalSequence, Digits, Natural, one
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)
sub_expr3 = ExprRange(sub_expr1, IndexedVar(d, sub_expr1), one, k)
sub_expr4 = Add(b_1_to_n)
expr = ExprTuple(Lambda([m, n, k], Conditional(Forall(instance_param_or_params = [sub_expr2, b_1_to_n, c, sub_expr3], instance_expr = Equals(DecimalSequence(sub_expr2, sub_expr4, sub_expr3), DecimalSequence(sub_expr2, c, sub_expr3)), domain = Digits, condition = Equals(sub_expr4, c)), And(InSet(m, Natural), InSet(n, 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, n, k\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{m}, b_{1}, b_{2}, \ldots, b_{n}, c, d_{1}, d_{2}, \ldots, d_{k} \in \mathbb{N}^{\leq 9}~|~\left(b_{1} +  b_{2} +  \ldots +  b_{n}\right) = c}~\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})\right) \textrm{ if } m \in \mathbb{N} ,  n \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
2ExprTuple48, 65, 50
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 22
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 53
operands: 15
11Operationoperator: 53
operands: 16
12Operationoperator: 53
operands: 17
13ExprTuple40, 60, 46, 41
14Conditionalvalue: 18
condition: 19
15ExprTuple48, 20
16ExprTuple65, 20
17ExprTuple50, 20
18Operationoperator: 38
operands: 21
19Operationoperator: 22
operands: 23
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple26, 27, 28, 29, 30
24Operationoperator: 32
operands: 31
25Operationoperator: 32
operands: 33
26ExprRangelambda_map: 34
start_index: 64
end_index: 48
27ExprRangelambda_map: 35
start_index: 64
end_index: 65
28Operationoperator: 53
operands: 36
29ExprRangelambda_map: 37
start_index: 64
end_index: 50
30Operationoperator: 38
operands: 39
31ExprTuple40, 45, 41
32Literal
33ExprTuple40, 46, 41
34Lambdaparameter: 69
body: 42
35Lambdaparameter: 69
body: 43
36ExprTuple46, 59
37Lambdaparameter: 69
body: 44
38Literal
39ExprTuple45, 46
40ExprRangelambda_map: 47
start_index: 64
end_index: 48
41ExprRangelambda_map: 49
start_index: 64
end_index: 50
42Operationoperator: 53
operands: 51
43Operationoperator: 53
operands: 52
44Operationoperator: 53
operands: 54
45Operationoperator: 55
operands: 56
46Variable
47Lambdaparameter: 69
body: 57
48Variable
49Lambdaparameter: 69
body: 58
50Variable
51ExprTuple57, 59
52ExprTuple66, 59
53Literal
54ExprTuple58, 59
55Literal
56ExprTuple60
57IndexedVarvariable: 61
index: 69
58IndexedVarvariable: 62
index: 69
59Literal
60ExprRangelambda_map: 63
start_index: 64
end_index: 65
61Variable
62Variable
63Lambdaparameter: 69
body: 66
64Literal
65Variable
66IndexedVarvariable: 67
index: 69
67Variable
68ExprTuple69
69Variable