logo

Expression of type Conditional

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 Conditional, S, a, b, f, fa, fx, x
from proveit.logic import And, Forall, InSet, 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 = Conditional(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)]), And(InSet(f, MonDecFuncs(S)), 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())
\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) \textrm{ if } f \in \textrm{MonDecFuncs}\left(S\right) ,  S \subseteq \mathbb{R}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 17
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 60
body: 9
7Operationoperator: 55
operands: 10
8Operationoperator: 34
operands: 11
9Conditionalvalue: 12
condition: 13
10ExprTuple53, 14
11ExprTuple40, 15
12Operationoperator: 33
operands: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 19
operand: 40
15Literal
16ExprTuple21, 22
17Literal
18ExprTuple23, 24, 25, 26
19Literal
20ExprTuple40
21Operationoperator: 27
operand: 36
22Operationoperator: 29
operands: 30
23Operationoperator: 55
operands: 31
24Operationoperator: 55
operands: 32
25Operationoperator: 33
operands: 60
26Operationoperator: 34
operands: 35
27Literal
28ExprTuple36
29Literal
30ExprTuple37, 38
31ExprTuple61, 39
32ExprTuple62, 39
33Literal
34Literal
35ExprTuple58, 40
36Lambdaparameter: 57
body: 41
37Operationoperator: 53
operand: 61
38Operationoperator: 43
operand: 46
39Literal
40Variable
41Conditionalvalue: 50
condition: 45
42ExprTuple61
43Literal
44ExprTuple46
45Operationoperator: 55
operands: 47
46Lambdaparameter: 57
body: 48
47ExprTuple57, 49
48Conditionalvalue: 50
condition: 51
49Operationoperator: 52
operands: 60
50Operationoperator: 53
operand: 57
51Operationoperator: 55
operands: 56
52Literal
53Variable
54ExprTuple57
55Literal
56ExprTuple57, 58
57Variable
58Operationoperator: 59
operands: 60
59Literal
60ExprTuple61, 62
61Variable
62Variable