logo

Expression of type Conditional

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, IndexedVar, Variable, a, b, k, m
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, DecimalSequence, Digits, Less, Natural, nine, one, zero
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)
expr = Conditional(Forall(instance_param_or_params = [sub_expr2, b], instance_expr = Equals(Add(DecimalSequence(sub_expr2, b, ExprRange(sub_expr1, nine, one, k)), one), DecimalSequence(sub_expr2, Add(b, one), ExprRange(sub_expr1, zero, one, k))), domain = Digits, condition = Less(b, nine)), And(InSet(m, 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\{\forall_{a_{1}, a_{2}, \ldots, a_{m}, b \in \mathbb{N}^{\leq 9}~|~b < 9}~\left(\left(\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ b ~ 9, 9, ..\left(k - 3\right) \times.., 9) + 1\right) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ \left(b + 1\right) ~ 0, 0, ..\left(k - 3\right) \times.., 0)\right) \textrm{ if } m \in \mathbb{N} ,  k \in \mathbb{N}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 18
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 40
operands: 11
8Operationoperator: 40
operands: 12
9ExprTuple42, 44
10Conditionalvalue: 13
condition: 14
11ExprTuple48, 15
12ExprTuple51, 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Literal
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23, 24
20Operationoperator: 37
operands: 25
21Operationoperator: 35
operands: 26
22ExprRangelambda_map: 27
start_index: 50
end_index: 48
23Operationoperator: 40
operands: 28
24Operationoperator: 29
operands: 30
25ExprTuple31, 50
26ExprTuple42, 32, 33
27Lambdaparameter: 56
body: 34
28ExprTuple44, 46
29Literal
30ExprTuple44, 53
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operands: 38
33ExprRangelambda_map: 39
start_index: 50
end_index: 51
34Operationoperator: 40
operands: 41
35Literal
36ExprTuple42, 44, 43
37Literal
38ExprTuple44, 50
39Lambdaparameter: 56
body: 45
40Literal
41ExprTuple52, 46
42ExprRangelambda_map: 47
start_index: 50
end_index: 48
43ExprRangelambda_map: 49
start_index: 50
end_index: 51
44Variable
45Literal
46Literal
47Lambdaparameter: 56
body: 52
48Variable
49Lambdaparameter: 56
body: 53
50Literal
51Variable
52IndexedVarvariable: 54
index: 56
53Literal
54Variable
55ExprTuple56
56Variable