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, c, d, k, m
from proveit.core_expr_types import b_1_to_n
from proveit.logic import Equals, Forall
from proveit.numbers import Add, DecimalSequence, Digits, one
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)
sub_expr3 = ExprRange(sub_expr1, IndexedVar(d, sub_expr1), one, k)
sub_expr4 = Add(b_1_to_n)
expr = Forall(instance_param_or_params = [sub_expr2, b_1_to_n, c, sub_expr3], instance_expr = Equals(DecimalSequence(sub_expr2, sub_expr4, sub_expr3), DecimalSequence(sub_expr2, c, sub_expr3)), domain = Digits, condition = Equals(sub_expr4, c))
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_{1}, b_{2}, \ldots, b_{n}, c, d_{1}, d_{2}, \ldots, d_{k} \in \mathbb{N}^{\leq 9}~|~\left(b_{1} +  b_{2} +  \ldots +  b_{n}\right) = c}~\left(\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ \left(b_{1} +  b_{2} +  \ldots +  b_{n}\right) ~ d_{1}, d_{2}, \ldots, d_{k}) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ c ~ d_{1}, d_{2}, \ldots, d_{k})\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
4ExprTuple27, 47, 33, 28
5Conditionalvalue: 6
condition: 7
6Operationoperator: 25
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15, 16, 17
11Operationoperator: 19
operands: 18
12Operationoperator: 19
operands: 20
13ExprRangelambda_map: 21
start_index: 51
end_index: 35
14ExprRangelambda_map: 22
start_index: 51
end_index: 52
15Operationoperator: 40
operands: 23
16ExprRangelambda_map: 24
start_index: 51
end_index: 37
17Operationoperator: 25
operands: 26
18ExprTuple27, 32, 28
19Literal
20ExprTuple27, 33, 28
21Lambdaparameter: 56
body: 29
22Lambdaparameter: 56
body: 30
23ExprTuple33, 46
24Lambdaparameter: 56
body: 31
25Literal
26ExprTuple32, 33
27ExprRangelambda_map: 34
start_index: 51
end_index: 35
28ExprRangelambda_map: 36
start_index: 51
end_index: 37
29Operationoperator: 40
operands: 38
30Operationoperator: 40
operands: 39
31Operationoperator: 40
operands: 41
32Operationoperator: 42
operands: 43
33Variable
34Lambdaparameter: 56
body: 44
35Variable
36Lambdaparameter: 56
body: 45
37Variable
38ExprTuple44, 46
39ExprTuple53, 46
40Literal
41ExprTuple45, 46
42Literal
43ExprTuple47
44IndexedVarvariable: 48
index: 56
45IndexedVarvariable: 49
index: 56
46Literal
47ExprRangelambda_map: 50
start_index: 51
end_index: 52
48Variable
49Variable
50Lambdaparameter: 56
body: 53
51Literal
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable