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, Less, LessEq, Sum, one, subtract
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, subtract(b, one))), Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(b, c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), Less(a, b), LessEq(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_{x = a}^{c} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b - 1} f\left(x\right)\right) + \left(\sum_{x = b}^{c} f\left(x\right)\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  a < b ,  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
2ExprTuple55, 60, 57
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14, 15, 16
10Operationoperator: 31
operand: 25
11Operationoperator: 58
operands: 18
12Operationoperator: 47
operands: 19
13Operationoperator: 47
operands: 20
14Operationoperator: 47
operands: 21
15Operationoperator: 22
operands: 23
16Operationoperator: 24
operands: 54
17ExprTuple25
18ExprTuple26, 27
19ExprTuple55, 28
20ExprTuple60, 28
21ExprTuple57, 28
22Literal
23ExprTuple55, 60
24Literal
25Lambdaparameter: 50
body: 29
26Operationoperator: 31
operand: 34
27Operationoperator: 31
operand: 35
28Literal
29Conditionalvalue: 41
condition: 33
30ExprTuple34
31Literal
32ExprTuple35
33Operationoperator: 47
operands: 36
34Lambdaparameter: 50
body: 37
35Lambdaparameter: 50
body: 38
36ExprTuple50, 39
37Conditionalvalue: 41
condition: 40
38Conditionalvalue: 41
condition: 42
39Operationoperator: 53
operands: 43
40Operationoperator: 47
operands: 44
41Operationoperator: 45
operand: 50
42Operationoperator: 47
operands: 48
43ExprTuple55, 57
44ExprTuple50, 49
45Variable
46ExprTuple50
47Literal
48ExprTuple50, 51
49Operationoperator: 53
operands: 52
50Variable
51Operationoperator: 53
operands: 54
52ExprTuple55, 56
53Literal
54ExprTuple60, 57
55Variable
56Operationoperator: 58
operands: 59
57Variable
58Literal
59ExprTuple60, 61
60Variable
61Operationoperator: 62
operand: 64
62Literal
63ExprTuple64
64Literal