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, 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), And(LessEq(a, b), LessEq(b, c)).with_total_ordering_style())))
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 \leq 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
1ExprTuple55, 60, 57
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 19
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple10, 11, 12, 13
8Operationoperator: 29
operand: 21
9Operationoperator: 58
operands: 15
10Operationoperator: 47
operands: 16
11Operationoperator: 47
operands: 17
12Operationoperator: 47
operands: 18
13Operationoperator: 19
operands: 20
14ExprTuple21
15ExprTuple22, 23
16ExprTuple55, 24
17ExprTuple60, 24
18ExprTuple57, 24
19Literal
20ExprTuple25, 26
21Lambdaparameter: 50
body: 27
22Operationoperator: 29
operand: 34
23Operationoperator: 29
operand: 35
24Literal
25Operationoperator: 31
operands: 52
26Operationoperator: 31
operands: 32
27Conditionalvalue: 41
condition: 33
28ExprTuple34
29Literal
30ExprTuple35
31Literal
32ExprTuple60, 57
33Operationoperator: 47
operands: 36
34Lambdaparameter: 50
body: 37
35Lambdaparameter: 50
body: 38
36ExprTuple50, 39
37Conditionalvalue: 41
condition: 40
38Conditionalvalue: 41
condition: 42
39Operationoperator: 53
operands: 43
40Operationoperator: 47
operands: 44
41Operationoperator: 45
operand: 50
42Operationoperator: 47
operands: 48
43ExprTuple55, 57
44ExprTuple50, 49
45Variable
46ExprTuple50
47Literal
48ExprTuple50, 51
49Operationoperator: 53
operands: 52
50Variable
51Operationoperator: 53
operands: 54
52ExprTuple55, 60
53Literal
54ExprTuple56, 57
55Variable
56Operationoperator: 58
operands: 59
57Variable
58Literal
59ExprTuple60, 61
60Variable
61Literal