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