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, c, d, k, m, n
from proveit.logic import Equals, Forall
from proveit.numbers import 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, b, one, n)
sub_expr3 = ExprRange(sub_expr1, IndexedVar(a, sub_expr1), one, m)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, n)
sub_expr5 = ExprRange(sub_expr1, IndexedVar(d, sub_expr1), one, k)
expr = Forall(instance_param_or_params = [sub_expr3, b, sub_expr4, sub_expr5], instance_expr = Equals(DecimalSequence(sub_expr3, sub_expr2, sub_expr5), DecimalSequence(sub_expr3, sub_expr4, sub_expr5)), domain = Digits, condition = Equals([sub_expr2], [sub_expr4]))
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, c_{1}, c_{2}, \ldots, c_{n}, d_{1}, d_{2}, \ldots, d_{k} \in \mathbb{N}^{\leq 9}~|~\left(b, b, ..\left(n - 3\right) \times.., b\right) = \left(c_{1}, c_{2}, \ldots, c_{n}\right)}~\left(\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ b, b, ..\left(n - 3\right) \times.., b ~ d_{1}, d_{2}, \ldots, d_{k}) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ c_{1}, c_{2}, \ldots, c_{n} ~ 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, 53, 43, 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: 49
end_index: 35
14Operationoperator: 40
operands: 22
15ExprRangelambda_map: 23
start_index: 49
end_index: 50
16ExprRangelambda_map: 24
start_index: 49
end_index: 37
17Operationoperator: 25
operands: 26
18ExprTuple27, 42, 28
19Literal
20ExprTuple27, 43, 28
21Lambdaparameter: 57
body: 29
22ExprTuple53, 46
23Lambdaparameter: 57
body: 30
24Lambdaparameter: 57
body: 31
25Literal
26ExprTuple32, 33
27ExprRangelambda_map: 34
start_index: 49
end_index: 35
28ExprRangelambda_map: 36
start_index: 49
end_index: 37
29Operationoperator: 40
operands: 38
30Operationoperator: 40
operands: 39
31Operationoperator: 40
operands: 41
32ExprTuple42
33ExprTuple43
34Lambdaparameter: 57
body: 44
35Variable
36Lambdaparameter: 57
body: 45
37Variable
38ExprTuple44, 46
39ExprTuple54, 46
40Literal
41ExprTuple45, 46
42ExprRangelambda_map: 47
start_index: 49
end_index: 50
43ExprRangelambda_map: 48
start_index: 49
end_index: 50
44IndexedVarvariable: 51
index: 57
45IndexedVarvariable: 52
index: 57
46Literal
47Lambdaparameter: 57
body: 53
48Lambdaparameter: 57
body: 54
49Literal
50Variable
51Variable
52Variable
53Variable
54IndexedVarvariable: 55
index: 57
55Variable
56ExprTuple57
57Variable