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, c, i, v, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import Equals, Forall
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(v, Forall(instance_param_or_params = [a, b, c], instance_expr = 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)))), domain = Integer, conditions = [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(v \mapsto \left[\forall_{a, b, c \in \mathbb{Z}~|~a \leq b, b < c}~\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)\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: 51
body: 3
2ExprTuple51
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple61, 66, 63
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19, 20, 21
15Operationoperator: 37
operand: 31
16Operationoperator: 23
operands: 24
17Operationoperator: 53
operands: 25
18Operationoperator: 53
operands: 26
19Operationoperator: 53
operands: 27
20Operationoperator: 28
operands: 58
21Operationoperator: 29
operands: 30
22ExprTuple31
23Literal
24ExprTuple32, 33
25ExprTuple61, 34
26ExprTuple66, 34
27ExprTuple63, 34
28Literal
29Literal
30ExprTuple66, 63
31Lambdaparameter: 56
body: 35
32Operationoperator: 37
operand: 40
33Operationoperator: 37
operand: 41
34Literal
35Conditionalvalue: 47
condition: 39
36ExprTuple40
37Literal
38ExprTuple41
39Operationoperator: 53
operands: 42
40Lambdaparameter: 56
body: 43
41Lambdaparameter: 56
body: 44
42ExprTuple56, 45
43Conditionalvalue: 47
condition: 46
44Conditionalvalue: 47
condition: 48
45Operationoperator: 59
operands: 49
46Operationoperator: 53
operands: 50
47Operationoperator: 51
operand: 56
48Operationoperator: 53
operands: 54
49ExprTuple61, 63
50ExprTuple56, 55
51Variable
52ExprTuple56
53Literal
54ExprTuple56, 57
55Operationoperator: 59
operands: 58
56Variable
57Operationoperator: 59
operands: 60
58ExprTuple61, 66
59Literal
60ExprTuple62, 63
61Variable
62Operationoperator: 64
operands: 65
63Variable
64Literal
65ExprTuple66, 67
66Variable
67Literal