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, n
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 Equals, Forall, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [f_1_to_n, i_1_to_n, j_1_to_n], instance_expr = Equals(Len(operands = [f_ik_to_jk__1_to_n]), range_len_sum).with_wrapping_at(1), condition = range_len_conditions).with_wrapping(), InSet(n, NaturalPos))))
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(n \mapsto \left\{\begin{array}{l}\forall_{f_{1}, f_{2}, \ldots, f_{n}, i_{1}, i_{2}, \ldots, i_{n}, j_{1}, j_{2}, \ldots, j_{n}~|~\left(\left(j_{1} - i_{1} + 1\right) \in \mathbb{N}\right), \left(\left(j_{2} - i_{2} + 1\right) \in \mathbb{N}\right), \ldots, \left(\left(j_{n} - i_{n} + 1\right) \in \mathbb{N}\right)}~\\
\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}\right)\end{array} \textrm{ if } n \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
1Lambdaparameter: 38
body: 3
2ExprTuple38
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 39
operands: 8
6Literal
7ExprTuple9
8ExprTuple38, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13, 14, 15
12Conditionalvalue: 16
condition: 17
13ExprRangelambda_map: 18
start_index: 52
end_index: 38
14ExprRangelambda_map: 19
start_index: 52
end_index: 38
15ExprRangelambda_map: 20
start_index: 52
end_index: 38
16Operationoperator: 21
operands: 22
17Operationoperator: 23
operands: 24
18Lambdaparameter: 63
body: 25
19Lambdaparameter: 63
body: 59
20Lambdaparameter: 63
body: 50
21Literal
22ExprTuple26, 27
23Literal
24ExprTuple28
25IndexedVarvariable: 57
index: 63
26Operationoperator: 29
operands: 30
27Operationoperator: 47
operands: 31
28ExprRangelambda_map: 32
start_index: 52
end_index: 38
29Literal
30ExprTuple33
31ExprTuple34
32Lambdaparameter: 63
body: 35
33ExprRangelambda_map: 36
start_index: 52
end_index: 38
34ExprRangelambda_map: 37
start_index: 52
end_index: 38
35Operationoperator: 39
operands: 40
36Lambdaparameter: 60
body: 41
37Lambdaparameter: 63
body: 42
38Variable
39Literal
40ExprTuple42, 43
41ExprRangelambda_map: 44
start_index: 45
end_index: 46
42Operationoperator: 47
operands: 48
43Literal
44Lambdaparameter: 63
body: 49
45IndexedVarvariable: 61
index: 60
46IndexedVarvariable: 54
index: 60
47Literal
48ExprTuple50, 51, 52
49Operationoperator: 53
operand: 63
50IndexedVarvariable: 54
index: 63
51Operationoperator: 55
operand: 59
52Literal
53IndexedVarvariable: 57
index: 60
54Variable
55Literal
56ExprTuple59
57Variable
58ExprTuple60
59IndexedVarvariable: 61
index: 63
60Variable
61Variable
62ExprTuple63
63Variable