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, c, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import And, Forall, InSet
from proveit.numbers import Add, Real, RealNonNeg, greater_eq, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, c_1_to_j], Conditional(Forall(instance_param_or_params = [b], instance_expr = greater_eq(Add(a_1_to_i, b, c_1_to_j), b), domain = Real), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), RealNonNeg), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), RealNonNeg), one, j))))
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}, c_{1}, c_{2}, \ldots, c_{j}\right) \mapsto \left\{\forall_{b \in \mathbb{R}}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \geq b\right) \textrm{ if } \left(a_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(a_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}^{\ge 0}\right), \left(c_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(c_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{R}^{\ge 0}\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
1ExprTuple31, 33
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 32
body: 13
10ExprRangelambda_map: 14
start_index: 37
end_index: 35
11ExprRangelambda_map: 15
start_index: 37
end_index: 38
12ExprTuple32
13Conditionalvalue: 16
condition: 17
14Lambdaparameter: 44
body: 18
15Lambdaparameter: 44
body: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 24
operands: 22
18Operationoperator: 24
operands: 23
19Operationoperator: 24
operands: 25
20Literal
21ExprTuple32, 26
22ExprTuple32, 27
23ExprTuple39, 28
24Literal
25ExprTuple40, 28
26Operationoperator: 29
operands: 30
27Literal
28Literal
29Literal
30ExprTuple31, 32, 33
31ExprRangelambda_map: 34
start_index: 37
end_index: 35
32Variable
33ExprRangelambda_map: 36
start_index: 37
end_index: 38
34Lambdaparameter: 44
body: 39
35Variable
36Lambdaparameter: 44
body: 40
37Literal
38Variable
39IndexedVarvariable: 41
index: 44
40IndexedVarvariable: 42
index: 44
41Variable
42Variable
43ExprTuple44
44Variable