logo

Expression of type ExprTuple

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 Conditional, ExprTuple, Lambda, f, i, j
from proveit.core_expr_types import merge_series_conditions, merge_series_equiv, x_0_to_jmi
from proveit.logic import Forall, InSet
from proveit.numbers import Natural, subtract
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([f, i, j], Conditional(Forall(instance_param_or_params = [x_0_to_jmi], instance_expr = merge_series_equiv, condition = merge_series_conditions), InSet(subtract(j, i), Natural))))
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())
\left(\left(f, i, j\right) \mapsto \left\{\forall_{x_{0}, x_{1}, \ldots, x_{j - i}~|~\left(x_{0} = f\left(i + 0\right)\right), \left(x_{1} = f\left(i + 1\right)\right), \ldots, \left(x_{j - i} = f\left(i + \left(j - i\right)\right)\right)}~\left(\begin{array}{c} \begin{array}{l} \left(x_{0}, x_{1}, \ldots, x_{j - i}\right) =  \\ \left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) \end{array} \end{array}\right) \textrm{ if } \left(j - i\right) \in \mathbb{N}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple41, 46, 33
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple26, 11
10Lambdaparameters: 18
body: 12
11Literal
12Conditionalvalue: 13
condition: 14
13Operationoperator: 31
operands: 15
14Operationoperator: 16
operands: 17
15ExprTuple18, 19
16Literal
17ExprTuple20
18ExprTuple21
19ExprTuple22
20ExprRangelambda_map: 23
start_index: 25
end_index: 26
21ExprRangelambda_map: 24
start_index: 25
end_index: 26
22ExprRangelambda_map: 27
start_index: 46
end_index: 33
23Lambdaparameter: 47
body: 28
24Lambdaparameter: 47
body: 35
25Literal
26Operationoperator: 44
operands: 29
27Lambdaparameter: 47
body: 30
28Operationoperator: 31
operands: 32
29ExprTuple33, 34
30Operationoperator: 41
operand: 47
31Literal
32ExprTuple35, 36
33Variable
34Operationoperator: 37
operand: 46
35IndexedVarvariable: 39
index: 47
36Operationoperator: 41
operand: 43
37Literal
38ExprTuple46
39Variable
40ExprTuple47
41Variable
42ExprTuple43
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Variable
47Variable