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, 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 = [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_{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]
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: 6
operand: 2
1ExprTuple2
2Lambdaparameter: 65
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 25
operands: 8
6Literal
7ExprTuple9
8ExprTuple65, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple63, 61, 50, 51
12Conditionalvalue: 13
condition: 14
13Operationoperator: 28
operands: 15
14Operationoperator: 16
operands: 17
15ExprTuple18, 19
16Literal
17ExprTuple20, 21, 22
18ExprTuple23
19ExprTuple24
20Operationoperator: 25
operands: 26
21Operationoperator: 28
operands: 27
22Operationoperator: 28
operands: 29
23ExprRangelambda_map: 30
start_index: 53
end_index: 31
24ExprRangelambda_map: 32
start_index: 33
end_index: 34
25Literal
26ExprTuple35, 36
27ExprTuple50, 37
28Literal
29ExprTuple51, 38
30Lambdaparameter: 70
body: 39
31Operationoperator: 67
operand: 61
32Lambdaparameter: 70
body: 41
33Operationoperator: 67
operand: 50
34Operationoperator: 67
operand: 51
35Operationoperator: 59
operands: 44
36Literal
37Operationoperator: 59
operands: 45
38Operationoperator: 59
operands: 46
39Operationoperator: 48
operand: 64
40ExprTuple61
41Operationoperator: 48
operand: 55
42ExprTuple50
43ExprTuple51
44ExprTuple52, 53
45ExprTuple63, 54
46ExprTuple61, 54
47ExprTuple64
48Variable
49ExprTuple55
50Variable
51Variable
52Operationoperator: 59
operands: 56
53Operationoperator: 67
operand: 63
54Operationoperator: 67
operand: 65
55Operationoperator: 59
operands: 60
56ExprTuple61, 62
57ExprTuple63
58ExprTuple65
59Literal
60ExprTuple64, 65
61Variable
62Operationoperator: 67
operand: 69
63Variable
64Operationoperator: 67
operand: 70
65Variable
66ExprTuple69
67Literal
68ExprTuple70
69Literal
70Variable