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, ExprRange, IndexedVar, Lambda, Variable, a, b, c, d, e, 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, InSet
from proveit.numbers import Add, Complex, Neg, one
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, d, e_1_to_k], Conditional(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)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), InSet(b, Complex), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), Complex), one, j), InSet(d, Complex), ExprRange(sub_expr1, InSet(IndexedVar(e, sub_expr1), Complex), one, k), Equals(b, d))))
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}, d, e_{1}, e_{2}, \ldots, e_{k}\right) \mapsto \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) \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right) ,  b \in \mathbb{C}, \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{C}\right) ,  d \in \mathbb{C}, \left(e_{1} \in \mathbb{C}\right) ,  \left(e_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(e_{k} \in \mathbb{C}\right) ,  b = d\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
1ExprTuple27, 33, 28, 47, 29
2Conditionalvalue: 3
condition: 4
3Operationoperator: 24
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12, 13, 14, 15
8Operationoperator: 17
operands: 16
9Operationoperator: 17
operands: 18
10ExprRangelambda_map: 19
start_index: 41
end_index: 37
11Operationoperator: 45
operands: 20
12ExprRangelambda_map: 21
start_index: 41
end_index: 39
13Operationoperator: 45
operands: 22
14ExprRangelambda_map: 23
start_index: 41
end_index: 42
15Operationoperator: 24
operands: 25
16ExprTuple27, 33, 28, 26, 29
17Literal
18ExprTuple27, 28, 29
19Lambdaparameter: 56
body: 30
20ExprTuple33, 51
21Lambdaparameter: 56
body: 31
22ExprTuple47, 51
23Lambdaparameter: 56
body: 32
24Literal
25ExprTuple33, 47
26Operationoperator: 34
operand: 47
27ExprRangelambda_map: 36
start_index: 41
end_index: 37
28ExprRangelambda_map: 38
start_index: 41
end_index: 39
29ExprRangelambda_map: 40
start_index: 41
end_index: 42
30Operationoperator: 45
operands: 43
31Operationoperator: 45
operands: 44
32Operationoperator: 45
operands: 46
33Variable
34Literal
35ExprTuple47
36Lambdaparameter: 56
body: 48
37Variable
38Lambdaparameter: 56
body: 49
39Variable
40Lambdaparameter: 56
body: 50
41Literal
42Variable
43ExprTuple48, 51
44ExprTuple49, 51
45Literal
46ExprTuple50, 51
47Variable
48IndexedVarvariable: 52
index: 56
49IndexedVarvariable: 53
index: 56
50IndexedVarvariable: 54
index: 56
51Literal
52Variable
53Variable
54Variable
55ExprTuple56
56Variable