logo

Expression of type Lambda

from the theory of proveit.numbers.addition

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, IndexedVar, Lambda, Variable, a, b, i, j, x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, InSet
from proveit.numbers import Add, Less, Real, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, b_1_to_j], Conditional(Less(Add(a_1_to_i, x, b_1_to_j), Add(a_1_to_i, y, b_1_to_j)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Real), one, i), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Real), one, j), Less(x, y))))
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(a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}\right) \mapsto \left\{\left(a_{1} +  a_{2} +  \ldots +  a_{i} + x+ b_{1} +  b_{2} +  \ldots +  b_{j}\right) < \left(a_{1} +  a_{2} +  \ldots +  a_{i} + y+ b_{1} +  b_{2} +  \ldots +  b_{j}\right) \textrm{ if } \left(a_{1} \in \mathbb{R}\right) ,  \left(a_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}\right), \left(b_{1} \in \mathbb{R}\right) ,  \left(b_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(b_{j} \in \mathbb{R}\right) ,  x < y\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
1ExprTuple20, 21
2Conditionalvalue: 3
condition: 4
3Operationoperator: 18
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Operationoperator: 14
operands: 13
9Operationoperator: 14
operands: 15
10ExprRangelambda_map: 16
start_index: 29
end_index: 27
11ExprRangelambda_map: 17
start_index: 29
end_index: 30
12Operationoperator: 18
operands: 19
13ExprTuple20, 24, 21
14Literal
15ExprTuple20, 25, 21
16Lambdaparameter: 40
body: 22
17Lambdaparameter: 40
body: 23
18Literal
19ExprTuple24, 25
20ExprRangelambda_map: 26
start_index: 29
end_index: 27
21ExprRangelambda_map: 28
start_index: 29
end_index: 30
22Operationoperator: 32
operands: 31
23Operationoperator: 32
operands: 33
24Variable
25Variable
26Lambdaparameter: 40
body: 34
27Variable
28Lambdaparameter: 40
body: 35
29Literal
30Variable
31ExprTuple34, 36
32Literal
33ExprTuple35, 36
34IndexedVarvariable: 37
index: 40
35IndexedVarvariable: 38
index: 40
36Literal
37Variable
38Variable
39ExprTuple40
40Variable