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, f, 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 = [f], instance_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_{f}~\left[\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]\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: 11
operand: 2
1ExprTuple2
2Lambdaparameter: 61
body: 4
3ExprTuple61
4Operationoperator: 11
operand: 6
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple77, 79
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 14
10Operationoperator: 25
operands: 13
11Literal
12ExprTuple14
13ExprTuple15, 16
14Lambdaparameters: 17
body: 18
15Operationoperator: 34
operands: 19
16Operationoperator: 34
operands: 20
17ExprTuple76, 74, 65, 66
18Conditionalvalue: 21
condition: 22
19ExprTuple77, 23
20ExprTuple79, 23
21Operationoperator: 37
operands: 24
22Operationoperator: 25
operands: 26
23Literal
24ExprTuple27, 28
25Literal
26ExprTuple29, 30, 31
27ExprTuple32
28ExprTuple33
29Operationoperator: 34
operands: 35
30Operationoperator: 37
operands: 36
31Operationoperator: 37
operands: 38
32ExprRangelambda_map: 39
start_index: 64
end_index: 40
33ExprRangelambda_map: 41
start_index: 42
end_index: 43
34Literal
35ExprTuple44, 45
36ExprTuple46, 47
37Literal
38ExprTuple48, 49
39Lambdaparameter: 82
body: 50
40Operationoperator: 80
operand: 74
41Lambdaparameter: 82
body: 52
42Operationoperator: 80
operand: 65
43Operationoperator: 80
operand: 66
44Operationoperator: 72
operands: 55
45Literal
46Operationoperator: 72
operands: 56
47Operationoperator: 72
operands: 57
48Operationoperator: 72
operands: 58
49Operationoperator: 72
operands: 59
50Operationoperator: 61
operand: 67
51ExprTuple74
52Operationoperator: 61
operand: 68
53ExprTuple65
54ExprTuple66
55ExprTuple63, 64
56ExprTuple76, 77
57ExprTuple65, 79
58ExprTuple74, 77
59ExprTuple66, 79
60ExprTuple67
61Variable
62ExprTuple68
63Operationoperator: 72
operands: 69
64Operationoperator: 80
operand: 76
65Variable
66Variable
67Operationoperator: 72
operands: 71
68Operationoperator: 72
operands: 73
69ExprTuple74, 75
70ExprTuple76
71ExprTuple78, 77
72Literal
73ExprTuple78, 79
74Variable
75Literal
76Variable
77Variable
78Operationoperator: 80
operand: 82
79Variable
80Literal
81ExprTuple82
82Variable