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 Lambda, a, b, f, fb, fx, x
from proveit.logic import Equals, Forall
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(f, Forall(instance_param_or_params = [a, b], instance_expr = 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)), domain = Integer, condition = 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())
f \mapsto \left[\forall_{a, b \in \mathbb{Z}~|~a < b}~\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)\right)\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 39
body: 2
1ExprTuple39
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameters: 38
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operands: 10
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13, 14
11Literal
12ExprTuple15, 16, 17
13Operationoperator: 28
operand: 23
14Operationoperator: 49
operands: 19
15Operationoperator: 41
operands: 20
16Operationoperator: 41
operands: 21
17Operationoperator: 22
operands: 38
18ExprTuple23
19ExprTuple24, 25
20ExprTuple47, 26
21ExprTuple51, 26
22Literal
23Lambdaparameter: 43
body: 27
24Operationoperator: 28
operand: 32
25Operationoperator: 39
operand: 51
26Literal
27Conditionalvalue: 36
condition: 31
28Literal
29ExprTuple32
30ExprTuple51
31Operationoperator: 41
operands: 33
32Lambdaparameter: 43
body: 34
33ExprTuple43, 35
34Conditionalvalue: 36
condition: 37
35Operationoperator: 45
operands: 38
36Operationoperator: 39
operand: 43
37Operationoperator: 41
operands: 42
38ExprTuple47, 51
39Variable
40ExprTuple43
41Literal
42ExprTuple43, 44
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Variable
48Operationoperator: 49
operands: 50
49Literal
50ExprTuple51, 52
51Variable
52Operationoperator: 53
operand: 55
53Literal
54ExprTuple55
55Literal