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, 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 = ExprTuple(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(\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..\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: 2
body: 3
2ExprTuple56, 61, 58
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14, 15, 16
10Operationoperator: 32
operand: 26
11Operationoperator: 18
operands: 19
12Operationoperator: 48
operands: 20
13Operationoperator: 48
operands: 21
14Operationoperator: 48
operands: 22
15Operationoperator: 23
operands: 53
16Operationoperator: 24
operands: 25
17ExprTuple26
18Literal
19ExprTuple27, 28
20ExprTuple56, 29
21ExprTuple61, 29
22ExprTuple58, 29
23Literal
24Literal
25ExprTuple61, 58
26Lambdaparameter: 51
body: 30
27Operationoperator: 32
operand: 35
28Operationoperator: 32
operand: 36
29Literal
30Conditionalvalue: 42
condition: 34
31ExprTuple35
32Literal
33ExprTuple36
34Operationoperator: 48
operands: 37
35Lambdaparameter: 51
body: 38
36Lambdaparameter: 51
body: 39
37ExprTuple51, 40
38Conditionalvalue: 42
condition: 41
39Conditionalvalue: 42
condition: 43
40Operationoperator: 54
operands: 44
41Operationoperator: 48
operands: 45
42Operationoperator: 46
operand: 51
43Operationoperator: 48
operands: 49
44ExprTuple56, 58
45ExprTuple51, 50
46Variable
47ExprTuple51
48Literal
49ExprTuple51, 52
50Operationoperator: 54
operands: 53
51Variable
52Operationoperator: 54
operands: 55
53ExprTuple56, 61
54Literal
55ExprTuple57, 58
56Variable
57Operationoperator: 59
operands: 60
58Variable
59Literal
60ExprTuple61, 62
61Variable
62Literal