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 import a, b, i, j, k, l
from proveit.core_expr_types.tuples import neg_shift_equiv_both
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Add, Integer, Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [a, b], instance_expr = Forall(instance_param_or_params = [i, j, k, l], instance_expr = neg_shift_equiv_both, conditions = [InSet(subtract(Add(j, one), i), Natural), Equals(Add(i, a), Add(k, b)), Equals(Add(j, a), Add(l, b))]), domain = Integer)
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, b \in \mathbb{Z}}~\left[\forall_{i, j, k, l~|~\left(\left(j + 1\right) - i\right) \in \mathbb{N}, \left(i + a\right) = \left(k + b\right), \left(j + a\right) = \left(l + b\right)}~\left(\left(f\left(i + a\right), f\left(\left(i - 1\right) + a\right), \ldots, f\left(j + a\right)\right) = \left(f\left(k + b\right), f\left(\left(k - 1\right) + b\right), \ldots, f\left(l + b\right)\right)\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
3ExprTuple73, 75
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 21
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 30
operands: 15
12Operationoperator: 30
operands: 16
13ExprTuple72, 70, 61, 62
14Conditionalvalue: 17
condition: 18
15ExprTuple73, 19
16ExprTuple75, 19
17Operationoperator: 33
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27
23ExprTuple28
24ExprTuple29
25Operationoperator: 30
operands: 31
26Operationoperator: 33
operands: 32
27Operationoperator: 33
operands: 34
28ExprRangelambda_map: 35
start_index: 60
end_index: 36
29ExprRangelambda_map: 37
start_index: 38
end_index: 39
30Literal
31ExprTuple40, 41
32ExprTuple42, 43
33Literal
34ExprTuple44, 45
35Lambdaparameter: 78
body: 46
36Operationoperator: 76
operand: 70
37Lambdaparameter: 78
body: 48
38Operationoperator: 76
operand: 61
39Operationoperator: 76
operand: 62
40Operationoperator: 68
operands: 51
41Literal
42Operationoperator: 68
operands: 52
43Operationoperator: 68
operands: 53
44Operationoperator: 68
operands: 54
45Operationoperator: 68
operands: 55
46Operationoperator: 57
operand: 63
47ExprTuple70
48Operationoperator: 57
operand: 64
49ExprTuple61
50ExprTuple62
51ExprTuple59, 60
52ExprTuple72, 73
53ExprTuple61, 75
54ExprTuple70, 73
55ExprTuple62, 75
56ExprTuple63
57Variable
58ExprTuple64
59Operationoperator: 68
operands: 65
60Operationoperator: 76
operand: 72
61Variable
62Variable
63Operationoperator: 68
operands: 67
64Operationoperator: 68
operands: 69
65ExprTuple70, 71
66ExprTuple72
67ExprTuple74, 73
68Literal
69ExprTuple74, 75
70Variable
71Literal
72Variable
73Variable
74Operationoperator: 76
operand: 78
75Variable
76Literal
77ExprTuple78
78Variable