logo

Expression of type Lambda

from the theory of proveit.numbers.division

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, Py, S, y, z
from proveit.logic import And, Equals, InSet, NotEquals
from proveit.numbers import Complex, Sum, frac, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y]
expr = Lambda(z, Conditional(Equals(frac(Sum(index_or_indices = sub_expr1, summand = Py, domain = S), z), Sum(index_or_indices = sub_expr1, summand = frac(Py, z), domain = S)), And(InSet(z, Complex), NotEquals(z, zero))))
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())
z \mapsto \left\{\frac{\sum_{y \in S}~P\left(y\right)}{z} = \left[\sum_{y \in S}~\frac{P\left(y\right)}{z}\right] \textrm{ if } z \in \mathbb{C} ,  z \neq 0\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 32
body: 2
1ExprTuple32
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 28
operands: 13
10Operationoperator: 22
operand: 19
11Operationoperator: 33
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple18, 32
14ExprTuple19
15ExprTuple32, 20
16Literal
17ExprTuple32, 21
18Operationoperator: 22
operand: 25
19Lambdaparameter: 38
body: 24
20Literal
21Literal
22Literal
23ExprTuple25
24Conditionalvalue: 26
condition: 30
25Lambdaparameter: 38
body: 27
26Operationoperator: 28
operands: 29
27Conditionalvalue: 31
condition: 30
28Literal
29ExprTuple31, 32
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operand: 38
32Variable
33Literal
34ExprTuple38, 37
35Variable
36ExprTuple38
37Variable
38Variable