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, n
from proveit.core_expr_types import b_1_to_n
from proveit.logic import Equals, Forall
from proveit.numbers import Add, DecimalSequence, Digits, Natural, 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 = [m, n, k], instance_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)), domain = 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())
\forall_{m, n, k \in \mathbb{N}}~\left[\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)\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: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple49, 66, 51
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 23
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12, 13
10Lambdaparameters: 14
body: 15
11Operationoperator: 54
operands: 16
12Operationoperator: 54
operands: 17
13Operationoperator: 54
operands: 18
14ExprTuple41, 61, 47, 42
15Conditionalvalue: 19
condition: 20
16ExprTuple49, 21
17ExprTuple66, 21
18ExprTuple51, 21
19Operationoperator: 39
operands: 22
20Operationoperator: 23
operands: 24
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28, 29, 30, 31
25Operationoperator: 33
operands: 32
26Operationoperator: 33
operands: 34
27ExprRangelambda_map: 35
start_index: 65
end_index: 49
28ExprRangelambda_map: 36
start_index: 65
end_index: 66
29Operationoperator: 54
operands: 37
30ExprRangelambda_map: 38
start_index: 65
end_index: 51
31Operationoperator: 39
operands: 40
32ExprTuple41, 46, 42
33Literal
34ExprTuple41, 47, 42
35Lambdaparameter: 70
body: 43
36Lambdaparameter: 70
body: 44
37ExprTuple47, 60
38Lambdaparameter: 70
body: 45
39Literal
40ExprTuple46, 47
41ExprRangelambda_map: 48
start_index: 65
end_index: 49
42ExprRangelambda_map: 50
start_index: 65
end_index: 51
43Operationoperator: 54
operands: 52
44Operationoperator: 54
operands: 53
45Operationoperator: 54
operands: 55
46Operationoperator: 56
operands: 57
47Variable
48Lambdaparameter: 70
body: 58
49Variable
50Lambdaparameter: 70
body: 59
51Variable
52ExprTuple58, 60
53ExprTuple67, 60
54Literal
55ExprTuple59, 60
56Literal
57ExprTuple61
58IndexedVarvariable: 62
index: 70
59IndexedVarvariable: 63
index: 70
60Literal
61ExprRangelambda_map: 64
start_index: 65
end_index: 66
62Variable
63Variable
64Lambdaparameter: 70
body: 67
65Literal
66Variable
67IndexedVarvariable: 68
index: 70
68Variable
69ExprTuple70
70Variable