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, InSet
from proveit.numbers import 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(c, sub_expr1)
sub_expr4 = IndexedVar(d, sub_expr1)
sub_expr5 = ExprRange(sub_expr1, b, one, n)
sub_expr6 = ExprRange(sub_expr1, sub_expr2, one, m)
sub_expr7 = ExprRange(sub_expr1, sub_expr3, one, n)
sub_expr8 = ExprRange(sub_expr1, sub_expr4, one, k)
expr = ExprTuple(Lambda([sub_expr6, b, sub_expr7, sub_expr8], Conditional(Equals(DecimalSequence(sub_expr6, sub_expr5, sub_expr8), DecimalSequence(sub_expr6, sub_expr7, sub_expr8)), And(ExprRange(sub_expr1, InSet(sub_expr2, Digits), one, m), InSet(b, Digits), ExprRange(sub_expr1, InSet(sub_expr3, Digits), one, n), ExprRange(sub_expr1, InSet(sub_expr4, Digits), one, k), Equals([sub_expr5], [sub_expr7])))))
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, c_{1}, c_{2}, \ldots, c_{n}, d_{1}, d_{2}, \ldots, d_{k}\right) \mapsto \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}) \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}, \left(c_{1} \in \mathbb{N}^{\leq 9}\right) ,  \left(c_{2} \in \mathbb{N}^{\leq 9}\right) ,  \ldots ,  \left(c_{n} \in \mathbb{N}^{\leq 9}\right), \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, b, ..\left(n - 3\right) \times.., b\right) = \left(c_{1}, c_{2}, \ldots, c_{n}\right)\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, 51, 41, 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: 47
end_index: 33
12Operationoperator: 38
operands: 20
13ExprRangelambda_map: 21
start_index: 47
end_index: 48
14ExprRangelambda_map: 22
start_index: 47
end_index: 35
15Operationoperator: 23
operands: 24
16ExprTuple25, 40, 26
17Literal
18ExprTuple25, 41, 26
19Lambdaparameter: 55
body: 27
20ExprTuple51, 44
21Lambdaparameter: 55
body: 28
22Lambdaparameter: 55
body: 29
23Literal
24ExprTuple30, 31
25ExprRangelambda_map: 32
start_index: 47
end_index: 33
26ExprRangelambda_map: 34
start_index: 47
end_index: 35
27Operationoperator: 38
operands: 36
28Operationoperator: 38
operands: 37
29Operationoperator: 38
operands: 39
30ExprTuple40
31ExprTuple41
32Lambdaparameter: 55
body: 42
33Variable
34Lambdaparameter: 55
body: 43
35Variable
36ExprTuple42, 44
37ExprTuple52, 44
38Literal
39ExprTuple43, 44
40ExprRangelambda_map: 45
start_index: 47
end_index: 48
41ExprRangelambda_map: 46
start_index: 47
end_index: 48
42IndexedVarvariable: 49
index: 55
43IndexedVarvariable: 50
index: 55
44Literal
45Lambdaparameter: 55
body: 51
46Lambdaparameter: 55
body: 52
47Literal
48Variable
49Variable
50Variable
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable