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, fx, x
from proveit.logic import And, Forall, InSet, SubsetEq
from proveit.numbers import Integer, Integrate, Interval, IntervalCC, LessEq, MonDecFuncs, Real, 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(f, Conditional(Forall(instance_param_or_params = [a, b], instance_expr = LessEq(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), 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 - 1,b\right] \subseteq S}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) \leq \left(\int_{a - 1}^{b} f\left(x\right)\,dx\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: 49
body: 3
2ExprTuple49
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 20
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 57
body: 12
10Operationoperator: 51
operands: 13
11Operationoperator: 37
operands: 14
12Conditionalvalue: 15
condition: 16
13ExprTuple49, 17
14ExprTuple42, 18
15Operationoperator: 36
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operand: 42
18Literal
19ExprTuple24, 25
20Literal
21ExprTuple26, 27, 28, 29
22Literal
23ExprTuple42
24Operationoperator: 30
operand: 39
25Operationoperator: 32
operand: 40
26Operationoperator: 51
operands: 34
27Operationoperator: 51
operands: 35
28Operationoperator: 36
operands: 57
29Operationoperator: 37
operands: 38
30Literal
31ExprTuple39
32Literal
33ExprTuple40
34ExprTuple64, 41
35ExprTuple61, 41
36Literal
37Literal
38ExprTuple55, 42
39Lambdaparameter: 54
body: 43
40Lambdaparameter: 54
body: 44
41Literal
42Variable
43Conditionalvalue: 46
condition: 45
44Conditionalvalue: 46
condition: 47
45Operationoperator: 51
operands: 48
46Operationoperator: 49
operand: 54
47Operationoperator: 51
operands: 52
48ExprTuple54, 53
49Variable
50ExprTuple54
51Literal
52ExprTuple54, 55
53Operationoperator: 56
operands: 57
54Variable
55Operationoperator: 58
operands: 59
56Literal
57ExprTuple64, 61
58Literal
59ExprTuple60, 61
60Operationoperator: 62
operands: 63
61Variable
62Literal
63ExprTuple64, 65
64Variable
65Operationoperator: 66
operand: 68
66Literal
67ExprTuple68
68Literal