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, fb, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, Sum, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda([a, b], Conditional(Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, subtract(b, one))), fb)), 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_{x = a}^{b} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b - 1} f\left(x\right)\right) + f\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: 34
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Operationoperator: 24
operand: 19
10Operationoperator: 45
operands: 15
11Operationoperator: 37
operands: 16
12Operationoperator: 37
operands: 17
13Operationoperator: 18
operands: 34
14ExprTuple19
15ExprTuple20, 21
16ExprTuple43, 22
17ExprTuple47, 22
18Literal
19Lambdaparameter: 39
body: 23
20Operationoperator: 24
operand: 28
21Operationoperator: 35
operand: 47
22Literal
23Conditionalvalue: 32
condition: 27
24Literal
25ExprTuple28
26ExprTuple47
27Operationoperator: 37
operands: 29
28Lambdaparameter: 39
body: 30
29ExprTuple39, 31
30Conditionalvalue: 32
condition: 33
31Operationoperator: 41
operands: 34
32Operationoperator: 35
operand: 39
33Operationoperator: 37
operands: 38
34ExprTuple43, 47
35Variable
36ExprTuple39
37Literal
38ExprTuple39, 40
39Variable
40Operationoperator: 41
operands: 42
41Literal
42ExprTuple43, 44
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Variable
48Operationoperator: 49
operand: 51
49Literal
50ExprTuple51
51Literal