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 ExprTuple, Lambda, S, a, b, f, fa, fx, x
from proveit.logic import Forall, 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(S, Forall(instance_param_or_params = [f], instance_expr = 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)]), domain = MonDecFuncs(S), condition = 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(S \mapsto \left[\forall_{f \in \textrm{MonDecFuncs}\left(S\right)~|~S \subseteq \mathbb{R}}~\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)\right]\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: 46
body: 2
2Operationoperator: 9
operand: 4
3ExprTuple4
4Lambdaparameter: 59
body: 6
5ExprTuple59
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operand: 12
8Operationoperator: 23
operands: 11
9Literal
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 66
body: 15
13Operationoperator: 61
operands: 16
14Operationoperator: 40
operands: 17
15Conditionalvalue: 18
condition: 19
16ExprTuple59, 20
17ExprTuple46, 21
18Operationoperator: 39
operands: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operand: 46
21Literal
22ExprTuple27, 28
23Literal
24ExprTuple29, 30, 31, 32
25Literal
26ExprTuple46
27Operationoperator: 33
operand: 42
28Operationoperator: 35
operands: 36
29Operationoperator: 61
operands: 37
30Operationoperator: 61
operands: 38
31Operationoperator: 39
operands: 66
32Operationoperator: 40
operands: 41
33Literal
34ExprTuple42
35Literal
36ExprTuple43, 44
37ExprTuple67, 45
38ExprTuple68, 45
39Literal
40Literal
41ExprTuple64, 46
42Lambdaparameter: 63
body: 47
43Operationoperator: 59
operand: 67
44Operationoperator: 49
operand: 52
45Literal
46Variable
47Conditionalvalue: 56
condition: 51
48ExprTuple67
49Literal
50ExprTuple52
51Operationoperator: 61
operands: 53
52Lambdaparameter: 63
body: 54
53ExprTuple63, 55
54Conditionalvalue: 56
condition: 57
55Operationoperator: 58
operands: 66
56Operationoperator: 59
operand: 63
57Operationoperator: 61
operands: 62
58Literal
59Variable
60ExprTuple63
61Literal
62ExprTuple63, 64
63Variable
64Operationoperator: 65
operands: 66
65Literal
66ExprTuple67, 68
67Variable
68Variable