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, n
from proveit.core_expr_types import b_1_to_n
from proveit.logic import And, InSet
from proveit.numbers import DecimalSequence, Digits, NaturalPos, greater, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([a, b_1_to_n], Conditional(InSet(DecimalSequence(a, b_1_to_n), NaturalPos), And(InSet(a, Digits), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Digits), one, n), greater(a, zero)))))
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, b_{1}, b_{2}, \ldots, b_{n}\right) \mapsto \left\{\texttt{\#}(a ~ b_{1}, b_{2}, \ldots, b_{n}) \in \mathbb{N}^+ \textrm{ if } a \in \mathbb{N}^{\leq 9}, \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) ,  a > 0\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: 14
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 26
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Operationoperator: 13
operands: 14
9Literal
10Operationoperator: 26
operands: 15
11ExprRangelambda_map: 16
start_index: 24
end_index: 25
12Operationoperator: 17
operands: 18
13Literal
14ExprTuple22, 19
15ExprTuple22, 29
16Lambdaparameter: 32
body: 20
17Literal
18ExprTuple21, 22
19ExprRangelambda_map: 23
start_index: 24
end_index: 25
20Operationoperator: 26
operands: 27
21Literal
22Variable
23Lambdaparameter: 32
body: 28
24Literal
25Variable
26Literal
27ExprTuple28, 29
28IndexedVarvariable: 30
index: 32
29Literal
30Variable
31ExprTuple32
32Variable