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 shift_equiv
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 = shift_equiv, conditions = [InSet(subtract(Add(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
4ExprTuple51, 49, 27, 29
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: 51
end_index: 49
17ExprRangelambda_map: 24
start_index: 27
end_index: 29
18Literal
19ExprTuple25, 26
20ExprTuple27, 28
21Literal
22ExprTuple29, 30
23Lambdaparameter: 52
body: 31
24Lambdaparameter: 52
body: 32
25Operationoperator: 47
operands: 33
26Literal
27Variable
28Operationoperator: 47
operands: 34
29Variable
30Operationoperator: 47
operands: 35
31Operationoperator: 37
operand: 52
32Operationoperator: 37
operand: 42
33ExprTuple39, 40
34ExprTuple51, 41
35ExprTuple49, 41
36ExprTuple52
37Variable
38ExprTuple42
39Operationoperator: 47
operands: 43
40Operationoperator: 45
operand: 51
41Operationoperator: 45
operand: 53
42Operationoperator: 47
operands: 48
43ExprTuple49, 50
44ExprTuple51
45Literal
46ExprTuple53
47Literal
48ExprTuple52, 53
49Variable
50Literal
51Variable
52Variable
53Variable