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 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, conditions = [InSet(subtract(subtract(j, one), i), Natural), Equals(k, subtract(i, a)), Equals(l, subtract(j, a))])
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}, 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)
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
4ExprTuple56, 54, 43, 44
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: 46
end_index: 24
17ExprRangelambda_map: 25
start_index: 26
end_index: 27
18Literal
19ExprTuple28, 29
20ExprTuple43, 30
21Literal
22ExprTuple44, 31
23Lambdaparameter: 63
body: 32
24Operationoperator: 60
operand: 54
25Lambdaparameter: 63
body: 34
26Operationoperator: 60
operand: 43
27Operationoperator: 60
operand: 44
28Operationoperator: 52
operands: 37
29Literal
30Operationoperator: 52
operands: 38
31Operationoperator: 52
operands: 39
32Operationoperator: 41
operand: 57
33ExprTuple54
34Operationoperator: 41
operand: 48
35ExprTuple43
36ExprTuple44
37ExprTuple45, 46
38ExprTuple56, 47
39ExprTuple54, 47
40ExprTuple57
41Variable
42ExprTuple48
43Variable
44Variable
45Operationoperator: 52
operands: 49
46Operationoperator: 60
operand: 56
47Operationoperator: 60
operand: 58
48Operationoperator: 52
operands: 53
49ExprTuple54, 55
50ExprTuple56
51ExprTuple58
52Literal
53ExprTuple57, 58
54Variable
55Operationoperator: 60
operand: 62
56Variable
57Operationoperator: 60
operand: 63
58Variable
59ExprTuple62
60Literal
61ExprTuple63
62Literal
63Variable