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, Lambda, b, 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, Natural, RealNonNeg, RealPos, greater, zero
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j], Conditional(Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_j], instance_expr = InSet(Add(a_1_to_i, b, c_1_to_j), RealPos), domain = RealNonNeg, condition = greater(b, zero)), And(InSet(i, Natural), InSet(j, Natural))))
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(i, j\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j} \in \mathbb{R}^{\ge 0}~|~b > 0}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{R}^+\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N}\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
1ExprTuple40, 43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 18
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 27
body: 11
9Operationoperator: 45
operands: 12
10Operationoperator: 45
operands: 13
11Conditionalvalue: 14
condition: 15
12ExprTuple40, 16
13ExprTuple43, 16
14Operationoperator: 45
operands: 17
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23, 24, 25
20Operationoperator: 26
operands: 27
21Literal
22ExprRangelambda_map: 28
start_index: 42
end_index: 40
23Operationoperator: 45
operands: 29
24ExprRangelambda_map: 30
start_index: 42
end_index: 43
25Operationoperator: 31
operands: 32
26Literal
27ExprTuple33, 38, 34
28Lambdaparameter: 53
body: 35
29ExprTuple38, 49
30Lambdaparameter: 53
body: 36
31Literal
32ExprTuple37, 38
33ExprRangelambda_map: 39
start_index: 42
end_index: 40
34ExprRangelambda_map: 41
start_index: 42
end_index: 43
35Operationoperator: 45
operands: 44
36Operationoperator: 45
operands: 46
37Literal
38Variable
39Lambdaparameter: 53
body: 47
40Variable
41Lambdaparameter: 53
body: 48
42Literal
43Variable
44ExprTuple47, 49
45Literal
46ExprTuple48, 49
47IndexedVarvariable: 50
index: 53
48IndexedVarvariable: 51
index: 53
49Literal
50Variable
51Variable
52ExprTuple53
53Variable