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, vb, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Integer, Interval, Less, one, subtract
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(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, subtract(b, one))), vb)), 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(\left(\sum_{i=a}^{b - 1} v\left(i\right)\right) + v\left(b\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: 29
operand: 24
14Operationoperator: 19
operands: 20
15Operationoperator: 42
operands: 21
16Operationoperator: 42
operands: 22
17Operationoperator: 23
operands: 39
18ExprTuple24
19Literal
20ExprTuple25, 26
21ExprTuple48, 27
22ExprTuple52, 27
23Literal
24Lambdaparameter: 44
body: 28
25Operationoperator: 29
operand: 33
26Operationoperator: 40
operand: 52
27Literal
28Conditionalvalue: 37
condition: 32
29Literal
30ExprTuple33
31ExprTuple52
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
39ExprTuple48, 52
40Variable
41ExprTuple44
42Literal
43ExprTuple44, 45
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Variable
49Operationoperator: 50
operands: 51
50Literal
51ExprTuple52, 53
52Variable
53Operationoperator: 54
operand: 56
54Literal
55ExprTuple56
56Literal