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, ExprRange, Function, Lambda, Variable, f, i, j, m, n
from proveit.logic import Equals
from proveit.numbers import Add, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([f, i, j, m, n], Conditional(Equals([ExprRange(sub_expr1, ExprRange(sub_expr2, Function(f, [sub_expr1, sub_expr2]), i, j), m, n)], []), Equals(Add(n, one), m)))
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, m, n\right) \mapsto \left\{\left(f\left(m, i\right), f\left(m, i + 1\right), \ldots, f\left(m, j\right), f\left(m + 1, i\right), f\left(m + 1, i + 1\right), \ldots, f\left(m + 1, j\right), \ldots\ldots, f\left(n, i\right), f\left(n, i + 1\right), \ldots, f\left(n, j\right)\right) = () \textrm{ if } \left(n + 1\right) = m\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
1ExprTuple25, 21, 22, 15, 16
2Conditionalvalue: 3
condition: 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 15
8ExprTuple11
9ExprTuple
10Operationoperator: 12
operands: 13
11ExprRangelambda_map: 14
start_index: 15
end_index: 16
12Literal
13ExprTuple16, 17
14Lambdaparameter: 27
body: 19
15Variable
16Variable
17Literal
18ExprTuple27
19ExprRangelambda_map: 20
start_index: 21
end_index: 22
20Lambdaparameter: 28
body: 24
21Variable
22Variable
23ExprTuple28
24Operationoperator: 25
operands: 26
25Variable
26ExprTuple27, 28
27Variable
28Variable