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
from proveit.core_expr_types import Len, f_1_to_n, i_1_to_n, j_1_to_n
from proveit.core_expr_types.tuples import f_ik_to_jk__1_to_n, range_len_conditions, range_len_sum
from proveit.logic import And, Equals
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([f_1_to_n, i_1_to_n, j_1_to_n], Conditional(Equals(Len(operands = [f_ik_to_jk__1_to_n]), range_len_sum).with_wrapping_at(1), And(range_len_conditions))))
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_{1}, f_{2}, \ldots, f_{n}, i_{1}, i_{2}, \ldots, i_{n}, j_{1}, j_{2}, \ldots, j_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} |\left(f_{1}\left(i_{1}\right), f_{1}\left(i_{1} + 1\right), \ldots, f_{1}\left(j_{1}\right), f_{2}\left(i_{2}\right), f_{2}\left(i_{2} + 1\right), \ldots, f_{2}\left(j_{2}\right), \ldots\ldots, f_{n}\left(i_{n}\right), f_{n}\left(i_{n} + 1\right), \ldots, f_{n}\left(j_{n}\right)\right)| \\  = \left(\left(j_{1} - i_{1} + 1\right) +  \left(j_{2} - i_{2} + 1\right) +  \ldots +  \left(j_{n} - i_{n} + 1\right)\right) \end{array} \end{array} \textrm{ if } \left(\left(j_{1} - i_{1} + 1\right) \in \mathbb{N}\right) \land  \left(\left(j_{2} - i_{2} + 1\right) \in \mathbb{N}\right) \land  \ldots \land  \left(\left(j_{n} - i_{n} + 1\right) \in \mathbb{N}\right)\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
2ExprTuple4, 5, 6
3Conditionalvalue: 7
condition: 8
4ExprRangelambda_map: 9
start_index: 43
end_index: 29
5ExprRangelambda_map: 10
start_index: 43
end_index: 29
6ExprRangelambda_map: 11
start_index: 43
end_index: 29
7Operationoperator: 12
operands: 13
8Operationoperator: 14
operands: 15
9Lambdaparameter: 54
body: 16
10Lambdaparameter: 54
body: 50
11Lambdaparameter: 54
body: 41
12Literal
13ExprTuple17, 18
14Literal
15ExprTuple19
16IndexedVarvariable: 48
index: 54
17Operationoperator: 20
operands: 21
18Operationoperator: 38
operands: 22
19ExprRangelambda_map: 23
start_index: 43
end_index: 29
20Literal
21ExprTuple24
22ExprTuple25
23Lambdaparameter: 54
body: 26
24ExprRangelambda_map: 27
start_index: 43
end_index: 29
25ExprRangelambda_map: 28
start_index: 43
end_index: 29
26Operationoperator: 30
operands: 31
27Lambdaparameter: 51
body: 32
28Lambdaparameter: 54
body: 33
29Variable
30Literal
31ExprTuple33, 34
32ExprRangelambda_map: 35
start_index: 36
end_index: 37
33Operationoperator: 38
operands: 39
34Literal
35Lambdaparameter: 54
body: 40
36IndexedVarvariable: 52
index: 51
37IndexedVarvariable: 45
index: 51
38Literal
39ExprTuple41, 42, 43
40Operationoperator: 44
operand: 54
41IndexedVarvariable: 45
index: 54
42Operationoperator: 46
operand: 50
43Literal
44IndexedVarvariable: 48
index: 51
45Variable
46Literal
47ExprTuple50
48Variable
49ExprTuple51
50IndexedVarvariable: 52
index: 54
51Variable
52Variable
53ExprTuple54
54Variable