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, Forall, InSet, NotEquals
from proveit.numbers import Add, Complex, Exp, Integer, Interval, LessEq, Sum, frac, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda(x, Conditional(Forall(instance_param_or_params = [j, k], instance_expr = 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))), domain = Integer, condition = LessEq(j, k)), And(InSet(x, Complex), 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())
x \mapsto \left\{\forall_{j, k \in \mathbb{Z}~|~j \leq k}~\left(\left(\sum_{i = j}^{k} x^{i}\right) = \frac{x^{j} - x^{k + 1}}{1 - x}\right) \textrm{ if } x \in \mathbb{C} ,  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
0Lambdaparameter: 61
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 19
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 57
body: 10
8Operationoperator: 47
operands: 11
9Operationoperator: 12
operands: 13
10Conditionalvalue: 14
condition: 15
11ExprTuple61, 16
12Literal
13ExprTuple61, 66
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Literal
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24, 25
21Operationoperator: 26
operand: 33
22Operationoperator: 28
operands: 29
23Operationoperator: 47
operands: 30
24Operationoperator: 47
operands: 31
25Operationoperator: 32
operands: 57
26Literal
27ExprTuple33
28Literal
29ExprTuple34, 35
30ExprTuple60, 36
31ExprTuple65, 36
32Literal
33Lambdaparameter: 53
body: 38
34Operationoperator: 63
operands: 39
35Operationoperator: 63
operands: 40
36Literal
37ExprTuple53
38Conditionalvalue: 41
condition: 42
39ExprTuple43, 44
40ExprTuple66, 45
41Operationoperator: 58
operands: 46
42Operationoperator: 47
operands: 48
43Operationoperator: 58
operands: 49
44Operationoperator: 51
operand: 55
45Operationoperator: 51
operand: 61
46ExprTuple61, 53
47Literal
48ExprTuple53, 54
49ExprTuple61, 60
50ExprTuple55
51Literal
52ExprTuple61
53Variable
54Operationoperator: 56
operands: 57
55Operationoperator: 58
operands: 59
56Literal
57ExprTuple60, 65
58Literal
59ExprTuple61, 62
60Variable
61Variable
62Operationoperator: 63
operands: 64
63Literal
64ExprTuple65, 66
65Variable
66Literal