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.logic import And, Equals, Forall, InSet
from proveit.numbers import 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, b, one, n)
sub_expr3 = ExprRange(sub_expr1, IndexedVar(a, sub_expr1), one, m)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, n)
sub_expr5 = ExprRange(sub_expr1, IndexedVar(d, sub_expr1), one, k)
expr = ExprTuple(Lambda([m, n, k], Conditional(Forall(instance_param_or_params = [sub_expr3, b, sub_expr4, sub_expr5], instance_expr = Equals(DecimalSequence(sub_expr3, sub_expr2, sub_expr5), DecimalSequence(sub_expr3, sub_expr4, sub_expr5)), domain = Digits, condition = Equals([sub_expr2], [sub_expr4])), 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, c_{1}, c_{2}, \ldots, c_{n}, d_{1}, d_{2}, \ldots, d_{k} \in \mathbb{N}^{\leq 9}~|~\left(b, b, ..\left(n - 3\right) \times.., b\right) = \left(c_{1}, c_{2}, \ldots, c_{n}\right)}~\left(\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ b, b, ..\left(n - 3\right) \times.., b ~ d_{1}, d_{2}, \ldots, d_{k}) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ c_{1}, c_{2}, \ldots, c_{n} ~ 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, 63, 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, 66, 56, 41
14Conditionalvalue: 18
condition: 19
15ExprTuple48, 20
16ExprTuple63, 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: 62
end_index: 48
27Operationoperator: 53
operands: 35
28ExprRangelambda_map: 36
start_index: 62
end_index: 63
29ExprRangelambda_map: 37
start_index: 62
end_index: 50
30Operationoperator: 38
operands: 39
31ExprTuple40, 55, 41
32Literal
33ExprTuple40, 56, 41
34Lambdaparameter: 70
body: 42
35ExprTuple66, 59
36Lambdaparameter: 70
body: 43
37Lambdaparameter: 70
body: 44
38Literal
39ExprTuple45, 46
40ExprRangelambda_map: 47
start_index: 62
end_index: 48
41ExprRangelambda_map: 49
start_index: 62
end_index: 50
42Operationoperator: 53
operands: 51
43Operationoperator: 53
operands: 52
44Operationoperator: 53
operands: 54
45ExprTuple55
46ExprTuple56
47Lambdaparameter: 70
body: 57
48Variable
49Lambdaparameter: 70
body: 58
50Variable
51ExprTuple57, 59
52ExprTuple67, 59
53Literal
54ExprTuple58, 59
55ExprRangelambda_map: 60
start_index: 62
end_index: 63
56ExprRangelambda_map: 61
start_index: 62
end_index: 63
57IndexedVarvariable: 64
index: 70
58IndexedVarvariable: 65
index: 70
59Literal
60Lambdaparameter: 70
body: 66
61Lambdaparameter: 70
body: 67
62Literal
63Variable
64Variable
65Variable
66Variable
67IndexedVarvariable: 68
index: 70
68Variable
69ExprTuple70
70Variable