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, f, fa, fx, x
from proveit.logic import And, Forall, InSet, SubsetEq
from proveit.numbers import Add, Integer, Integrate, Interval, IntervalCC, LessEq, MonDecFuncs, Real, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = IntervalCC(a, b)
expr = ExprTuple(Lambda(f, Conditional(Forall(instance_param_or_params = [a, b], instance_expr = 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))), domain = Integer, conditions = [LessEq(a, b), SubsetEq(sub_expr2, S)]), And(InSet(f, MonDecFuncs(S)), SubsetEq(S, Real)))))
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(f \mapsto \left\{\forall_{a, b \in \mathbb{Z}~|~a \leq b, \left[a,b\right] \subseteq S}~\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)\right) \textrm{ if } f \in \textrm{MonDecFuncs}\left(S\right) ,  S \subseteq \mathbb{R}\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
1Lambdaparameter: 56
body: 3
2ExprTuple56
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 20
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 63
body: 12
10Operationoperator: 58
operands: 13
11Operationoperator: 37
operands: 14
12Conditionalvalue: 15
condition: 16
13ExprTuple56, 17
14ExprTuple43, 18
15Operationoperator: 36
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operand: 43
18Literal
19ExprTuple24, 25
20Literal
21ExprTuple26, 27, 28, 29
22Literal
23ExprTuple43
24Operationoperator: 30
operand: 39
25Operationoperator: 32
operands: 33
26Operationoperator: 58
operands: 34
27Operationoperator: 58
operands: 35
28Operationoperator: 36
operands: 63
29Operationoperator: 37
operands: 38
30Literal
31ExprTuple39
32Literal
33ExprTuple40, 41
34ExprTuple64, 42
35ExprTuple65, 42
36Literal
37Literal
38ExprTuple61, 43
39Lambdaparameter: 60
body: 44
40Operationoperator: 56
operand: 64
41Operationoperator: 46
operand: 49
42Literal
43Variable
44Conditionalvalue: 53
condition: 48
45ExprTuple64
46Literal
47ExprTuple49
48Operationoperator: 58
operands: 50
49Lambdaparameter: 60
body: 51
50ExprTuple60, 52
51Conditionalvalue: 53
condition: 54
52Operationoperator: 55
operands: 63
53Operationoperator: 56
operand: 60
54Operationoperator: 58
operands: 59
55Literal
56Variable
57ExprTuple60
58Literal
59ExprTuple60, 61
60Variable
61Operationoperator: 62
operands: 63
62Literal
63ExprTuple64, 65
64Variable
65Variable