logo

Expression of type Lambda

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, 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 = 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())
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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 37
body: 2
1ExprTuple37
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 38
operands: 7
5Literal
6ExprTuple8
7ExprTuple37, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple12, 13, 14
11Conditionalvalue: 15
condition: 16
12ExprRangelambda_map: 17
start_index: 51
end_index: 37
13ExprRangelambda_map: 18
start_index: 51
end_index: 37
14ExprRangelambda_map: 19
start_index: 51
end_index: 37
15Operationoperator: 20
operands: 21
16Operationoperator: 22
operands: 23
17Lambdaparameter: 62
body: 24
18Lambdaparameter: 62
body: 58
19Lambdaparameter: 62
body: 49
20Literal
21ExprTuple25, 26
22Literal
23ExprTuple27
24IndexedVarvariable: 56
index: 62
25Operationoperator: 28
operands: 29
26Operationoperator: 46
operands: 30
27ExprRangelambda_map: 31
start_index: 51
end_index: 37
28Literal
29ExprTuple32
30ExprTuple33
31Lambdaparameter: 62
body: 34
32ExprRangelambda_map: 35
start_index: 51
end_index: 37
33ExprRangelambda_map: 36
start_index: 51
end_index: 37
34Operationoperator: 38
operands: 39
35Lambdaparameter: 59
body: 40
36Lambdaparameter: 62
body: 41
37Variable
38Literal
39ExprTuple41, 42
40ExprRangelambda_map: 43
start_index: 44
end_index: 45
41Operationoperator: 46
operands: 47
42Literal
43Lambdaparameter: 62
body: 48
44IndexedVarvariable: 60
index: 59
45IndexedVarvariable: 53
index: 59
46Literal
47ExprTuple49, 50, 51
48Operationoperator: 52
operand: 62
49IndexedVarvariable: 53
index: 62
50Operationoperator: 54
operand: 58
51Literal
52IndexedVarvariable: 56
index: 59
53Variable
54Literal
55ExprTuple58
56Variable
57ExprTuple59
58IndexedVarvariable: 60
index: 62
59Variable
60Variable
61ExprTuple62
62Variable