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, S, a, b, fa, fx, x
from proveit.logic import And, InSet, SubsetEq
from proveit.numbers import Add, Integer, Integrate, Interval, IntervalCC, LessEq, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = IntervalCC(a, b)
expr = ExprTuple(Lambda([a, b], Conditional(LessEq(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Add(fa, Integrate(index_or_indices = sub_expr1, integrand = fx, domain = sub_expr2))), And(InSet(a, Integer), InSet(b, Integer), LessEq(a, b), SubsetEq(sub_expr2, S)))))
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) \leq \left(f\left(a\right) + \left(\int_{a}^{b} f\left(x\right)\,dx\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  a \leq b ,  \left[a,b\right] \subseteq S\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: 47
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 20
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12, 13
8Operationoperator: 14
operand: 23
9Operationoperator: 16
operands: 17
10Operationoperator: 42
operands: 18
11Operationoperator: 42
operands: 19
12Operationoperator: 20
operands: 47
13Operationoperator: 21
operands: 22
14Literal
15ExprTuple23
16Literal
17ExprTuple24, 25
18ExprTuple48, 26
19ExprTuple49, 26
20Literal
21Literal
22ExprTuple45, 27
23Lambdaparameter: 44
body: 28
24Operationoperator: 40
operand: 48
25Operationoperator: 30
operand: 33
26Literal
27Variable
28Conditionalvalue: 37
condition: 32
29ExprTuple48
30Literal
31ExprTuple33
32Operationoperator: 42
operands: 34
33Lambdaparameter: 44
body: 35
34ExprTuple44, 36
35Conditionalvalue: 37
condition: 38
36Operationoperator: 39
operands: 47
37Operationoperator: 40
operand: 44
38Operationoperator: 42
operands: 43
39Literal
40Variable
41ExprTuple44
42Literal
43ExprTuple44, 45
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Variable
49Variable