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, c, i, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import And, Equals, InSet
from proveit.numbers import Integer, Interval, Less, LessEq, one, subtract
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, c)), VecAdd(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, subtract(b, one))), VecSum(index_or_indices = sub_expr1, summand = vi, 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_{i=a}^{c} v\left(i\right)\right) = \left(\left(\sum_{i=a}^{b - 1} v\left(i\right)\right) + \left(\sum_{i=b}^{c} v\left(i\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: 29
operand: 23
8Operationoperator: 15
operands: 16
9Operationoperator: 45
operands: 17
10Operationoperator: 45
operands: 18
11Operationoperator: 45
operands: 19
12Operationoperator: 20
operands: 21
13Operationoperator: 22
operands: 52
14ExprTuple23
15Literal
16ExprTuple24, 25
17ExprTuple53, 26
18ExprTuple58, 26
19ExprTuple55, 26
20Literal
21ExprTuple53, 58
22Literal
23Lambdaparameter: 48
body: 27
24Operationoperator: 29
operand: 32
25Operationoperator: 29
operand: 33
26Literal
27Conditionalvalue: 39
condition: 31
28ExprTuple32
29Literal
30ExprTuple33
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, 54
51Literal
52ExprTuple58, 55
53Variable
54Operationoperator: 56
operands: 57
55Variable
56Literal
57ExprTuple58, 59
58Variable
59Operationoperator: 60
operand: 62
60Literal
61ExprTuple62
62Literal