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 And, Equals, Forall
from proveit.numbers import Add, Integer, Interval, 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, condition = 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(f \mapsto \left[\forall_{a, b, c \in \mathbb{Z}~|~a \leq b \leq 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: 51
body: 3
2ExprTuple51
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple61, 66, 63
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 25
operands: 13
11Literal
12ExprTuple14, 15
13ExprTuple16, 17, 18, 19
14Operationoperator: 35
operand: 27
15Operationoperator: 64
operands: 21
16Operationoperator: 53
operands: 22
17Operationoperator: 53
operands: 23
18Operationoperator: 53
operands: 24
19Operationoperator: 25
operands: 26
20ExprTuple27
21ExprTuple28, 29
22ExprTuple61, 30
23ExprTuple66, 30
24ExprTuple63, 30
25Literal
26ExprTuple31, 32
27Lambdaparameter: 56
body: 33
28Operationoperator: 35
operand: 40
29Operationoperator: 35
operand: 41
30Literal
31Operationoperator: 37
operands: 58
32Operationoperator: 37
operands: 38
33Conditionalvalue: 47
condition: 39
34ExprTuple40
35Literal
36ExprTuple41
37Literal
38ExprTuple66, 63
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
47Operationoperator: 51
operand: 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