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, fa, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, 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], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Add(fa, Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(a, one), b)))), 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(f\left(a\right) + \left(\sum_{x = a + 1}^{b} 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: 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: 30
operand: 24
15Operationoperator: 50
operands: 20
16Operationoperator: 42
operands: 21
17Operationoperator: 42
operands: 22
18Operationoperator: 23
operands: 39
19ExprTuple24
20ExprTuple25, 26
21ExprTuple52, 27
22ExprTuple49, 27
23Literal
24Lambdaparameter: 44
body: 28
25Operationoperator: 40
operand: 52
26Operationoperator: 30
operand: 33
27Literal
28Conditionalvalue: 37
condition: 32
29ExprTuple52
30Literal
31ExprTuple33
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
39ExprTuple52, 49
40Variable
41ExprTuple44
42Literal
43ExprTuple44, 45
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Operationoperator: 50
operands: 51
49Variable
50Literal
51ExprTuple52, 53
52Variable
53Literal