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, n, x
from proveit.logic import And, Equals, InSet, NotEquals
from proveit.numbers import Add, Complex, Exp, Interval, Natural, Sum, frac, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([x, n], Conditional(Equals(Sum(index_or_indices = [i], summand = Exp(x, i), domain = Interval(zero, n)), frac(subtract(one, Exp(x, Add(n, one))), subtract(one, x))), And(InSet(x, Complex), InSet(n, Natural), NotEquals(x, one)))))
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(x, n\right) \mapsto \left\{\left(\sum_{i = 0}^{n} x^{i}\right) = \frac{1 - x^{n + 1}}{1 - x} \textrm{ if } x \in \mathbb{C} ,  n \in \mathbb{N} ,  x \neq 1\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
2ExprTuple50, 54
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10Operationoperator: 15
operand: 23
11Operationoperator: 17
operands: 18
12Operationoperator: 37
operands: 19
13Operationoperator: 37
operands: 20
14Operationoperator: 21
operands: 22
15Literal
16ExprTuple23
17Literal
18ExprTuple24, 25
19ExprTuple50, 26
20ExprTuple54, 27
21Literal
22ExprTuple50, 55
23Lambdaparameter: 42
body: 29
24Operationoperator: 52
operands: 30
25Operationoperator: 52
operands: 31
26Literal
27Literal
28ExprTuple42
29Conditionalvalue: 32
condition: 33
30ExprTuple55, 34
31ExprTuple55, 35
32Operationoperator: 47
operands: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 40
operand: 44
35Operationoperator: 40
operand: 50
36ExprTuple50, 42
37Literal
38ExprTuple42, 43
39ExprTuple44
40Literal
41ExprTuple50
42Variable
43Operationoperator: 45
operands: 46
44Operationoperator: 47
operands: 48
45Literal
46ExprTuple49, 54
47Literal
48ExprTuple50, 51
49Literal
50Variable
51Operationoperator: 52
operands: 53
52Literal
53ExprTuple54, 55
54Variable
55Literal