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