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