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, Lambda, i, j, k, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Exp, Integer, Interval, LessEq, Sum, frac, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([j, k], Conditional(Equals(Sum(index_or_indices = [i], summand = Exp(x, i), domain = Interval(j, k)), frac(subtract(Exp(x, j), Exp(x, Add(k, one))), subtract(one, x))), And(InSet(j, Integer), InSet(k, Integer), LessEq(j, k)))))
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(j, k\right) \mapsto \left\{\left(\sum_{i = j}^{k} x^{i}\right) = \frac{x^{j} - x^{k + 1}}{1 - x} \textrm{ if } j \in \mathbb{Z} ,  k \in \mathbb{Z} ,  j \leq k\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: 45
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Operationoperator: 14
operand: 21
10Operationoperator: 16
operands: 17
11Operationoperator: 35
operands: 18
12Operationoperator: 35
operands: 19
13Operationoperator: 20
operands: 45
14Literal
15ExprTuple21
16Literal
17ExprTuple22, 23
18ExprTuple48, 24
19ExprTuple53, 24
20Literal
21Lambdaparameter: 41
body: 26
22Operationoperator: 51
operands: 27
23Operationoperator: 51
operands: 28
24Literal
25ExprTuple41
26Conditionalvalue: 29
condition: 30
27ExprTuple31, 32
28ExprTuple54, 33
29Operationoperator: 46
operands: 34
30Operationoperator: 35
operands: 36
31Operationoperator: 46
operands: 37
32Operationoperator: 39
operand: 43
33Operationoperator: 39
operand: 49
34ExprTuple49, 41
35Literal
36ExprTuple41, 42
37ExprTuple49, 48
38ExprTuple43
39Literal
40ExprTuple49
41Variable
42Operationoperator: 44
operands: 45
43Operationoperator: 46
operands: 47
44Literal
45ExprTuple48, 53
46Literal
47ExprTuple49, 50
48Variable
49Variable
50Operationoperator: 51
operands: 52
51Literal
52ExprTuple53, 54
53Variable
54Literal