logo

Expression of type ExprTuple

from the theory of proveit.numbers.summation

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, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, LessEq, Sum, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda([a, b, c], Conditional(Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, c)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(b, one), c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), And(LessEq(a, b), LessEq(b, c)).with_total_ordering_style()))))
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_{x = a}^{c} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b} f\left(x\right)\right) + \left(\sum_{x = b + 1}^{c} f\left(x\right)\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  a \leq b \leq 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: 20
operands: 8
6Literal
7ExprTuple9, 10
8ExprTuple11, 12, 13, 14
9Operationoperator: 30
operand: 22
10Operationoperator: 59
operands: 16
11Operationoperator: 48
operands: 17
12Operationoperator: 48
operands: 18
13Operationoperator: 48
operands: 19
14Operationoperator: 20
operands: 21
15ExprTuple22
16ExprTuple23, 24
17ExprTuple56, 25
18ExprTuple61, 25
19ExprTuple58, 25
20Literal
21ExprTuple26, 27
22Lambdaparameter: 51
body: 28
23Operationoperator: 30
operand: 35
24Operationoperator: 30
operand: 36
25Literal
26Operationoperator: 32
operands: 53
27Operationoperator: 32
operands: 33
28Conditionalvalue: 42
condition: 34
29ExprTuple35
30Literal
31ExprTuple36
32Literal
33ExprTuple61, 58
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