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, f, g, k, l, m, n
from proveit.logic import Equals, Forall, Implies
from proveit.numbers import Integer, Interval, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = [l]
sub_expr3 = Interval(m, n)
expr = ExprTuple(Lambda([f, g], Forall(instance_param_or_params = [m, n], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(f, sub_expr1), Function(g, sub_expr1)), domain = sub_expr3), Equals(Sum(index_or_indices = sub_expr2, summand = Function(f, sub_expr2), domain = sub_expr3), Sum(index_or_indices = sub_expr2, summand = Function(g, sub_expr2), domain = sub_expr3))), 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(\left(f, g\right) \mapsto \left[\forall_{m, n \in \mathbb{Z}}~\left(\left[\forall_{k \in \{m~\ldotp \ldotp~n\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(\sum_{l = m}^{n} f\left(l\right)\right) = \left(\sum_{l = m}^{n} g\left(l\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
1Lambdaparameters: 2
body: 3
2ExprTuple45, 46
3Operationoperator: 17
operand: 5
4ExprTuple5
5Lambdaparameters: 54
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operands: 10
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13, 14
11Literal
12ExprTuple15, 16
13Operationoperator: 17
operand: 22
14Operationoperator: 34
operands: 19
15Operationoperator: 48
operands: 20
16Operationoperator: 48
operands: 21
17Literal
18ExprTuple22
19ExprTuple23, 24
20ExprTuple55, 25
21ExprTuple56, 25
22Lambdaparameter: 50
body: 26
23Operationoperator: 28
operand: 32
24Operationoperator: 28
operand: 33
25Literal
26Conditionalvalue: 30
condition: 31
27ExprTuple32
28Literal
29ExprTuple33
30Operationoperator: 34
operands: 35
31Operationoperator: 48
operands: 36
32Lambdaparameter: 51
body: 37
33Lambdaparameter: 51
body: 38
34Literal
35ExprTuple39, 40
36ExprTuple50, 52
37Conditionalvalue: 41
condition: 43
38Conditionalvalue: 42
condition: 43
39Operationoperator: 45
operand: 50
40Operationoperator: 46
operand: 50
41Operationoperator: 45
operand: 51
42Operationoperator: 46
operand: 51
43Operationoperator: 48
operands: 49
44ExprTuple50
45Variable
46Variable
47ExprTuple51
48Literal
49ExprTuple51, 52
50Variable
51Variable
52Operationoperator: 53
operands: 54
53Literal
54ExprTuple55, 56
55Variable
56Variable