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 Conditional, Lambda, a, b, c, i, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, LessEq, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
expr = Lambda([a, b, c], Conditional(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)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), 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())
\left(a, b, c\right) \mapsto \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) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  a \leq b ,  b < c\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
1ExprTuple55, 60, 57
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14, 15
9Operationoperator: 31
operand: 25
10Operationoperator: 17
operands: 18
11Operationoperator: 47
operands: 19
12Operationoperator: 47
operands: 20
13Operationoperator: 47
operands: 21
14Operationoperator: 22
operands: 52
15Operationoperator: 23
operands: 24
16ExprTuple25
17Literal
18ExprTuple26, 27
19ExprTuple55, 28
20ExprTuple60, 28
21ExprTuple57, 28
22Literal
23Literal
24ExprTuple60, 57
25Lambdaparameter: 50
body: 29
26Operationoperator: 31
operand: 34
27Operationoperator: 31
operand: 35
28Literal
29Conditionalvalue: 41
condition: 33
30ExprTuple34
31Literal
32ExprTuple35
33Operationoperator: 47
operands: 36
34Lambdaparameter: 50
body: 37
35Lambdaparameter: 50
body: 38
36ExprTuple50, 39
37Conditionalvalue: 41
condition: 40
38Conditionalvalue: 41
condition: 42
39Operationoperator: 53
operands: 43
40Operationoperator: 47
operands: 44
41Operationoperator: 45
operand: 50
42Operationoperator: 47
operands: 48
43ExprTuple55, 57
44ExprTuple50, 49
45Variable
46ExprTuple50
47Literal
48ExprTuple50, 51
49Operationoperator: 53
operands: 52
50Variable
51Operationoperator: 53
operands: 54
52ExprTuple55, 60
53Literal
54ExprTuple56, 57
55Variable
56Operationoperator: 58
operands: 59
57Variable
58Literal
59ExprTuple60, 61
60Variable
61Literal