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, a, b, i, x
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Complex, Interval, Mult, Neg, Sum, one
In [2]:
# build up the expression from sub-expressions
expr = Lambda(x, Conditional(Equals(Sum(index_or_indices = [i], summand = x, domain = Interval(a, b)), Mult(Add(b, Neg(a), one), x)), InSet(x, Complex)))
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\{\left(\sum_{i = a}^{b} x\right) = \left(\left(b - a + 1\right) \cdot x\right) \textrm{ if } x \in \mathbb{C}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 21
body: 2
1ExprTuple21
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 25
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple21, 10
8Operationoperator: 11
operand: 15
9Operationoperator: 13
operands: 14
10Literal
11Literal
12ExprTuple15
13Literal
14ExprTuple16, 21
15Lambdaparameter: 29
body: 18
16Operationoperator: 19
operands: 20
17ExprTuple29
18Conditionalvalue: 21
condition: 22
19Literal
20ExprTuple34, 23, 24
21Variable
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operand: 33
24Literal
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple33
29Variable
30Operationoperator: 31
operands: 32
31Literal
32ExprTuple33, 34
33Variable
34Variable