logo

Expression of type Lambda

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 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 = 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())
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]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 45
body: 1
1Operationoperator: 8
operand: 3
2ExprTuple3
3Lambdaparameter: 58
body: 5
4ExprTuple58
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operand: 11
7Operationoperator: 22
operands: 10
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 65
body: 14
12Operationoperator: 60
operands: 15
13Operationoperator: 39
operands: 16
14Conditionalvalue: 17
condition: 18
15ExprTuple58, 19
16ExprTuple45, 20
17Operationoperator: 38
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operand: 45
20Literal
21ExprTuple26, 27
22Literal
23ExprTuple28, 29, 30, 31
24Literal
25ExprTuple45
26Operationoperator: 32
operand: 41
27Operationoperator: 34
operands: 35
28Operationoperator: 60
operands: 36
29Operationoperator: 60
operands: 37
30Operationoperator: 38
operands: 65
31Operationoperator: 39
operands: 40
32Literal
33ExprTuple41
34Literal
35ExprTuple42, 43
36ExprTuple66, 44
37ExprTuple67, 44
38Literal
39Literal
40ExprTuple63, 45
41Lambdaparameter: 62
body: 46
42Operationoperator: 58
operand: 66
43Operationoperator: 48
operand: 51
44Literal
45Variable
46Conditionalvalue: 55
condition: 50
47ExprTuple66
48Literal
49ExprTuple51
50Operationoperator: 60
operands: 52
51Lambdaparameter: 62
body: 53
52ExprTuple62, 54
53Conditionalvalue: 55
condition: 56
54Operationoperator: 57
operands: 65
55Operationoperator: 58
operand: 62
56Operationoperator: 60
operands: 61
57Literal
58Variable
59ExprTuple62
60Literal
61ExprTuple62, 63
62Variable
63Operationoperator: 64
operands: 65
64Literal
65ExprTuple66, 67
66Variable
67Variable