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, i, j, n
from proveit.core_expr_types import Len, f_1_to_n, i_to_j_len
from proveit.core_expr_types.tuples import f_i_to_j__1_to_n
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Mult, Natural, 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, j], instance_expr = Equals(Len(operands = [f_i_to_j__1_to_n]), Mult(n, i_to_j_len)).with_wrapping_at(1), condition = InSet(i_to_j_len, Natural)), 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\{\forall_{f_{1}, f_{2}, \ldots, f_{n}, i, j~|~\left(j - i + 1\right) \in \mathbb{N}}~\left(\begin{array}{c} \begin{array}{l} |\left(f_{1}\left(i\right), f_{1}\left(i + 1\right), \ldots, f_{1}\left(j\right), f_{2}\left(i\right), f_{2}\left(i + 1\right), \ldots, f_{2}\left(j\right), \ldots\ldots, f_{n}\left(i\right), f_{n}\left(i + 1\right), \ldots, f_{n}\left(j\right)\right)| \\  = \left(n \cdot \left(j - i + 1\right)\right) \end{array} \end{array}\right) \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: 32
body: 3
2ExprTuple32
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 19
operands: 8
6Literal
7ExprTuple9
8ExprTuple32, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13, 43, 39
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 37
end_index: 32
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Lambdaparameter: 48
body: 21
17Literal
18ExprTuple22, 23
19Literal
20ExprTuple30, 24
21IndexedVarvariable: 46
index: 48
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29
27Literal
28ExprTuple32, 30
29ExprRangelambda_map: 31
start_index: 37
end_index: 32
30Operationoperator: 33
operands: 34
31Lambdaparameter: 49
body: 35
32Variable
33Literal
34ExprTuple39, 36, 37
35ExprRangelambda_map: 38
start_index: 43
end_index: 39
36Operationoperator: 40
operand: 43
37Literal
38Lambdaparameter: 48
body: 42
39Variable
40Literal
41ExprTuple43
42Operationoperator: 44
operand: 48
43Variable
44IndexedVarvariable: 46
index: 49
45ExprTuple48
46Variable
47ExprTuple49
48Variable
49Variable