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 = [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_{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]
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: 50
body: 4
3ExprTuple50
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 21
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 58
body: 13
11Operationoperator: 52
operands: 14
12Operationoperator: 38
operands: 15
13Conditionalvalue: 16
condition: 17
14ExprTuple50, 18
15ExprTuple43, 19
16Operationoperator: 37
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operand: 43
19Literal
20ExprTuple25, 26
21Literal
22ExprTuple27, 28, 29, 30
23Literal
24ExprTuple43
25Operationoperator: 31
operand: 40
26Operationoperator: 33
operand: 41
27Operationoperator: 52
operands: 35
28Operationoperator: 52
operands: 36
29Operationoperator: 37
operands: 58
30Operationoperator: 38
operands: 39
31Literal
32ExprTuple40
33Literal
34ExprTuple41
35ExprTuple65, 42
36ExprTuple62, 42
37Literal
38Literal
39ExprTuple56, 43
40Lambdaparameter: 55
body: 44
41Lambdaparameter: 55
body: 45
42Literal
43Variable
44Conditionalvalue: 47
condition: 46
45Conditionalvalue: 47
condition: 48
46Operationoperator: 52
operands: 49
47Operationoperator: 50
operand: 55
48Operationoperator: 52
operands: 53
49ExprTuple55, 54
50Variable
51ExprTuple55
52Literal
53ExprTuple55, 56
54Operationoperator: 57
operands: 58
55Variable
56Operationoperator: 59
operands: 60
57Literal
58ExprTuple65, 62
59Literal
60ExprTuple61, 62
61Operationoperator: 63
operands: 64
62Variable
63Literal
64ExprTuple65, 66
65Variable
66Operationoperator: 67
operand: 69
67Literal
68ExprTuple69
69Literal