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 Lambda, P, Py, S, y, z
from proveit.logic import Equals, Forall, Implies, InSet, NotEquals
from proveit.numbers import Complex, Sum, frac, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y]
expr = Lambda([P, S], Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(Py, Complex), domain = S), Forall(instance_param_or_params = [z], instance_expr = 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)), domain = Complex, condition = 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())
\left(P, S\right) \mapsto \left(\left[\forall_{y \in S}~\left(P\left(y\right) \in \mathbb{C}\right)\right] \Rightarrow \left[\forall_{z \in \mathbb{C}~|~z \neq 0}~\left(\frac{\sum_{y \in S}~P\left(y\right)}{z} = \left[\sum_{y \in S}~\frac{P\left(y\right)}{z}\right]\right)\right]\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple49, 51
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 8
operand: 10
6Operationoperator: 8
operand: 11
7ExprTuple10
8Literal
9ExprTuple11
10Lambdaparameter: 52
body: 12
11Lambdaparameter: 46
body: 14
12Conditionalvalue: 15
condition: 44
13ExprTuple46
14Conditionalvalue: 16
condition: 17
15Operationoperator: 47
operands: 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18ExprTuple45, 34
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26
23Operationoperator: 42
operands: 27
24Operationoperator: 36
operand: 33
25Operationoperator: 47
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple32, 46
28ExprTuple33
29ExprTuple46, 34
30Literal
31ExprTuple46, 35
32Operationoperator: 36
operand: 39
33Lambdaparameter: 52
body: 38
34Literal
35Literal
36Literal
37ExprTuple39
38Conditionalvalue: 40
condition: 44
39Lambdaparameter: 52
body: 41
40Operationoperator: 42
operands: 43
41Conditionalvalue: 45
condition: 44
42Literal
43ExprTuple45, 46
44Operationoperator: 47
operands: 48
45Operationoperator: 49
operand: 52
46Variable
47Literal
48ExprTuple52, 51
49Variable
50ExprTuple52
51Variable
52Variable