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 Conditional, ExprTuple, Lambda, a, b, i, vb, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import And, Equals, InSet
from proveit.numbers import Integer, Interval, Less, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
expr = ExprTuple(Lambda([a, b], Conditional(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)), And(InSet(a, Integer), InSet(b, Integer), 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(\left(a, b\right) \mapsto \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) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  a < b\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
1Lambdaparameters: 35
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Operationoperator: 25
operand: 20
10Operationoperator: 15
operands: 16
11Operationoperator: 38
operands: 17
12Operationoperator: 38
operands: 18
13Operationoperator: 19
operands: 35
14ExprTuple20
15Literal
16ExprTuple21, 22
17ExprTuple44, 23
18ExprTuple48, 23
19Literal
20Lambdaparameter: 40
body: 24
21Operationoperator: 25
operand: 29
22Operationoperator: 36
operand: 48
23Literal
24Conditionalvalue: 33
condition: 28
25Literal
26ExprTuple29
27ExprTuple48
28Operationoperator: 38
operands: 30
29Lambdaparameter: 40
body: 31
30ExprTuple40, 32
31Conditionalvalue: 33
condition: 34
32Operationoperator: 42
operands: 35
33Operationoperator: 36
operand: 40
34Operationoperator: 38
operands: 39
35ExprTuple44, 48
36Variable
37ExprTuple40
38Literal
39ExprTuple40, 41
40Variable
41Operationoperator: 42
operands: 43
42Literal
43ExprTuple44, 45
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Variable
49Operationoperator: 50
operand: 52
50Literal
51ExprTuple52
52Literal