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, fa, fx, x
from proveit.logic import And, InSet, SubsetEq
from proveit.numbers import Add, Integer, Integrate, Interval, IntervalCC, LessEq, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = IntervalCC(a, b)
expr = Conditional(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))), And(InSet(a, Integer), InSet(b, Integer), LessEq(a, b), SubsetEq(sub_expr2, S)))
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\{\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) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  a \leq b ,  \left[a,b\right] \subseteq S\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: 18
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9, 10, 11
6Operationoperator: 12
operand: 21
7Operationoperator: 14
operands: 15
8Operationoperator: 40
operands: 16
9Operationoperator: 40
operands: 17
10Operationoperator: 18
operands: 45
11Operationoperator: 19
operands: 20
12Literal
13ExprTuple21
14Literal
15ExprTuple22, 23
16ExprTuple46, 24
17ExprTuple47, 24
18Literal
19Literal
20ExprTuple43, 25
21Lambdaparameter: 42
body: 26
22Operationoperator: 38
operand: 46
23Operationoperator: 28
operand: 31
24Literal
25Variable
26Conditionalvalue: 35
condition: 30
27ExprTuple46
28Literal
29ExprTuple31
30Operationoperator: 40
operands: 32
31Lambdaparameter: 42
body: 33
32ExprTuple42, 34
33Conditionalvalue: 35
condition: 36
34Operationoperator: 37
operands: 45
35Operationoperator: 38
operand: 42
36Operationoperator: 40
operands: 41
37Literal
38Variable
39ExprTuple42
40Literal
41ExprTuple42, 43
42Variable
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Variable
47Variable