logo

Expression of type Forall

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 S, a, b, f, fa, fx, x
from proveit.logic import Forall, SubsetEq
from proveit.numbers import Add, Integer, Integrate, Interval, IntervalCC, LessEq, MonDecFuncs, Real, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = IntervalCC(a, b)
expr = Forall(instance_param_or_params = [f], instance_expr = Forall(instance_param_or_params = [a, b], instance_expr = 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))), domain = Integer, conditions = [LessEq(a, b), SubsetEq(sub_expr2, S)]), domain = MonDecFuncs(S), condition = SubsetEq(S, Real))
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 \in \textrm{MonDecFuncs}\left(S\right)~|~S \subseteq \mathbb{R}}~\left[\forall_{a, b \in \mathbb{Z}~|~a \leq b, \left[a,b\right] \subseteq S}~\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)\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: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 57
body: 4
3ExprTuple57
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 21
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 64
body: 13
11Operationoperator: 59
operands: 14
12Operationoperator: 38
operands: 15
13Conditionalvalue: 16
condition: 17
14ExprTuple57, 18
15ExprTuple44, 19
16Operationoperator: 37
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operand: 44
19Literal
20ExprTuple25, 26
21Literal
22ExprTuple27, 28, 29, 30
23Literal
24ExprTuple44
25Operationoperator: 31
operand: 40
26Operationoperator: 33
operands: 34
27Operationoperator: 59
operands: 35
28Operationoperator: 59
operands: 36
29Operationoperator: 37
operands: 64
30Operationoperator: 38
operands: 39
31Literal
32ExprTuple40
33Literal
34ExprTuple41, 42
35ExprTuple65, 43
36ExprTuple66, 43
37Literal
38Literal
39ExprTuple62, 44
40Lambdaparameter: 61
body: 45
41Operationoperator: 57
operand: 65
42Operationoperator: 47
operand: 50
43Literal
44Variable
45Conditionalvalue: 54
condition: 49
46ExprTuple65
47Literal
48ExprTuple50
49Operationoperator: 59
operands: 51
50Lambdaparameter: 61
body: 52
51ExprTuple61, 53
52Conditionalvalue: 54
condition: 55
53Operationoperator: 56
operands: 64
54Operationoperator: 57
operand: 61
55Operationoperator: 59
operands: 60
56Literal
57Variable
58ExprTuple61
59Literal
60ExprTuple61, 62
61Variable
62Operationoperator: 63
operands: 64
63Literal
64ExprTuple65, 66
65Variable
66Variable