logo

Expression of type ExprTuple

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 ExprTuple, 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 = ExprTuple(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())
\left(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]\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 41
body: 3
2ExprTuple41
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 40
body: 7
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17, 18
14Operationoperator: 30
operand: 25
15Operationoperator: 20
operands: 21
16Operationoperator: 43
operands: 22
17Operationoperator: 43
operands: 23
18Operationoperator: 24
operands: 40
19ExprTuple25
20Literal
21ExprTuple26, 27
22ExprTuple49, 28
23ExprTuple53, 28
24Literal
25Lambdaparameter: 45
body: 29
26Operationoperator: 30
operand: 34
27Operationoperator: 41
operand: 53
28Literal
29Conditionalvalue: 38
condition: 33
30Literal
31ExprTuple34
32ExprTuple53
33Operationoperator: 43
operands: 35
34Lambdaparameter: 45
body: 36
35ExprTuple45, 37
36Conditionalvalue: 38
condition: 39
37Operationoperator: 47
operands: 40
38Operationoperator: 41
operand: 45
39Operationoperator: 43
operands: 44
40ExprTuple49, 53
41Variable
42ExprTuple45
43Literal
44ExprTuple45, 46
45Variable
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Variable
50Operationoperator: 51
operands: 52
51Literal
52ExprTuple53, 54
53Variable
54Operationoperator: 55
operand: 57
55Literal
56ExprTuple57
57Literal