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, a, b, fb, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, Sum, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Conditional(Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, subtract(b, one))), fb)), And(InSet(a, Integer), InSet(b, Integer), Less(a, b)))
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) = \left(\left(\sum_{x = a}^{b - 1} f\left(x\right)\right) + f\left(b\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  a < b\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
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11
7Operationoperator: 22
operand: 17
8Operationoperator: 43
operands: 13
9Operationoperator: 35
operands: 14
10Operationoperator: 35
operands: 15
11Operationoperator: 16
operands: 32
12ExprTuple17
13ExprTuple18, 19
14ExprTuple41, 20
15ExprTuple45, 20
16Literal
17Lambdaparameter: 37
body: 21
18Operationoperator: 22
operand: 26
19Operationoperator: 33
operand: 45
20Literal
21Conditionalvalue: 30
condition: 25
22Literal
23ExprTuple26
24ExprTuple45
25Operationoperator: 35
operands: 27
26Lambdaparameter: 37
body: 28
27ExprTuple37, 29
28Conditionalvalue: 30
condition: 31
29Operationoperator: 39
operands: 32
30Operationoperator: 33
operand: 37
31Operationoperator: 35
operands: 36
32ExprTuple41, 45
33Variable
34ExprTuple37
35Literal
36ExprTuple37, 38
37Variable
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41Variable
42Operationoperator: 43
operands: 44
43Literal
44ExprTuple45, 46
45Variable
46Operationoperator: 47
operand: 49
47Literal
48ExprTuple49
49Literal