# 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 f, i, j, k, l
from proveit.core_expr_types import merge_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 = [f, i, j, k, l], instance_expr = merge_equiv, conditions = [InSet(subtract(k, i), Natural), InSet(subtract(l, j), Natural), Equals(k, Add(j, one))])

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_{f, i, j, k, l~|~\left(k - i\right) \in \mathbb{N}, \left(l - j\right) \in \mathbb{N}, k = \left(j + 1\right)}~\left(\begin{array}{c} \begin{array}{l} \left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right),f\left(k\right), f\left(k + 1\right), \ldots, f\left(l\right)\right) =  \\ \left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(l\right)\right) \end{array} \end{array}\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
4ExprTuple34, 45, 46, 36, 38
5Conditionalvalue: 6
condition: 7
6Operationoperator: 22
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11ExprTuple16, 17
12ExprTuple18
13Operationoperator: 20
operands: 19
14Operationoperator: 20
operands: 21
15Operationoperator: 22
operands: 23
16ExprRangelambda_map: 24
start_index: 45
end_index: 46
17ExprRangelambda_map: 24
start_index: 36
end_index: 38
18ExprRangelambda_map: 24
start_index: 45
end_index: 38
19ExprTuple25, 27
20Literal
21ExprTuple26, 27
22Literal
23ExprTuple36, 28
24Lambdaparameter: 41
body: 29
25Operationoperator: 32
operands: 30
26Operationoperator: 32
operands: 31
27Literal
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operand: 41
30ExprTuple36, 37
31ExprTuple38, 39
32Literal
33ExprTuple46, 40
34Variable
35ExprTuple41
36Variable
37Operationoperator: 43
operand: 45
38Variable
39Operationoperator: 43
operand: 46
40Literal
41Variable
42ExprTuple45
43Literal
44ExprTuple46
45Variable
46Variable