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, NaturalPos, 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), NaturalPos), domain = Natural, 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{N}~|~b > 0}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{N}^+\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
1ExprTuple39, 42
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 17
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 26
body: 11
9Operationoperator: 44
operands: 12
10Operationoperator: 44
operands: 13
11Conditionalvalue: 14
condition: 15
12ExprTuple39, 48
13ExprTuple42, 48
14Operationoperator: 44
operands: 16
15Operationoperator: 17
operands: 18
16ExprTuple19, 20
17Literal
18ExprTuple21, 22, 23, 24
19Operationoperator: 25
operands: 26
20Literal
21ExprRangelambda_map: 27
start_index: 41
end_index: 39
22Operationoperator: 44
operands: 28
23ExprRangelambda_map: 29
start_index: 41
end_index: 42
24Operationoperator: 30
operands: 31
25Literal
26ExprTuple32, 37, 33
27Lambdaparameter: 52
body: 34
28ExprTuple37, 48
29Lambdaparameter: 52
body: 35
30Literal
31ExprTuple36, 37
32ExprRangelambda_map: 38
start_index: 41
end_index: 39
33ExprRangelambda_map: 40
start_index: 41
end_index: 42
34Operationoperator: 44
operands: 43
35Operationoperator: 44
operands: 45
36Literal
37Variable
38Lambdaparameter: 52
body: 46
39Variable
40Lambdaparameter: 52
body: 47
41Literal
42Variable
43ExprTuple46, 48
44Literal
45ExprTuple47, 48
46IndexedVarvariable: 49
index: 52
47IndexedVarvariable: 50
index: 52
48Literal
49Variable
50Variable
51ExprTuple52
52Variable