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, c, f, fx, x
from proveit.logic import Equals, Forall
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(f, Forall(instance_param_or_params = [a, b, c], instance_expr = 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)))), domain = Integer, conditions = [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())
f \mapsto \left[\forall_{a, b, c \in \mathbb{Z}~|~a \leq b, b < c}~\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)\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: 49
body: 2
1ExprTuple49
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple59, 64, 61
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17, 18, 19, 20
14Operationoperator: 35
operand: 29
15Operationoperator: 62
operands: 22
16Operationoperator: 51
operands: 23
17Operationoperator: 51
operands: 24
18Operationoperator: 51
operands: 25
19Operationoperator: 26
operands: 56
20Operationoperator: 27
operands: 28
21ExprTuple29
22ExprTuple30, 31
23ExprTuple59, 32
24ExprTuple64, 32
25ExprTuple61, 32
26Literal
27Literal
28ExprTuple64, 61
29Lambdaparameter: 54
body: 33
30Operationoperator: 35
operand: 38
31Operationoperator: 35
operand: 39
32Literal
33Conditionalvalue: 45
condition: 37
34ExprTuple38
35Literal
36ExprTuple39
37Operationoperator: 51
operands: 40
38Lambdaparameter: 54
body: 41
39Lambdaparameter: 54
body: 42
40ExprTuple54, 43
41Conditionalvalue: 45
condition: 44
42Conditionalvalue: 45
condition: 46
43Operationoperator: 57
operands: 47
44Operationoperator: 51
operands: 48
45Operationoperator: 49
operand: 54
46Operationoperator: 51
operands: 52
47ExprTuple59, 61
48ExprTuple54, 53
49Variable
50ExprTuple54
51Literal
52ExprTuple54, 55
53Operationoperator: 57
operands: 56
54Variable
55Operationoperator: 57
operands: 58
56ExprTuple59, 64
57Literal
58ExprTuple60, 61
59Variable
60Operationoperator: 62
operands: 63
61Variable
62Literal
63ExprTuple64, 65
64Variable
65Literal