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, ExprRange, IndexedVar, Lambda, Variable, m, n, w, x, y, z
from proveit.core_expr_types import w_1_to_m, z_1_to_n
from proveit.logic import And, Equals, InSet, NotEquals
from proveit.numbers import Complex, Mult, Neg, frac, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(w, sub_expr1)
sub_expr3 = IndexedVar(z, sub_expr1)
expr = Lambda([w_1_to_m, x, y, z_1_to_n], Conditional(Equals(frac(x, Mult(w_1_to_m, Neg(y), z_1_to_n)), Neg(frac(x, Mult(w_1_to_m, y, z_1_to_n)))), And(ExprRange(sub_expr1, InSet(sub_expr2, Complex), one, m), InSet(x, Complex), InSet(y, Complex), ExprRange(sub_expr1, InSet(sub_expr3, Complex), one, n), NotEquals(y, zero), ExprRange(sub_expr1, NotEquals(sub_expr2, zero), one, m), ExprRange(sub_expr1, NotEquals(sub_expr3, zero), one, n))))
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(w_{1}, w_{2}, \ldots, w_{m}, x, y, z_{1}, z_{2}, \ldots, z_{n}\right) \mapsto \left\{\frac{x}{w_{1} \cdot  w_{2} \cdot  \ldots \cdot  w_{m} \cdot \left(-y\right)\cdot z_{1} \cdot  z_{2} \cdot  \ldots \cdot  z_{n}} = \left(-\frac{x}{w_{1} \cdot  w_{2} \cdot  \ldots \cdot  w_{m} \cdot y\cdot z_{1} \cdot  z_{2} \cdot  \ldots \cdot  z_{n}}\right) \textrm{ if } \left(w_{1} \in \mathbb{C}\right) ,  \left(w_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(w_{m} \in \mathbb{C}\right) ,  x \in \mathbb{C} ,  y \in \mathbb{C}, \left(z_{1} \in \mathbb{C}\right) ,  \left(z_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(z_{n} \in \mathbb{C}\right) ,  y \neq 0, \left(w_{1} \neq 0\right) ,  \left(w_{2} \neq 0\right) ,  \ldots ,  \left(w_{m} \neq 0\right), \left(z_{1} \neq 0\right) ,  \left(z_{2} \neq 0\right) ,  \ldots ,  \left(z_{n} \neq 0\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
1ExprTuple51, 43, 52, 53
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14, 15, 16, 17
9Operationoperator: 34
operands: 18
10Operationoperator: 47
operand: 28
11ExprRangelambda_map: 20
start_index: 57
end_index: 55
12Operationoperator: 37
operands: 21
13Operationoperator: 37
operands: 22
14ExprRangelambda_map: 23
start_index: 57
end_index: 58
15Operationoperator: 40
operands: 24
16ExprRangelambda_map: 25
start_index: 57
end_index: 55
17ExprRangelambda_map: 26
start_index: 57
end_index: 58
18ExprTuple43, 27
19ExprTuple28
20Lambdaparameter: 64
body: 29
21ExprTuple43, 45
22ExprTuple52, 45
23Lambdaparameter: 64
body: 30
24ExprTuple52, 46
25Lambdaparameter: 64
body: 31
26Lambdaparameter: 64
body: 32
27Operationoperator: 49
operands: 33
28Operationoperator: 34
operands: 35
29Operationoperator: 37
operands: 36
30Operationoperator: 37
operands: 38
31Operationoperator: 40
operands: 39
32Operationoperator: 40
operands: 41
33ExprTuple51, 42, 53
34Literal
35ExprTuple43, 44
36ExprTuple59, 45
37Literal
38ExprTuple60, 45
39ExprTuple59, 46
40Literal
41ExprTuple60, 46
42Operationoperator: 47
operand: 52
43Variable
44Operationoperator: 49
operands: 50
45Literal
46Literal
47Literal
48ExprTuple52
49Literal
50ExprTuple51, 52, 53
51ExprRangelambda_map: 54
start_index: 57
end_index: 55
52Variable
53ExprRangelambda_map: 56
start_index: 57
end_index: 58
54Lambdaparameter: 64
body: 59
55Variable
56Lambdaparameter: 64
body: 60
57Literal
58Variable
59IndexedVarvariable: 61
index: 64
60IndexedVarvariable: 62
index: 64
61Variable
62Variable
63ExprTuple64
64Variable