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, f, i, j, k, l
from proveit.core_expr_types.tuples import neg_shift_equiv
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import 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], instance_expr = Forall(instance_param_or_params = [i, j, k, l], instance_expr = neg_shift_equiv, conditions = [InSet(subtract(subtract(j, one), i), Natural), Equals(k, subtract(i, a)), Equals(l, subtract(j, a))]), 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 \in \mathbb{Z}}~\left[\forall_{i, j, k, l~|~\left(\left(j - 1\right) - i\right) \in \mathbb{N}, k = \left(i - a\right), l = \left(j - a\right)}~\left(\left(f\left(i\right), f\left(i - 1\right), \ldots, f\left(j\right)\right) = \left(f\left(k + a\right), f\left(\left(k - 1\right) + a\right), \ldots, f\left(l + a\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: 10
operand: 2
1ExprTuple2
2Lambdaparameter: 52
body: 4
3ExprTuple52
4Operationoperator: 10
operand: 6
5ExprTuple6
6Lambdaparameter: 69
body: 7
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 13
9Operationoperator: 29
operands: 12
10Literal
11ExprTuple13
12ExprTuple69, 14
13Lambdaparameters: 15
body: 16
14Literal
15ExprTuple67, 65, 54, 55
16Conditionalvalue: 17
condition: 18
17Operationoperator: 32
operands: 19
18Operationoperator: 20
operands: 21
19ExprTuple22, 23
20Literal
21ExprTuple24, 25, 26
22ExprTuple27
23ExprTuple28
24Operationoperator: 29
operands: 30
25Operationoperator: 32
operands: 31
26Operationoperator: 32
operands: 33
27ExprRangelambda_map: 34
start_index: 57
end_index: 35
28ExprRangelambda_map: 36
start_index: 37
end_index: 38
29Literal
30ExprTuple39, 40
31ExprTuple54, 41
32Literal
33ExprTuple55, 42
34Lambdaparameter: 74
body: 43
35Operationoperator: 71
operand: 65
36Lambdaparameter: 74
body: 45
37Operationoperator: 71
operand: 54
38Operationoperator: 71
operand: 55
39Operationoperator: 63
operands: 48
40Literal
41Operationoperator: 63
operands: 49
42Operationoperator: 63
operands: 50
43Operationoperator: 52
operand: 68
44ExprTuple65
45Operationoperator: 52
operand: 59
46ExprTuple54
47ExprTuple55
48ExprTuple56, 57
49ExprTuple67, 58
50ExprTuple65, 58
51ExprTuple68
52Variable
53ExprTuple59
54Variable
55Variable
56Operationoperator: 63
operands: 60
57Operationoperator: 71
operand: 67
58Operationoperator: 71
operand: 69
59Operationoperator: 63
operands: 64
60ExprTuple65, 66
61ExprTuple67
62ExprTuple69
63Literal
64ExprTuple68, 69
65Variable
66Operationoperator: 71
operand: 73
67Variable
68Operationoperator: 71
operand: 74
69Variable
70ExprTuple73
71Literal
72ExprTuple74
73Literal
74Variable