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, four, one, three, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Add(i, four)
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, [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)\right) \textrm{ if } j = \left(i + 4\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
1ExprTuple28, 39, 17
2Conditionalvalue: 3
condition: 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple17, 27
8ExprTuple10
9ExprTuple11, 12, 13, 14, 15
10ExprRangelambda_map: 16
start_index: 39
end_index: 17
11Operationoperator: 28
operand: 39
12Operationoperator: 28
operand: 24
13Operationoperator: 28
operand: 25
14Operationoperator: 28
operand: 26
15Operationoperator: 28
operand: 27
16Lambdaparameter: 35
body: 23
17Variable
18ExprTuple39
19ExprTuple24
20ExprTuple25
21ExprTuple26
22ExprTuple27
23Operationoperator: 28
operand: 35
24Operationoperator: 33
operands: 30
25Operationoperator: 33
operands: 31
26Operationoperator: 33
operands: 32
27Operationoperator: 33
operands: 34
28Variable
29ExprTuple35
30ExprTuple39, 36
31ExprTuple39, 37
32ExprTuple39, 38
33Literal
34ExprTuple39, 40
35Variable
36Literal
37Literal
38Literal
39Variable
40Literal