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 ExprTuple, Lambda, a, b, c, f, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, LessEq, Sum, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda(f, Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, c)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(b, one), c)))), domain = Integer, conditions = [LessEq(a, b), Less(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(f \mapsto \left[\forall_{a, b, c \in \mathbb{Z}~|~a \leq b, b < c}~\left(\left(\sum_{x = a}^{c} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b} f\left(x\right)\right) + \left(\sum_{x = b + 1}^{c} f\left(x\right)\right)\right)\right)\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
1Lambdaparameter: 50
body: 3
2ExprTuple50
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple60, 65, 62
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19, 20, 21
15Operationoperator: 36
operand: 30
16Operationoperator: 63
operands: 23
17Operationoperator: 52
operands: 24
18Operationoperator: 52
operands: 25
19Operationoperator: 52
operands: 26
20Operationoperator: 27
operands: 57
21Operationoperator: 28
operands: 29
22ExprTuple30
23ExprTuple31, 32
24ExprTuple60, 33
25ExprTuple65, 33
26ExprTuple62, 33
27Literal
28Literal
29ExprTuple65, 62
30Lambdaparameter: 55
body: 34
31Operationoperator: 36
operand: 39
32Operationoperator: 36
operand: 40
33Literal
34Conditionalvalue: 46
condition: 38
35ExprTuple39
36Literal
37ExprTuple40
38Operationoperator: 52
operands: 41
39Lambdaparameter: 55
body: 42
40Lambdaparameter: 55
body: 43
41ExprTuple55, 44
42Conditionalvalue: 46
condition: 45
43Conditionalvalue: 46
condition: 47
44Operationoperator: 58
operands: 48
45Operationoperator: 52
operands: 49
46Operationoperator: 50
operand: 55
47Operationoperator: 52
operands: 53
48ExprTuple60, 62
49ExprTuple55, 54
50Variable
51ExprTuple55
52Literal
53ExprTuple55, 56
54Operationoperator: 58
operands: 57
55Variable
56Operationoperator: 58
operands: 59
57ExprTuple60, 65
58Literal
59ExprTuple61, 62
60Variable
61Operationoperator: 63
operands: 64
62Variable
63Literal
64ExprTuple65, 66
65Variable
66Literal