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, f, fb, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, Sum, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda(f, Forall(instance_param_or_params = [a, b], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, subtract(b, one))), fb)), domain = Integer, condition = 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(f \mapsto \left[\forall_{a, b \in \mathbb{Z}~|~a < b}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b - 1} f\left(x\right)\right) + f\left(b\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: 40
body: 3
2ExprTuple40
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 39
body: 7
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17, 18
14Operationoperator: 29
operand: 24
15Operationoperator: 50
operands: 20
16Operationoperator: 42
operands: 21
17Operationoperator: 42
operands: 22
18Operationoperator: 23
operands: 39
19ExprTuple24
20ExprTuple25, 26
21ExprTuple48, 27
22ExprTuple52, 27
23Literal
24Lambdaparameter: 44
body: 28
25Operationoperator: 29
operand: 33
26Operationoperator: 40
operand: 52
27Literal
28Conditionalvalue: 37
condition: 32
29Literal
30ExprTuple33
31ExprTuple52
32Operationoperator: 42
operands: 34
33Lambdaparameter: 44
body: 35
34ExprTuple44, 36
35Conditionalvalue: 37
condition: 38
36Operationoperator: 46
operands: 39
37Operationoperator: 40
operand: 44
38Operationoperator: 42
operands: 43
39ExprTuple48, 52
40Variable
41ExprTuple44
42Literal
43ExprTuple44, 45
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Variable
49Operationoperator: 50
operands: 51
50Literal
51ExprTuple52, 53
52Variable
53Operationoperator: 54
operand: 56
54Literal
55ExprTuple56
56Literal