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 And, Equals, Forall
from proveit.numbers import Add, Integer, Interval, 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, condition = 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())
f \mapsto \left[\forall_{a, b, c \in \mathbb{Z}~|~a \leq b \leq 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: 50
body: 2
1ExprTuple50
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple60, 65, 62
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 24
operands: 12
10Literal
11ExprTuple13, 14
12ExprTuple15, 16, 17, 18
13Operationoperator: 34
operand: 26
14Operationoperator: 63
operands: 20
15Operationoperator: 52
operands: 21
16Operationoperator: 52
operands: 22
17Operationoperator: 52
operands: 23
18Operationoperator: 24
operands: 25
19ExprTuple26
20ExprTuple27, 28
21ExprTuple60, 29
22ExprTuple65, 29
23ExprTuple62, 29
24Literal
25ExprTuple30, 31
26Lambdaparameter: 55
body: 32
27Operationoperator: 34
operand: 39
28Operationoperator: 34
operand: 40
29Literal
30Operationoperator: 36
operands: 57
31Operationoperator: 36
operands: 37
32Conditionalvalue: 46
condition: 38
33ExprTuple39
34Literal
35ExprTuple40
36Literal
37ExprTuple65, 62
38Operationoperator: 52
operands: 41
39Lambdaparameter: 55
body: 42
40Lambdaparameter: 55
body: 43
41ExprTuple55, 44
42Conditionalvalue: 46
condition: 45
43Conditionalvalue: 46
condition: 47
44Operationoperator: 58
operands: 48
45Operationoperator: 52
operands: 49
46Operationoperator: 50
operand: 55
47Operationoperator: 52
operands: 53
48ExprTuple60, 62
49ExprTuple55, 54
50Variable
51ExprTuple55
52Literal
53ExprTuple55, 56
54Operationoperator: 58
operands: 57
55Variable
56Operationoperator: 58
operands: 59
57ExprTuple60, 65
58Literal
59ExprTuple61, 62
60Variable
61Operationoperator: 63
operands: 64
62Variable
63Literal
64ExprTuple65, 66
65Variable
66Literal