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