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, fx, x
from proveit.logic import And, Forall, InSet, 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 = Conditional(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)]), 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 - 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) \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: 54
body: 9
7Operationoperator: 48
operands: 10
8Operationoperator: 34
operands: 11
9Conditionalvalue: 12
condition: 13
10ExprTuple46, 14
11ExprTuple39, 15
12Operationoperator: 33
operands: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 19
operand: 39
15Literal
16ExprTuple21, 22
17Literal
18ExprTuple23, 24, 25, 26
19Literal
20ExprTuple39
21Operationoperator: 27
operand: 36
22Operationoperator: 29
operand: 37
23Operationoperator: 48
operands: 31
24Operationoperator: 48
operands: 32
25Operationoperator: 33
operands: 54
26Operationoperator: 34
operands: 35
27Literal
28ExprTuple36
29Literal
30ExprTuple37
31ExprTuple61, 38
32ExprTuple58, 38
33Literal
34Literal
35ExprTuple52, 39
36Lambdaparameter: 51
body: 40
37Lambdaparameter: 51
body: 41
38Literal
39Variable
40Conditionalvalue: 43
condition: 42
41Conditionalvalue: 43
condition: 44
42Operationoperator: 48
operands: 45
43Operationoperator: 46
operand: 51
44Operationoperator: 48
operands: 49
45ExprTuple51, 50
46Variable
47ExprTuple51
48Literal
49ExprTuple51, 52
50Operationoperator: 53
operands: 54
51Variable
52Operationoperator: 55
operands: 56
53Literal
54ExprTuple61, 58
55Literal
56ExprTuple57, 58
57Operationoperator: 59
operands: 60
58Variable
59Literal
60ExprTuple61, 62
61Variable
62Operationoperator: 63
operand: 65
63Literal
64ExprTuple65
65Literal