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, InSet
from proveit.numbers import Add, Less, RationalNeg, RationalNonPos, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, b, c_1_to_j], Conditional(InSet(Add(a_1_to_i, b, c_1_to_j), RationalNeg), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), RationalNonPos), one, i), InSet(b, RationalNonPos), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), RationalNonPos), one, j), Less(b, zero))))
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, c_{1}, c_{2}, \ldots, c_{j}\right) \mapsto \left\{\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{Q}^- \textrm{ if } \left(a_{1} \in \mathbb{Q}^{\leq 0}\right) ,  \left(a_{2} \in \mathbb{Q}^{\leq 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{Q}^{\leq 0}\right) ,  b \in \mathbb{Q}^{\leq 0}, \left(c_{1} \in \mathbb{Q}^{\leq 0}\right) ,  \left(c_{2} \in \mathbb{Q}^{\leq 0}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{Q}^{\leq 0}\right) ,  b < 0\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 14
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 32
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11, 12
7Operationoperator: 13
operands: 14
8Literal
9ExprRangelambda_map: 15
start_index: 29
end_index: 27
10Operationoperator: 32
operands: 16
11ExprRangelambda_map: 17
start_index: 29
end_index: 30
12Operationoperator: 18
operands: 19
13Literal
14ExprTuple20, 24, 21
15Lambdaparameter: 40
body: 22
16ExprTuple24, 36
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
25Literal
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