logo

Expression of type Forall

from the theory of proveit.core_expr_types.tuples

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.core_expr_types import Len, f_1_to_n, i_1_to_n, j_1_to_n
from proveit.core_expr_types.tuples import f_ik_to_jk__1_to_n, range_len_conditions, range_len_sum
from proveit.logic import Equals, Forall
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [f_1_to_n, i_1_to_n, j_1_to_n], instance_expr = Equals(Len(operands = [f_ik_to_jk__1_to_n]), range_len_sum).with_wrapping_at(1), condition = range_len_conditions).with_wrapping()
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())
\begin{array}{l}\forall_{f_{1}, f_{2}, \ldots, f_{n}, i_{1}, i_{2}, \ldots, i_{n}, j_{1}, j_{2}, \ldots, j_{n}~|~\left(\left(j_{1} - i_{1} + 1\right) \in \mathbb{N}\right), \left(\left(j_{2} - i_{2} + 1\right) \in \mathbb{N}\right), \ldots, \left(\left(j_{n} - i_{n} + 1\right) \in \mathbb{N}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} |\left(f_{1}\left(i_{1}\right), f_{1}\left(i_{1} + 1\right), \ldots, f_{1}\left(j_{1}\right), f_{2}\left(i_{2}\right), f_{2}\left(i_{2} + 1\right), \ldots, f_{2}\left(j_{2}\right), \ldots\ldots, f_{n}\left(i_{n}\right), f_{n}\left(i_{n} + 1\right), \ldots, f_{n}\left(j_{n}\right)\right)| \\  = \left(\left(j_{1} - i_{1} + 1\right) +  \left(j_{2} - i_{2} + 1\right) +  \ldots +  \left(j_{n} - i_{n} + 1\right)\right) \end{array} \end{array}\right)\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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
4ExprTuple6, 7, 8
5Conditionalvalue: 9
condition: 10
6ExprRangelambda_map: 11
start_index: 45
end_index: 31
7ExprRangelambda_map: 12
start_index: 45
end_index: 31
8ExprRangelambda_map: 13
start_index: 45
end_index: 31
9Operationoperator: 14
operands: 15
10Operationoperator: 16
operands: 17
11Lambdaparameter: 56
body: 18
12Lambdaparameter: 56
body: 52
13Lambdaparameter: 56
body: 43
14Literal
15ExprTuple19, 20
16Literal
17ExprTuple21
18IndexedVarvariable: 50
index: 56
19Operationoperator: 22
operands: 23
20Operationoperator: 40
operands: 24
21ExprRangelambda_map: 25
start_index: 45
end_index: 31
22Literal
23ExprTuple26
24ExprTuple27
25Lambdaparameter: 56
body: 28
26ExprRangelambda_map: 29
start_index: 45
end_index: 31
27ExprRangelambda_map: 30
start_index: 45
end_index: 31
28Operationoperator: 32
operands: 33
29Lambdaparameter: 53
body: 34
30Lambdaparameter: 56
body: 35
31Variable
32Literal
33ExprTuple35, 36
34ExprRangelambda_map: 37
start_index: 38
end_index: 39
35Operationoperator: 40
operands: 41
36Literal
37Lambdaparameter: 56
body: 42
38IndexedVarvariable: 54
index: 53
39IndexedVarvariable: 47
index: 53
40Literal
41ExprTuple43, 44, 45
42Operationoperator: 46
operand: 56
43IndexedVarvariable: 47
index: 56
44Operationoperator: 48
operand: 52
45Literal
46IndexedVarvariable: 50
index: 53
47Variable
48Literal
49ExprTuple52
50Variable
51ExprTuple53
52IndexedVarvariable: 54
index: 56
53Variable
54Variable
55ExprTuple56
56Variable