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 And, Equals, Forall, InSet
from proveit.numbers import Add, Complex, Integer, Interval, Mult, Neg, Sum, one
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b], Conditional(Forall(instance_param_or_params = [x], instance_expr = Equals(Sum(index_or_indices = [i], summand = x, domain = Interval(a, b)), Mult(Add(b, Neg(a), one), x)), domain = Complex), And(InSet(a, Integer), InSet(b, Integer))))
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(a, b\right) \mapsto \left\{\forall_{x \in \mathbb{C}}~\left(\left(\sum_{i = a}^{b} x\right) = \left(\left(b - a + 1\right) \cdot x\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 45
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 34
body: 12
9Operationoperator: 38
operands: 13
10Operationoperator: 38
operands: 14
11ExprTuple34
12Conditionalvalue: 15
condition: 16
13ExprTuple46, 17
14ExprTuple47, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 38
operands: 20
17Literal
18Literal
19ExprTuple21, 22
20ExprTuple34, 23
21Operationoperator: 24
operand: 28
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple29, 34
28Lambdaparameter: 42
body: 31
29Operationoperator: 32
operands: 33
30ExprTuple42
31Conditionalvalue: 34
condition: 35
32Literal
33ExprTuple47, 36, 37
34Variable
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operand: 46
37Literal
38Literal
39ExprTuple42, 43
40Literal
41ExprTuple46
42Variable
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Variable
47Variable