logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple49, 53
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Operationoperator: 14
operand: 22
10Operationoperator: 16
operands: 17
11Operationoperator: 36
operands: 18
12Operationoperator: 36
operands: 19
13Operationoperator: 20
operands: 21
14Literal
15ExprTuple22
16Literal
17ExprTuple23, 24
18ExprTuple49, 25
19ExprTuple53, 26
20Literal
21ExprTuple49, 54
22Lambdaparameter: 41
body: 28
23Operationoperator: 51
operands: 29
24Operationoperator: 51
operands: 30
25Literal
26Literal
27ExprTuple41
28Conditionalvalue: 31
condition: 32
29ExprTuple54, 33
30ExprTuple54, 34
31Operationoperator: 46
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 39
operand: 43
34Operationoperator: 39
operand: 49
35ExprTuple49, 41
36Literal
37ExprTuple41, 42
38ExprTuple43
39Literal
40ExprTuple49
41Variable
42Operationoperator: 44
operands: 45
43Operationoperator: 46
operands: 47
44Literal
45ExprTuple48, 53
46Literal
47ExprTuple49, 50
48Literal
49Variable
50Operationoperator: 51
operands: 52
51Literal
52ExprTuple53, 54
53Variable
54Literal