logo

Expression of type Conditional

from the theory of proveit.linear_algebra.addition

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, i, va, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Less, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
expr = Conditional(Equals(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, b)), VecAdd(va, VecSum(index_or_indices = sub_expr1, summand = vi, 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_{i=a}^{b} v\left(i\right)\right) = \left(v\left(a\right) + \left(\sum_{i=a + 1}^{b} v\left(i\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: 24
operand: 18
8Operationoperator: 13
operands: 14
9Operationoperator: 36
operands: 15
10Operationoperator: 36
operands: 16
11Operationoperator: 17
operands: 33
12ExprTuple18
13Literal
14ExprTuple19, 20
15ExprTuple46, 21
16ExprTuple43, 21
17Literal
18Lambdaparameter: 38
body: 22
19Operationoperator: 34
operand: 46
20Operationoperator: 24
operand: 27
21Literal
22Conditionalvalue: 31
condition: 26
23ExprTuple46
24Literal
25ExprTuple27
26Operationoperator: 36
operands: 28
27Lambdaparameter: 38
body: 29
28ExprTuple38, 30
29Conditionalvalue: 31
condition: 32
30Operationoperator: 40
operands: 33
31Operationoperator: 34
operand: 38
32Operationoperator: 36
operands: 37
33ExprTuple46, 43
34Variable
35ExprTuple38
36Literal
37ExprTuple38, 39
38Variable
39Operationoperator: 40
operands: 41
40Literal
41ExprTuple42, 43
42Operationoperator: 44
operands: 45
43Variable
44Literal
45ExprTuple46, 47
46Variable
47Literal