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 shift_equiv_both
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, b], instance_expr = Forall(instance_param_or_params = [i, j, k, l], instance_expr = 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))]), 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, b \in \mathbb{Z}}~\left[\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)\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: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple69, 71
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 21
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 30
operands: 15
12Operationoperator: 30
operands: 16
13ExprTuple68, 66, 56, 57
14Conditionalvalue: 17
condition: 18
15ExprTuple69, 19
16ExprTuple71, 19
17Operationoperator: 33
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27
23ExprTuple28
24ExprTuple29
25Operationoperator: 30
operands: 31
26Operationoperator: 33
operands: 32
27Operationoperator: 33
operands: 34
28ExprRangelambda_map: 35
start_index: 68
end_index: 66
29ExprRangelambda_map: 36
start_index: 56
end_index: 57
30Literal
31ExprTuple37, 38
32ExprTuple39, 40
33Literal
34ExprTuple41, 42
35Lambdaparameter: 70
body: 43
36Lambdaparameter: 70
body: 45
37Operationoperator: 64
operands: 46
38Literal
39Operationoperator: 64
operands: 47
40Operationoperator: 64
operands: 48
41Operationoperator: 64
operands: 49
42Operationoperator: 64
operands: 50
43Operationoperator: 52
operand: 58
44ExprTuple70
45Operationoperator: 52
operand: 59
46ExprTuple54, 55
47ExprTuple68, 69
48ExprTuple56, 71
49ExprTuple66, 69
50ExprTuple57, 71
51ExprTuple58
52Variable
53ExprTuple59
54Operationoperator: 64
operands: 60
55Operationoperator: 61
operand: 68
56Variable
57Variable
58Operationoperator: 64
operands: 63
59Operationoperator: 64
operands: 65
60ExprTuple66, 67
61Literal
62ExprTuple68
63ExprTuple70, 69
64Literal
65ExprTuple70, 71
66Variable
67Literal
68Variable
69Variable
70Variable
71Variable