logo

Expression of type ExprTuple

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, ExprTuple, Lambda, 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 = ExprTuple(Lambda([a, b, c], 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(\left(a, b, c\right) \mapsto \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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple61, 66, 63
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 19
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11, 12, 13
9Lambdaparameter: 51
body: 15
10Operationoperator: 53
operands: 16
11Operationoperator: 53
operands: 17
12Operationoperator: 53
operands: 18
13Operationoperator: 19
operands: 20
14ExprTuple51
15Operationoperator: 21
operands: 22
16ExprTuple61, 23
17ExprTuple66, 23
18ExprTuple63, 23
19Literal
20ExprTuple24, 25
21Literal
22ExprTuple26, 27
23Literal
24Operationoperator: 28
operands: 58
25Operationoperator: 28
operands: 29
26Operationoperator: 37
operand: 32
27Operationoperator: 64
operands: 31
28Literal
29ExprTuple66, 63
30ExprTuple32
31ExprTuple33, 34
32Lambdaparameter: 56
body: 35
33Operationoperator: 37
operand: 40
34Operationoperator: 37
operand: 41
35Conditionalvalue: 47
condition: 39
36ExprTuple40
37Literal
38ExprTuple41
39Operationoperator: 53
operands: 42
40Lambdaparameter: 56
body: 43
41Lambdaparameter: 56
body: 44
42ExprTuple56, 45
43Conditionalvalue: 47
condition: 46
44Conditionalvalue: 47
condition: 48
45Operationoperator: 59
operands: 49
46Operationoperator: 53
operands: 50
47IndexedVarvariable: 51
index: 56
48Operationoperator: 53
operands: 54
49ExprTuple61, 63
50ExprTuple56, 55
51Variable
52ExprTuple56
53Literal
54ExprTuple56, 57
55Operationoperator: 59
operands: 58
56Variable
57Operationoperator: 59
operands: 60
58ExprTuple61, 66
59Literal
60ExprTuple62, 63
61Variable
62Operationoperator: 64
operands: 65
63Variable
64Literal
65ExprTuple66, 67
66Variable
67Literal