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, fb, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, Sum, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda([a, b], Conditional(Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, subtract(b, one))), fb)), And(InSet(a, Integer), InSet(b, Integer), Less(a, b))))
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\right) \mapsto \left\{\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b - 1} f\left(x\right)\right) + f\left(b\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  a < b\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 33
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Operationoperator: 23
operand: 18
9Operationoperator: 44
operands: 14
10Operationoperator: 36
operands: 15
11Operationoperator: 36
operands: 16
12Operationoperator: 17
operands: 33
13ExprTuple18
14ExprTuple19, 20
15ExprTuple42, 21
16ExprTuple46, 21
17Literal
18Lambdaparameter: 38
body: 22
19Operationoperator: 23
operand: 27
20Operationoperator: 34
operand: 46
21Literal
22Conditionalvalue: 31
condition: 26
23Literal
24ExprTuple27
25ExprTuple46
26Operationoperator: 36
operands: 28
27Lambdaparameter: 38
body: 29
28ExprTuple38, 30
29Conditionalvalue: 31
condition: 32
30Operationoperator: 40
operands: 33
31Operationoperator: 34
operand: 38
32Operationoperator: 36
operands: 37
33ExprTuple42, 46
34Variable
35ExprTuple38
36Literal
37ExprTuple38, 39
38Variable
39Operationoperator: 40
operands: 41
40Literal
41ExprTuple42, 43
42Variable
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Variable
47Operationoperator: 48
operand: 50
48Literal
49ExprTuple50
50Literal