logo

Expression of type Forall

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 S, f
from proveit.core_expr_types import f__x_1_to_n, x_1_to_n
from proveit.logic import Forall, Implies, InSet
from proveit.numbers import Integrate, RealNonNeg
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
expr = Forall(instance_param_or_params = [f, S], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(f__x_1_to_n, RealNonNeg), domain = S), InSet(Integrate(index_or_indices = sub_expr1, integrand = f__x_1_to_n, domain = S), RealNonNeg)))
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())
\forall_{f, S}~\left(\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in S}~\left(f\left(x_{1}, x_{2}, \ldots, x_{n}\right) \in \mathbb{R}^{\ge 0}\right)\right] \Rightarrow \left(\left[\int_{x_{1}, x_{2}, \ldots, x_{n} \in S}~f\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \in \mathbb{R}^{\ge 0}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 9
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple24, 38
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8
7Operationoperator: 9
operand: 12
8Operationoperator: 35
operands: 11
9Literal
10ExprTuple12
11ExprTuple13, 21
12Lambdaparameters: 25
body: 14
13Operationoperator: 15
operand: 18
14Conditionalvalue: 17
condition: 23
15Literal
16ExprTuple18
17Operationoperator: 35
operands: 19
18Lambdaparameters: 25
body: 20
19ExprTuple22, 21
20Conditionalvalue: 22
condition: 23
21Literal
22Operationoperator: 24
operands: 25
23Operationoperator: 26
operands: 27
24Variable
25ExprTuple28
26Literal
27ExprTuple29
28ExprRangelambda_map: 30
start_index: 32
end_index: 33
29ExprRangelambda_map: 31
start_index: 32
end_index: 33
30Lambdaparameter: 41
body: 37
31Lambdaparameter: 41
body: 34
32Literal
33Variable
34Operationoperator: 35
operands: 36
35Literal
36ExprTuple37, 38
37IndexedVarvariable: 39
index: 41
38Variable
39Variable
40ExprTuple41
41Variable