logo

Expression of type Lambda

from the theory of proveit.numbers.numerals.decimals

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, Function, Lambda, f, i, j
from proveit.core_expr_types import f_i_to_j
from proveit.logic import Equals
from proveit.numbers import Add, eight, five, four, one, seven, six, three, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Add(i, eight)
expr = Lambda([f, i, j], Conditional(Equals([f_i_to_j], [Function(f, [i]), Function(f, [Add(i, one)]), Function(f, [Add(i, two)]), Function(f, [Add(i, three)]), Function(f, [Add(i, four)]), Function(f, [Add(i, five)]), Function(f, [Add(i, six)]), Function(f, [Add(i, seven)]), Function(f, [sub_expr1])]), Equals(j, sub_expr1)))
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(f, i, j\right) \mapsto \left\{\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) = \left(f\left(i\right), f\left(i + 1\right), f\left(i + 2\right), f\left(i + 3\right), f\left(i + 4\right), f\left(i + 5\right), f\left(i + 6\right), f\left(i + 7\right), f\left(i + 8\right)\right) \textrm{ if } j = \left(i + 8\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple40, 59, 21
2Conditionalvalue: 3
condition: 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple21, 39
8ExprTuple10
9ExprTuple11, 12, 13, 14, 15, 16, 17, 18, 19
10ExprRangelambda_map: 20
start_index: 59
end_index: 21
11Operationoperator: 40
operand: 59
12Operationoperator: 40
operand: 32
13Operationoperator: 40
operand: 33
14Operationoperator: 40
operand: 34
15Operationoperator: 40
operand: 35
16Operationoperator: 40
operand: 36
17Operationoperator: 40
operand: 37
18Operationoperator: 40
operand: 38
19Operationoperator: 40
operand: 39
20Lambdaparameter: 51
body: 31
21Variable
22ExprTuple59
23ExprTuple32
24ExprTuple33
25ExprTuple34
26ExprTuple35
27ExprTuple36
28ExprTuple37
29ExprTuple38
30ExprTuple39
31Operationoperator: 40
operand: 51
32Operationoperator: 49
operands: 42
33Operationoperator: 49
operands: 43
34Operationoperator: 49
operands: 44
35Operationoperator: 49
operands: 45
36Operationoperator: 49
operands: 46
37Operationoperator: 49
operands: 47
38Operationoperator: 49
operands: 48
39Operationoperator: 49
operands: 50
40Variable
41ExprTuple51
42ExprTuple59, 52
43ExprTuple59, 53
44ExprTuple59, 54
45ExprTuple59, 55
46ExprTuple59, 56
47ExprTuple59, 57
48ExprTuple59, 58
49Literal
50ExprTuple59, 60
51Variable
52Literal
53Literal
54Literal
55Literal
56Literal
57Literal
58Literal
59Variable
60Literal