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, i, v, va, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
expr = Lambda(v, Forall(instance_param_or_params = [a, b], instance_expr = Equals(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, b)), VecAdd(va, VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(Add(a, one), b)))), 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())
v \mapsto \left[\forall_{a, b \in \mathbb{Z}~|~a < b}~\left(\left(\sum_{i=a}^{b} v\left(i\right)\right) = \left(v\left(a\right) + \left(\sum_{i=a + 1}^{b} 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: 40
body: 2
1ExprTuple40
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameters: 39
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operands: 10
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13, 14
11Literal
12ExprTuple15, 16, 17
13Operationoperator: 30
operand: 24
14Operationoperator: 19
operands: 20
15Operationoperator: 42
operands: 21
16Operationoperator: 42
operands: 22
17Operationoperator: 23
operands: 39
18ExprTuple24
19Literal
20ExprTuple25, 26
21ExprTuple52, 27
22ExprTuple49, 27
23Literal
24Lambdaparameter: 44
body: 28
25Operationoperator: 40
operand: 52
26Operationoperator: 30
operand: 33
27Literal
28Conditionalvalue: 37
condition: 32
29ExprTuple52
30Literal
31ExprTuple33
32Operationoperator: 42
operands: 34
33Lambdaparameter: 44
body: 35
34ExprTuple44, 36
35Conditionalvalue: 37
condition: 38
36Operationoperator: 46
operands: 39
37Operationoperator: 40
operand: 44
38Operationoperator: 42
operands: 43
39ExprTuple52, 49
40Variable
41ExprTuple44
42Literal
43ExprTuple44, 45
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Operationoperator: 50
operands: 51
49Variable
50Literal
51ExprTuple52, 53
52Variable
53Literal