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, Function, Lambda, a, b, c, f, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Sum, subtract
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, b)), Sum(index_or_indices = sub_expr1, summand = Function(f, [subtract(x, c)]), domain = Interval(Add(a, c), Add(b, c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer))))
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}^{b} f\left(x\right)\right) = \left(\sum_{x = a + c}^{b + c} f\left(x - c\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z}\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
1ExprTuple51, 52, 53
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Operationoperator: 15
operand: 20
10Operationoperator: 15
operand: 21
11Operationoperator: 33
operands: 17
12Operationoperator: 33
operands: 18
13Operationoperator: 33
operands: 19
14ExprTuple20
15Literal
16ExprTuple21
17ExprTuple51, 22
18ExprTuple52, 22
19ExprTuple53, 22
20Lambdaparameter: 42
body: 23
21Lambdaparameter: 42
body: 24
22Literal
23Conditionalvalue: 25
condition: 26
24Conditionalvalue: 27
condition: 28
25Operationoperator: 31
operand: 42
26Operationoperator: 33
operands: 30
27Operationoperator: 31
operand: 36
28Operationoperator: 33
operands: 34
29ExprTuple42
30ExprTuple42, 35
31Variable
32ExprTuple36
33Literal
34ExprTuple42, 37
35Operationoperator: 40
operands: 38
36Operationoperator: 49
operands: 39
37Operationoperator: 40
operands: 41
38ExprTuple51, 52
39ExprTuple42, 43
40Literal
41ExprTuple44, 45
42Variable
43Operationoperator: 46
operand: 53
44Operationoperator: 49
operands: 48
45Operationoperator: 49
operands: 50
46Literal
47ExprTuple53
48ExprTuple51, 53
49Literal
50ExprTuple52, 53
51Variable
52Variable
53Variable