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, fx, x
from proveit.logic import And, InSet, SubsetEq
from proveit.numbers import Integer, Integrate, Interval, IntervalCC, LessEq, Sum, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = IntervalCC(subtract(a, one), b)
expr = Lambda([a, b], Conditional(LessEq(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), 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(\int_{a - 1}^{b} f\left(x\right)\,dx\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  a \leq b ,  \left[a - 1,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: 40
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
operand: 23
9Operationoperator: 34
operands: 17
10Operationoperator: 34
operands: 18
11Operationoperator: 19
operands: 40
12Operationoperator: 20
operands: 21
13Literal
14ExprTuple22
15Literal
16ExprTuple23
17ExprTuple47, 24
18ExprTuple44, 24
19Literal
20Literal
21ExprTuple38, 25
22Lambdaparameter: 37
body: 26
23Lambdaparameter: 37
body: 27
24Literal
25Variable
26Conditionalvalue: 29
condition: 28
27Conditionalvalue: 29
condition: 30
28Operationoperator: 34
operands: 31
29Operationoperator: 32
operand: 37
30Operationoperator: 34
operands: 35
31ExprTuple37, 36
32Variable
33ExprTuple37
34Literal
35ExprTuple37, 38
36Operationoperator: 39
operands: 40
37Variable
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple47, 44
41Literal
42ExprTuple43, 44
43Operationoperator: 45
operands: 46
44Variable
45Literal
46ExprTuple47, 48
47Variable
48Operationoperator: 49
operand: 51
49Literal
50ExprTuple51
51Literal