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