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, fx, x
from proveit.logic import Forall, SubsetEq
from proveit.numbers import Integer, Integrate, Interval, IntervalCC, LessEq, MonDecFuncs, Real, Sum, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = IntervalCC(subtract(a, one), b)
expr = Forall(instance_param_or_params = [S], instance_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)), 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_{S}~\left[\forall_{f \in \textrm{MonDecFuncs}\left(S\right)~|~S \subseteq \mathbb{R}}~\left[\forall_{a, b \in \mathbb{Z}~|~a \leq b, \left[a - 1,b\right] \subseteq S}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) \leq \left(\int_{a - 1}^{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: 10
operand: 2
1ExprTuple2
2Lambdaparameter: 46
body: 3
3Operationoperator: 10
operand: 5
4ExprTuple5
5Lambdaparameter: 53
body: 7
6ExprTuple53
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 13
9Operationoperator: 24
operands: 12
10Literal
11ExprTuple13
12ExprTuple14, 15
13Lambdaparameters: 61
body: 16
14Operationoperator: 55
operands: 17
15Operationoperator: 41
operands: 18
16Conditionalvalue: 19
condition: 20
17ExprTuple53, 21
18ExprTuple46, 22
19Operationoperator: 40
operands: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operand: 46
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30, 31, 32, 33
26Literal
27ExprTuple46
28Operationoperator: 34
operand: 43
29Operationoperator: 36
operand: 44
30Operationoperator: 55
operands: 38
31Operationoperator: 55
operands: 39
32Operationoperator: 40
operands: 61
33Operationoperator: 41
operands: 42
34Literal
35ExprTuple43
36Literal
37ExprTuple44
38ExprTuple68, 45
39ExprTuple65, 45
40Literal
41Literal
42ExprTuple59, 46
43Lambdaparameter: 58
body: 47
44Lambdaparameter: 58
body: 48
45Literal
46Variable
47Conditionalvalue: 50
condition: 49
48Conditionalvalue: 50
condition: 51
49Operationoperator: 55
operands: 52
50Operationoperator: 53
operand: 58
51Operationoperator: 55
operands: 56
52ExprTuple58, 57
53Variable
54ExprTuple58
55Literal
56ExprTuple58, 59
57Operationoperator: 60
operands: 61
58Variable
59Operationoperator: 62
operands: 63
60Literal
61ExprTuple68, 65
62Literal
63ExprTuple64, 65
64Operationoperator: 66
operands: 67
65Variable
66Literal
67ExprTuple68, 69
68Variable
69Operationoperator: 70
operand: 72
70Literal
71ExprTuple72
72Literal