logo

Expression of type Lambda

from the theory of proveit.numbers.addition.subtraction

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, d, i, j, k
from proveit.core_expr_types import a_1_to_i, c_1_to_j, e_1_to_k
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Complex, Natural, Neg
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j, k], Conditional(Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_j, d, e_1_to_k], instance_expr = Equals(Add(a_1_to_i, b, c_1_to_j, Neg(d), e_1_to_k), Add(a_1_to_i, c_1_to_j, e_1_to_k)), domain = Complex, condition = Equals(b, d)), And(InSet(i, Natural), InSet(j, Natural), InSet(k, 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, k\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j}, d, e_{1}, e_{2}, \ldots, e_{k} \in \mathbb{C}~|~b = d}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j} - d+ e_{1} +  e_{2} +  \ldots +  e_{k}\right) = \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ c_{1} +  c_{2} +  \ldots +  c_{j}+ e_{1} +  e_{2} +  \ldots +  e_{k}\right)\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \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
1ExprTuple52, 54, 57
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 21
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 12
body: 13
9Operationoperator: 60
operands: 14
10Operationoperator: 60
operands: 15
11Operationoperator: 60
operands: 16
12ExprTuple42, 48, 43, 62, 44
13Conditionalvalue: 17
condition: 18
14ExprTuple52, 19
15ExprTuple54, 19
16ExprTuple57, 19
17Operationoperator: 39
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27, 28, 29, 30
23Operationoperator: 32
operands: 31
24Operationoperator: 32
operands: 33
25ExprRangelambda_map: 34
start_index: 56
end_index: 52
26Operationoperator: 60
operands: 35
27ExprRangelambda_map: 36
start_index: 56
end_index: 54
28Operationoperator: 60
operands: 37
29ExprRangelambda_map: 38
start_index: 56
end_index: 57
30Operationoperator: 39
operands: 40
31ExprTuple42, 48, 43, 41, 44
32Literal
33ExprTuple42, 43, 44
34Lambdaparameter: 71
body: 45
35ExprTuple48, 66
36Lambdaparameter: 71
body: 46
37ExprTuple62, 66
38Lambdaparameter: 71
body: 47
39Literal
40ExprTuple48, 62
41Operationoperator: 49
operand: 62
42ExprRangelambda_map: 51
start_index: 56
end_index: 52
43ExprRangelambda_map: 53
start_index: 56
end_index: 54
44ExprRangelambda_map: 55
start_index: 56
end_index: 57
45Operationoperator: 60
operands: 58
46Operationoperator: 60
operands: 59
47Operationoperator: 60
operands: 61
48Variable
49Literal
50ExprTuple62
51Lambdaparameter: 71
body: 63
52Variable
53Lambdaparameter: 71
body: 64
54Variable
55Lambdaparameter: 71
body: 65
56Literal
57Variable
58ExprTuple63, 66
59ExprTuple64, 66
60Literal
61ExprTuple65, 66
62Variable
63IndexedVarvariable: 67
index: 71
64IndexedVarvariable: 68
index: 71
65IndexedVarvariable: 69
index: 71
66Literal
67Variable
68Variable
69Variable
70ExprTuple71
71Variable