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 Conditional, Lambda, S, a, b, f, fa, fx, x
from proveit.logic import And, Forall, InSet, 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(f, Conditional(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)]), 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())
f \mapsto \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) \textrm{ if } f \in \textrm{MonDecFuncs}\left(S\right) ,  S \subseteq \mathbb{R}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 55
body: 2
1ExprTuple55
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 19
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 62
body: 11
9Operationoperator: 57
operands: 12
10Operationoperator: 36
operands: 13
11Conditionalvalue: 14
condition: 15
12ExprTuple55, 16
13ExprTuple42, 17
14Operationoperator: 35
operands: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operand: 42
17Literal
18ExprTuple23, 24
19Literal
20ExprTuple25, 26, 27, 28
21Literal
22ExprTuple42
23Operationoperator: 29
operand: 38
24Operationoperator: 31
operands: 32
25Operationoperator: 57
operands: 33
26Operationoperator: 57
operands: 34
27Operationoperator: 35
operands: 62
28Operationoperator: 36
operands: 37
29Literal
30ExprTuple38
31Literal
32ExprTuple39, 40
33ExprTuple63, 41
34ExprTuple64, 41
35Literal
36Literal
37ExprTuple60, 42
38Lambdaparameter: 59
body: 43
39Operationoperator: 55
operand: 63
40Operationoperator: 45
operand: 48
41Literal
42Variable
43Conditionalvalue: 52
condition: 47
44ExprTuple63
45Literal
46ExprTuple48
47Operationoperator: 57
operands: 49
48Lambdaparameter: 59
body: 50
49ExprTuple59, 51
50Conditionalvalue: 52
condition: 53
51Operationoperator: 54
operands: 62
52Operationoperator: 55
operand: 59
53Operationoperator: 57
operands: 58
54Literal
55Variable
56ExprTuple59
57Literal
58ExprTuple59, 60
59Variable
60Operationoperator: 61
operands: 62
61Literal
62ExprTuple63, 64
63Variable
64Variable