logo

Expression of type Forall

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 ExprRange, IndexedVar, Variable, a, b, k, m
from proveit.logic import Equals, Forall
from proveit.numbers import Add, DecimalSequence, Digits, Less, 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 = 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))
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())
\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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple34, 36
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15, 16
12Operationoperator: 29
operands: 17
13Operationoperator: 27
operands: 18
14ExprRangelambda_map: 19
start_index: 42
end_index: 40
15Operationoperator: 32
operands: 20
16Operationoperator: 21
operands: 22
17ExprTuple23, 42
18ExprTuple34, 24, 25
19Lambdaparameter: 48
body: 26
20ExprTuple36, 38
21Literal
22ExprTuple36, 45
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25ExprRangelambda_map: 31
start_index: 42
end_index: 43
26Operationoperator: 32
operands: 33
27Literal
28ExprTuple34, 36, 35
29Literal
30ExprTuple36, 42
31Lambdaparameter: 48
body: 37
32Literal
33ExprTuple44, 38
34ExprRangelambda_map: 39
start_index: 42
end_index: 40
35ExprRangelambda_map: 41
start_index: 42
end_index: 43
36Variable
37Literal
38Literal
39Lambdaparameter: 48
body: 44
40Variable
41Lambdaparameter: 48
body: 45
42Literal
43Variable
44IndexedVarvariable: 46
index: 48
45Literal
46Variable
47ExprTuple48
48Variable