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, 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 = shift_equiv, conditions = [InSet(subtract(Add(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: 60
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 25
operands: 8
6Literal
7ExprTuple9
8ExprTuple60, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple58, 56, 34, 36
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: 58
end_index: 56
24ExprRangelambda_map: 31
start_index: 34
end_index: 36
25Literal
26ExprTuple32, 33
27ExprTuple34, 35
28Literal
29ExprTuple36, 37
30Lambdaparameter: 59
body: 38
31Lambdaparameter: 59
body: 39
32Operationoperator: 54
operands: 40
33Literal
34Variable
35Operationoperator: 54
operands: 41
36Variable
37Operationoperator: 54
operands: 42
38Operationoperator: 44
operand: 59
39Operationoperator: 44
operand: 49
40ExprTuple46, 47
41ExprTuple58, 48
42ExprTuple56, 48
43ExprTuple59
44Variable
45ExprTuple49
46Operationoperator: 54
operands: 50
47Operationoperator: 52
operand: 58
48Operationoperator: 52
operand: 60
49Operationoperator: 54
operands: 55
50ExprTuple56, 57
51ExprTuple58
52Literal
53ExprTuple60
54Literal
55ExprTuple59, 60
56Variable
57Literal
58Variable
59Variable
60Variable