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, n
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, NaturalPos, RealNonNeg
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
expr = Forall(instance_param_or_params = [n], instance_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))), domain = 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())
\forall_{n \in \mathbb{N}^+}~\left[\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)\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: 17
operand: 2
1ExprTuple2
2Lambdaparameter: 41
body: 4
3ExprTuple41
4Conditionalvalue: 5
condition: 6
5Operationoperator: 17
operand: 9
6Operationoperator: 43
operands: 8
7ExprTuple9
8ExprTuple41, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple32, 46
12Operationoperator: 13
operands: 14
13Literal
14ExprTuple15, 16
15Operationoperator: 17
operand: 20
16Operationoperator: 43
operands: 19
17Literal
18ExprTuple20
19ExprTuple21, 29
20Lambdaparameters: 33
body: 22
21Operationoperator: 23
operand: 26
22Conditionalvalue: 25
condition: 31
23Literal
24ExprTuple26
25Operationoperator: 43
operands: 27
26Lambdaparameters: 33
body: 28
27ExprTuple30, 29
28Conditionalvalue: 30
condition: 31
29Literal
30Operationoperator: 32
operands: 33
31Operationoperator: 34
operands: 35
32Variable
33ExprTuple36
34Literal
35ExprTuple37
36ExprRangelambda_map: 38
start_index: 40
end_index: 41
37ExprRangelambda_map: 39
start_index: 40
end_index: 41
38Lambdaparameter: 49
body: 45
39Lambdaparameter: 49
body: 42
40Literal
41Variable
42Operationoperator: 43
operands: 44
43Literal
44ExprTuple45, 46
45IndexedVarvariable: 47
index: 49
46Variable
47Variable
48ExprTuple49
49Variable