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, f, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Integer, Interval, Neg, Sum
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)), Sum(index_or_indices = sub_expr1, summand = Function(f, [Neg(x)]), domain = Interval(Neg(b), Neg(a)))), And(InSet(a, Integer), InSet(b, 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\right) \mapsto \left\{\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\sum_{x = -b}^{-a} f\left(-x\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \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: 35
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 14
operand: 18
10Operationoperator: 14
operand: 19
11Operationoperator: 30
operands: 16
12Operationoperator: 30
operands: 17
13ExprTuple18
14Literal
15ExprTuple19
16ExprTuple46, 20
17ExprTuple45, 20
18Lambdaparameter: 39
body: 21
19Lambdaparameter: 39
body: 22
20Literal
21Conditionalvalue: 23
condition: 24
22Conditionalvalue: 25
condition: 26
23Operationoperator: 28
operand: 39
24Operationoperator: 30
operands: 27
25Operationoperator: 28
operand: 33
26Operationoperator: 30
operands: 31
27ExprTuple39, 32
28Variable
29ExprTuple33
30Literal
31ExprTuple39, 34
32Operationoperator: 37
operands: 35
33Operationoperator: 43
operand: 39
34Operationoperator: 37
operands: 38
35ExprTuple46, 45
36ExprTuple39
37Literal
38ExprTuple40, 41
39Variable
40Operationoperator: 43
operand: 45
41Operationoperator: 43
operand: 46
42ExprTuple45
43Literal
44ExprTuple46
45Variable
46Variable