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, fa, fx, x
from proveit.logic import And, InSet, SubsetEq
from proveit.numbers import Add, Integer, Integrate, Interval, IntervalCC, LessEq, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = IntervalCC(a, b)
expr = Lambda([a, b], Conditional(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))), And(InSet(a, Integer), InSet(b, Integer), LessEq(a, b), SubsetEq(sub_expr2, S))))
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(a, b\right) \mapsto \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) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  a \leq b ,  \left[a,b\right] \subseteq S\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 46
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 19
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11, 12
7Operationoperator: 13
operand: 22
8Operationoperator: 15
operands: 16
9Operationoperator: 41
operands: 17
10Operationoperator: 41
operands: 18
11Operationoperator: 19
operands: 46
12Operationoperator: 20
operands: 21
13Literal
14ExprTuple22
15Literal
16ExprTuple23, 24
17ExprTuple47, 25
18ExprTuple48, 25
19Literal
20Literal
21ExprTuple44, 26
22Lambdaparameter: 43
body: 27
23Operationoperator: 39
operand: 47
24Operationoperator: 29
operand: 32
25Literal
26Variable
27Conditionalvalue: 36
condition: 31
28ExprTuple47
29Literal
30ExprTuple32
31Operationoperator: 41
operands: 33
32Lambdaparameter: 43
body: 34
33ExprTuple43, 35
34Conditionalvalue: 36
condition: 37
35Operationoperator: 38
operands: 46
36Operationoperator: 39
operand: 43
37Operationoperator: 41
operands: 42
38Literal
39Variable
40ExprTuple43
41Literal
42ExprTuple43, 44
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Variable
48Variable