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, 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 = 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())
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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 30
body: 2
1ExprTuple30
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 18
operands: 7
5Literal
6ExprTuple8
7ExprTuple30, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple12, 34
11Conditionalvalue: 13
condition: 14
12ExprRangelambda_map: 15
start_index: 33
end_index: 30
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Lambdaparameter: 40
body: 20
16Literal
17ExprTuple21, 22
18Literal
19ExprTuple34, 23
20IndexedVarvariable: 38
index: 40
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple30, 34
28ExprRangelambda_map: 29
start_index: 33
end_index: 30
29Lambdaparameter: 41
body: 31
30Variable
31ExprRangelambda_map: 32
start_index: 33
end_index: 34
32Lambdaparameter: 40
body: 35
33Literal
34Variable
35Operationoperator: 36
operand: 40
36IndexedVarvariable: 38
index: 41
37ExprTuple40
38Variable
39ExprTuple41
40Variable
41Variable