logo

Expression of type Lambda

from the theory of proveit.numbers.summation

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, a, b, c, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, LessEq, Sum, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda([a, b, c], Conditional(Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, c)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(b, one), c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), LessEq(a, b), Less(b, c))))
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, b, c\right) \mapsto \left\{\left(\sum_{x = a}^{c} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b} f\left(x\right)\right) + \left(\sum_{x = b + 1}^{c} f\left(x\right)\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  a \leq b ,  b < c\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
1ExprTuple54, 59, 56
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14, 15
9Operationoperator: 30
operand: 24
10Operationoperator: 57
operands: 17
11Operationoperator: 46
operands: 18
12Operationoperator: 46
operands: 19
13Operationoperator: 46
operands: 20
14Operationoperator: 21
operands: 51
15Operationoperator: 22
operands: 23
16ExprTuple24
17ExprTuple25, 26
18ExprTuple54, 27
19ExprTuple59, 27
20ExprTuple56, 27
21Literal
22Literal
23ExprTuple59, 56
24Lambdaparameter: 49
body: 28
25Operationoperator: 30
operand: 33
26Operationoperator: 30
operand: 34
27Literal
28Conditionalvalue: 40
condition: 32
29ExprTuple33
30Literal
31ExprTuple34
32Operationoperator: 46
operands: 35
33Lambdaparameter: 49
body: 36
34Lambdaparameter: 49
body: 37
35ExprTuple49, 38
36Conditionalvalue: 40
condition: 39
37Conditionalvalue: 40
condition: 41
38Operationoperator: 52
operands: 42
39Operationoperator: 46
operands: 43
40Operationoperator: 44
operand: 49
41Operationoperator: 46
operands: 47
42ExprTuple54, 56
43ExprTuple49, 48
44Variable
45ExprTuple49
46Literal
47ExprTuple49, 50
48Operationoperator: 52
operands: 51
49Variable
50Operationoperator: 52
operands: 53
51ExprTuple54, 59
52Literal
53ExprTuple55, 56
54Variable
55Operationoperator: 57
operands: 58
56Variable
57Literal
58ExprTuple59, 60
59Variable
60Literal