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, c, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, LessEq, 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, c)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, subtract(b, one))), Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(b, c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), Less(a, b), LessEq(b, c)))
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}^{c} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b - 1} f\left(x\right)\right) + \left(\sum_{x = b}^{c} f\left(x\right)\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  a < b ,  b \leq c\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, 12, 13
7Operationoperator: 28
operand: 22
8Operationoperator: 55
operands: 15
9Operationoperator: 44
operands: 16
10Operationoperator: 44
operands: 17
11Operationoperator: 44
operands: 18
12Operationoperator: 19
operands: 20
13Operationoperator: 21
operands: 51
14ExprTuple22
15ExprTuple23, 24
16ExprTuple52, 25
17ExprTuple57, 25
18ExprTuple54, 25
19Literal
20ExprTuple52, 57
21Literal
22Lambdaparameter: 47
body: 26
23Operationoperator: 28
operand: 31
24Operationoperator: 28
operand: 32
25Literal
26Conditionalvalue: 38
condition: 30
27ExprTuple31
28Literal
29ExprTuple32
30Operationoperator: 44
operands: 33
31Lambdaparameter: 47
body: 34
32Lambdaparameter: 47
body: 35
33ExprTuple47, 36
34Conditionalvalue: 38
condition: 37
35Conditionalvalue: 38
condition: 39
36Operationoperator: 50
operands: 40
37Operationoperator: 44
operands: 41
38Operationoperator: 42
operand: 47
39Operationoperator: 44
operands: 45
40ExprTuple52, 54
41ExprTuple47, 46
42Variable
43ExprTuple47
44Literal
45ExprTuple47, 48
46Operationoperator: 50
operands: 49
47Variable
48Operationoperator: 50
operands: 51
49ExprTuple52, 53
50Literal
51ExprTuple57, 54
52Variable
53Operationoperator: 55
operands: 56
54Variable
55Literal
56ExprTuple57, 58
57Variable
58Operationoperator: 59
operand: 61
59Literal
60ExprTuple61
61Literal