logo

Expression of type Lambda

from the theory of proveit.linear_algebra.addition

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, i, v, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, LessEq, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
expr = Lambda(v, Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, c)), VecAdd(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, b)), VecSum(index_or_indices = sub_expr1, summand = vi, 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())
v \mapsto \left[\forall_{a, b, c \in \mathbb{Z}~|~a \leq b, b < c}~\left(\left(\sum_{i=a}^{c} v\left(i\right)\right) = \left(\left(\sum_{i=a}^{b} v\left(i\right)\right) + \left(\sum_{i=b + 1}^{c} v\left(i\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: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17, 18, 19, 20
14Operationoperator: 36
operand: 30
15Operationoperator: 22
operands: 23
16Operationoperator: 52
operands: 24
17Operationoperator: 52
operands: 25
18Operationoperator: 52
operands: 26
19Operationoperator: 27
operands: 57
20Operationoperator: 28
operands: 29
21ExprTuple30
22Literal
23ExprTuple31, 32
24ExprTuple60, 33
25ExprTuple65, 33
26ExprTuple62, 33
27Literal
28Literal
29ExprTuple65, 62
30Lambdaparameter: 55
body: 34
31Operationoperator: 36
operand: 39
32Operationoperator: 36
operand: 40
33Literal
34Conditionalvalue: 46
condition: 38
35ExprTuple39
36Literal
37ExprTuple40
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