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, Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
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))])
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_{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)
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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple60, 58, 49, 50
5Conditionalvalue: 6
condition: 7
6Operationoperator: 21
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11ExprTuple16
12ExprTuple17
13Operationoperator: 18
operands: 19
14Operationoperator: 21
operands: 20
15Operationoperator: 21
operands: 22
16ExprRangelambda_map: 23
start_index: 48
end_index: 24
17ExprRangelambda_map: 25
start_index: 26
end_index: 27
18Literal
19ExprTuple28, 29
20ExprTuple30, 31
21Literal
22ExprTuple32, 33
23Lambdaparameter: 66
body: 34
24Operationoperator: 64
operand: 58
25Lambdaparameter: 66
body: 36
26Operationoperator: 64
operand: 49
27Operationoperator: 64
operand: 50
28Operationoperator: 56
operands: 39
29Literal
30Operationoperator: 56
operands: 40
31Operationoperator: 56
operands: 41
32Operationoperator: 56
operands: 42
33Operationoperator: 56
operands: 43
34Operationoperator: 45
operand: 51
35ExprTuple58
36Operationoperator: 45
operand: 52
37ExprTuple49
38ExprTuple50
39ExprTuple47, 48
40ExprTuple60, 61
41ExprTuple49, 63
42ExprTuple58, 61
43ExprTuple50, 63
44ExprTuple51
45Variable
46ExprTuple52
47Operationoperator: 56
operands: 53
48Operationoperator: 64
operand: 60
49Variable
50Variable
51Operationoperator: 56
operands: 55
52Operationoperator: 56
operands: 57
53ExprTuple58, 59
54ExprTuple60
55ExprTuple62, 61
56Literal
57ExprTuple62, 63
58Variable
59Literal
60Variable
61Variable
62Operationoperator: 64
operand: 66
63Variable
64Literal
65ExprTuple66
66Variable