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, fa, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, 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, b)), Add(fa, Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(a, one), b)))), 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(f\left(a\right) + \left(\sum_{x = a + 1}^{b} f\left(x\right)\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: 23
operand: 17
8Operationoperator: 43
operands: 13
9Operationoperator: 35
operands: 14
10Operationoperator: 35
operands: 15
11Operationoperator: 16
operands: 32
12ExprTuple17
13ExprTuple18, 19
14ExprTuple45, 20
15ExprTuple42, 20
16Literal
17Lambdaparameter: 37
body: 21
18Operationoperator: 33
operand: 45
19Operationoperator: 23
operand: 26
20Literal
21Conditionalvalue: 30
condition: 25
22ExprTuple45
23Literal
24ExprTuple26
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
32ExprTuple45, 42
33Variable
34ExprTuple37
35Literal
36ExprTuple37, 38
37Variable
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41Operationoperator: 43
operands: 44
42Variable
43Literal
44ExprTuple45, 46
45Variable
46Literal