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, 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_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
4ExprTuple56, 54, 44, 45
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: 56
end_index: 54
17ExprRangelambda_map: 24
start_index: 44
end_index: 45
18Literal
19ExprTuple25, 26
20ExprTuple27, 28
21Literal
22ExprTuple29, 30
23Lambdaparameter: 58
body: 31
24Lambdaparameter: 58
body: 33
25Operationoperator: 52
operands: 34
26Literal
27Operationoperator: 52
operands: 35
28Operationoperator: 52
operands: 36
29Operationoperator: 52
operands: 37
30Operationoperator: 52
operands: 38
31Operationoperator: 40
operand: 46
32ExprTuple58
33Operationoperator: 40
operand: 47
34ExprTuple42, 43
35ExprTuple56, 57
36ExprTuple44, 59
37ExprTuple54, 57
38ExprTuple45, 59
39ExprTuple46
40Variable
41ExprTuple47
42Operationoperator: 52
operands: 48
43Operationoperator: 49
operand: 56
44Variable
45Variable
46Operationoperator: 52
operands: 51
47Operationoperator: 52
operands: 53
48ExprTuple54, 55
49Literal
50ExprTuple56
51ExprTuple58, 57
52Literal
53ExprTuple58, 59
54Variable
55Literal
56Variable
57Variable
58Variable
59Variable