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, Function, Lambda, a, b, c, f, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Sum, 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, b)), Sum(index_or_indices = sub_expr1, summand = Function(f, [subtract(x, c)]), domain = Interval(Add(a, c), Add(b, c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer)))))
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}^{b} f\left(x\right)\right) = \left(\sum_{x = a + c}^{b + c} f\left(x - c\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z}\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
2ExprTuple52, 53, 54
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10Operationoperator: 16
operand: 21
11Operationoperator: 16
operand: 22
12Operationoperator: 34
operands: 18
13Operationoperator: 34
operands: 19
14Operationoperator: 34
operands: 20
15ExprTuple21
16Literal
17ExprTuple22
18ExprTuple52, 23
19ExprTuple53, 23
20ExprTuple54, 23
21Lambdaparameter: 43
body: 24
22Lambdaparameter: 43
body: 25
23Literal
24Conditionalvalue: 26
condition: 27
25Conditionalvalue: 28
condition: 29
26Operationoperator: 32
operand: 43
27Operationoperator: 34
operands: 31
28Operationoperator: 32
operand: 37
29Operationoperator: 34
operands: 35
30ExprTuple43
31ExprTuple43, 36
32Variable
33ExprTuple37
34Literal
35ExprTuple43, 38
36Operationoperator: 41
operands: 39
37Operationoperator: 50
operands: 40
38Operationoperator: 41
operands: 42
39ExprTuple52, 53
40ExprTuple43, 44
41Literal
42ExprTuple45, 46
43Variable
44Operationoperator: 47
operand: 54
45Operationoperator: 50
operands: 49
46Operationoperator: 50
operands: 51
47Literal
48ExprTuple54
49ExprTuple52, 54
50Literal
51ExprTuple53, 54
52Variable
53Variable
54Variable