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, Function, Lambda, a, b, c, f, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Sum, subtract
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, b)), Sum(index_or_indices = sub_expr1, summand = Function(f, [subtract(x, c)]), domain = Interval(Add(a, c), Add(b, c)))), domain = Integer)))
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}}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\sum_{x = a + c}^{b + c} f\left(x - c\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: 37
body: 3
2ExprTuple37
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple57, 58, 59
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19
15Operationoperator: 21
operand: 26
16Operationoperator: 21
operand: 27
17Operationoperator: 39
operands: 23
18Operationoperator: 39
operands: 24
19Operationoperator: 39
operands: 25
20ExprTuple26
21Literal
22ExprTuple27
23ExprTuple57, 28
24ExprTuple58, 28
25ExprTuple59, 28
26Lambdaparameter: 48
body: 29
27Lambdaparameter: 48
body: 30
28Literal
29Conditionalvalue: 31
condition: 32
30Conditionalvalue: 33
condition: 34
31Operationoperator: 37
operand: 48
32Operationoperator: 39
operands: 36
33Operationoperator: 37
operand: 42
34Operationoperator: 39
operands: 40
35ExprTuple48
36ExprTuple48, 41
37Variable
38ExprTuple42
39Literal
40ExprTuple48, 43
41Operationoperator: 46
operands: 44
42Operationoperator: 55
operands: 45
43Operationoperator: 46
operands: 47
44ExprTuple57, 58
45ExprTuple48, 49
46Literal
47ExprTuple50, 51
48Variable
49Operationoperator: 52
operand: 59
50Operationoperator: 55
operands: 54
51Operationoperator: 55
operands: 56
52Literal
53ExprTuple59
54ExprTuple57, 59
55Literal
56ExprTuple58, 59
57Variable
58Variable
59Variable