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, n
from proveit.core_expr_types import Len, f_1_to_n
from proveit.core_expr_types.tuples import f_1_to_i__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], instance_expr = Equals(Len(operands = [f_1_to_i__1_to_n]), Mult(n, i)).with_wrapping_at(1), condition = InSet(i, 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~|~i \in \mathbb{N}}~\left(\begin{array}{c} \begin{array}{l} |\left(f_{1}\left(1\right), f_{1}\left(2\right), \ldots, f_{1}\left(i\right), f_{2}\left(1\right), f_{2}\left(2\right), \ldots, f_{2}\left(i\right), \ldots\ldots, f_{n}\left(1\right), f_{n}\left(2\right), \ldots, f_{n}\left(i\right)\right)| \\  = \left(n \cdot i\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: 31
body: 3
2ExprTuple31
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 19
operands: 8
6Literal
7ExprTuple9
8ExprTuple31, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13, 35
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 34
end_index: 31
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Lambdaparameter: 41
body: 21
17Literal
18ExprTuple22, 23
19Literal
20ExprTuple35, 24
21IndexedVarvariable: 39
index: 41
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29
27Literal
28ExprTuple31, 35
29ExprRangelambda_map: 30
start_index: 34
end_index: 31
30Lambdaparameter: 42
body: 32
31Variable
32ExprRangelambda_map: 33
start_index: 34
end_index: 35
33Lambdaparameter: 41
body: 36
34Literal
35Variable
36Operationoperator: 37
operand: 41
37IndexedVarvariable: 39
index: 42
38ExprTuple41
39Variable
40ExprTuple42
41Variable
42Variable