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, fx, x
from proveit.logic import Forall, 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(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)), 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 - 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)\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: 45
body: 2
2Operationoperator: 9
operand: 4
3ExprTuple4
4Lambdaparameter: 52
body: 6
5ExprTuple52
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operand: 12
8Operationoperator: 23
operands: 11
9Literal
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 60
body: 15
13Operationoperator: 54
operands: 16
14Operationoperator: 40
operands: 17
15Conditionalvalue: 18
condition: 19
16ExprTuple52, 20
17ExprTuple45, 21
18Operationoperator: 39
operands: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operand: 45
21Literal
22ExprTuple27, 28
23Literal
24ExprTuple29, 30, 31, 32
25Literal
26ExprTuple45
27Operationoperator: 33
operand: 42
28Operationoperator: 35
operand: 43
29Operationoperator: 54
operands: 37
30Operationoperator: 54
operands: 38
31Operationoperator: 39
operands: 60
32Operationoperator: 40
operands: 41
33Literal
34ExprTuple42
35Literal
36ExprTuple43
37ExprTuple67, 44
38ExprTuple64, 44
39Literal
40Literal
41ExprTuple58, 45
42Lambdaparameter: 57
body: 46
43Lambdaparameter: 57
body: 47
44Literal
45Variable
46Conditionalvalue: 49
condition: 48
47Conditionalvalue: 49
condition: 50
48Operationoperator: 54
operands: 51
49Operationoperator: 52
operand: 57
50Operationoperator: 54
operands: 55
51ExprTuple57, 56
52Variable
53ExprTuple57
54Literal
55ExprTuple57, 58
56Operationoperator: 59
operands: 60
57Variable
58Operationoperator: 61
operands: 62
59Literal
60ExprTuple67, 64
61Literal
62ExprTuple63, 64
63Operationoperator: 65
operands: 66
64Variable
65Literal
66ExprTuple67, 68
67Variable
68Operationoperator: 69
operand: 71
69Literal
70ExprTuple71
71Literal