logo

Expression of type Lambda

from the theory of proveit.numbers.integration

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, P, S, n
from proveit.core_expr_types import P__x_1_to_n, x_1_to_n
from proveit.logic import Forall, Implies, InSet
from proveit.numbers import Integrate, NaturalPos, Real
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [P, S], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(P__x_1_to_n, Real), domain = S), InSet(Integrate(index_or_indices = sub_expr1, integrand = P__x_1_to_n, domain = S), Real))), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\forall_{P, S}~\left(\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in S}~\left(P\left(x_{1}, x_{2}, \ldots, x_{n}\right) \in \mathbb{R}\right)\right] \Rightarrow \left(\left[\int_{x_{1}, x_{2}, \ldots, x_{n} \in S}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \in \mathbb{R}\right)\right) \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 39
body: 2
1ExprTuple39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 15
operand: 7
4Operationoperator: 41
operands: 6
5ExprTuple7
6ExprTuple39, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple30, 44
10Operationoperator: 11
operands: 12
11Literal
12ExprTuple13, 14
13Operationoperator: 15
operand: 18
14Operationoperator: 41
operands: 17
15Literal
16ExprTuple18
17ExprTuple19, 27
18Lambdaparameters: 31
body: 20
19Operationoperator: 21
operand: 24
20Conditionalvalue: 23
condition: 29
21Literal
22ExprTuple24
23Operationoperator: 41
operands: 25
24Lambdaparameters: 31
body: 26
25ExprTuple28, 27
26Conditionalvalue: 28
condition: 29
27Literal
28Operationoperator: 30
operands: 31
29Operationoperator: 32
operands: 33
30Variable
31ExprTuple34
32Literal
33ExprTuple35
34ExprRangelambda_map: 36
start_index: 38
end_index: 39
35ExprRangelambda_map: 37
start_index: 38
end_index: 39
36Lambdaparameter: 47
body: 43
37Lambdaparameter: 47
body: 40
38Literal
39Variable
40Operationoperator: 41
operands: 42
41Literal
42ExprTuple43, 44
43IndexedVarvariable: 45
index: 47
44Variable
45Variable
46ExprTuple47
47Variable