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, alpha, b, c, k
from proveit.core_expr_types import alpha_k
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Integer, Interval, LessEq, Sum, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
expr = Conditional(Forall(instance_param_or_params = [alpha], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(a, c)), Add(Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = alpha_k, 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\{\forall_{\alpha}~\left(\left(\sum_{k = a}^{c} \alpha_{k}\right) = \left(\left(\sum_{k = a}^{b} \alpha_{k}\right) + \left(\sum_{k = b + 1}^{c} \alpha_{k}\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
operand: 6
2Operationoperator: 16
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9, 10
6Lambdaparameter: 48
body: 12
7Operationoperator: 50
operands: 13
8Operationoperator: 50
operands: 14
9Operationoperator: 50
operands: 15
10Operationoperator: 16
operands: 17
11ExprTuple48
12Operationoperator: 18
operands: 19
13ExprTuple58, 20
14ExprTuple63, 20
15ExprTuple60, 20
16Literal
17ExprTuple21, 22
18Literal
19ExprTuple23, 24
20Literal
21Operationoperator: 25
operands: 55
22Operationoperator: 25
operands: 26
23Operationoperator: 34
operand: 29
24Operationoperator: 61
operands: 28
25Literal
26ExprTuple63, 60
27ExprTuple29
28ExprTuple30, 31
29Lambdaparameter: 53
body: 32
30Operationoperator: 34
operand: 37
31Operationoperator: 34
operand: 38
32Conditionalvalue: 44
condition: 36
33ExprTuple37
34Literal
35ExprTuple38
36Operationoperator: 50
operands: 39
37Lambdaparameter: 53
body: 40
38Lambdaparameter: 53
body: 41
39ExprTuple53, 42
40Conditionalvalue: 44
condition: 43
41Conditionalvalue: 44
condition: 45
42Operationoperator: 56
operands: 46
43Operationoperator: 50
operands: 47
44IndexedVarvariable: 48
index: 53
45Operationoperator: 50
operands: 51
46ExprTuple58, 60
47ExprTuple53, 52
48Variable
49ExprTuple53
50Literal
51ExprTuple53, 54
52Operationoperator: 56
operands: 55
53Variable
54Operationoperator: 56
operands: 57
55ExprTuple58, 63
56Literal
57ExprTuple59, 60
58Variable
59Operationoperator: 61
operands: 62
60Variable
61Literal
62ExprTuple63, 64
63Variable
64Literal