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, LessEq, Sum, one
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, b)), Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(b, one), c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), And(LessEq(a, b), LessEq(b, c)).with_total_ordering_style()))
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} f\left(x\right)\right) + \left(\sum_{x = b + 1}^{c} f\left(x\right)\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  a \leq 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: 17
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple8, 9, 10, 11
6Operationoperator: 27
operand: 19
7Operationoperator: 56
operands: 13
8Operationoperator: 45
operands: 14
9Operationoperator: 45
operands: 15
10Operationoperator: 45
operands: 16
11Operationoperator: 17
operands: 18
12ExprTuple19
13ExprTuple20, 21
14ExprTuple53, 22
15ExprTuple58, 22
16ExprTuple55, 22
17Literal
18ExprTuple23, 24
19Lambdaparameter: 48
body: 25
20Operationoperator: 27
operand: 32
21Operationoperator: 27
operand: 33
22Literal
23Operationoperator: 29
operands: 50
24Operationoperator: 29
operands: 30
25Conditionalvalue: 39
condition: 31
26ExprTuple32
27Literal
28ExprTuple33
29Literal
30ExprTuple58, 55
31Operationoperator: 45
operands: 34
32Lambdaparameter: 48
body: 35
33Lambdaparameter: 48
body: 36
34ExprTuple48, 37
35Conditionalvalue: 39
condition: 38
36Conditionalvalue: 39
condition: 40
37Operationoperator: 51
operands: 41
38Operationoperator: 45
operands: 42
39Operationoperator: 43
operand: 48
40Operationoperator: 45
operands: 46
41ExprTuple53, 55
42ExprTuple48, 47
43Variable
44ExprTuple48
45Literal
46ExprTuple48, 49
47Operationoperator: 51
operands: 50
48Variable
49Operationoperator: 51
operands: 52
50ExprTuple53, 58
51Literal
52ExprTuple54, 55
53Variable
54Operationoperator: 56
operands: 57
55Variable
56Literal
57ExprTuple58, 59
58Variable
59Literal