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 Conditional, ExprTuple, Function, Lambda, f, g, k, l, m, n
from proveit.logic import And, Equals, Forall, Implies, InSet
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([m, n], Conditional(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))), And(InSet(m, Integer), InSet(n, 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(m, n\right) \mapsto \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) \textrm{ if } m \in \mathbb{Z} ,  n \in \mathbb{Z}\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: 50
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 13
operand: 18
10Operationoperator: 30
operands: 15
11Operationoperator: 44
operands: 16
12Operationoperator: 44
operands: 17
13Literal
14ExprTuple18
15ExprTuple19, 20
16ExprTuple51, 21
17ExprTuple52, 21
18Lambdaparameter: 46
body: 22
19Operationoperator: 24
operand: 28
20Operationoperator: 24
operand: 29
21Literal
22Conditionalvalue: 26
condition: 27
23ExprTuple28
24Literal
25ExprTuple29
26Operationoperator: 30
operands: 31
27Operationoperator: 44
operands: 32
28Lambdaparameter: 47
body: 33
29Lambdaparameter: 47
body: 34
30Literal
31ExprTuple35, 36
32ExprTuple46, 48
33Conditionalvalue: 37
condition: 39
34Conditionalvalue: 38
condition: 39
35Operationoperator: 41
operand: 46
36Operationoperator: 42
operand: 46
37Operationoperator: 41
operand: 47
38Operationoperator: 42
operand: 47
39Operationoperator: 44
operands: 45
40ExprTuple46
41Variable
42Variable
43ExprTuple47
44Literal
45ExprTuple47, 48
46Variable
47Variable
48Operationoperator: 49
operands: 50
49Literal
50ExprTuple51, 52
51Variable
52Variable