# 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.
# import Expression classes needed to build the expression
from proveit import f, i, j, k
from proveit.core_expr_types import merge_front_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], instance_expr = merge_front_equiv, conditions = [InSet(subtract(k, i), Natural), Equals(j, Add(i, 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~|~\left(k - i\right) \in \mathbb{N}, j = \left(i + 1\right)}~\left(\begin{array}{c} \begin{array}{l} \left(f\left(i\right),f\left(j\right), f\left(j + 1\right), \ldots, f\left(k\right)\right) =  \\ \left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(k\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
4ExprTuple31, 39, 25, 33
5Conditionalvalue: 6
condition: 7
6Operationoperator: 20
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11ExprTuple15, 16
12ExprTuple17
13Operationoperator: 18
operands: 19
14Operationoperator: 20
operands: 21
15Operationoperator: 31
operand: 39
16ExprRangelambda_map: 22
start_index: 25
end_index: 33
17ExprRangelambda_map: 22
start_index: 39
end_index: 33
18Literal
19ExprTuple23, 24
20Literal
21ExprTuple25, 26
22Lambdaparameter: 36
body: 27
23Operationoperator: 29
operands: 28
24Literal
25Variable
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operand: 36
28ExprTuple33, 34
29Literal
30ExprTuple39, 35
31Variable
32ExprTuple36
33Variable
34Operationoperator: 37
operand: 39
35Literal
36Variable
37Literal
38ExprTuple39
39Variable