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, frac, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([w_1_to_m, x, y, z_1_to_n], Conditional(Equals(Mult(w_1_to_m, frac(x, y), z_1_to_n), frac(Mult(w_1_to_m, x, z_1_to_n), y)), And(ExprRange(sub_expr1, InSet(IndexedVar(w, sub_expr1), Complex), one, m), InSet(x, Complex), InSet(y, Complex), ExprRange(sub_expr1, InSet(IndexedVar(z, sub_expr1), Complex), one, n), NotEquals(y, 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(w_{1}, w_{2}, \ldots, w_{m}, x, y, z_{1}, z_{2}, \ldots, z_{n}\right) \mapsto \left\{\left(w_{1} \cdot  w_{2} \cdot  \ldots \cdot  w_{m} \cdot \frac{x}{y}\cdot z_{1} \cdot  z_{2} \cdot  \ldots \cdot  z_{n}\right) = \frac{w_{1} \cdot  w_{2} \cdot  \ldots \cdot  w_{m} \cdot x\cdot z_{1} \cdot  z_{2} \cdot  \ldots \cdot  z_{n}}{y} \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\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
1ExprTuple37, 38, 36, 39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14, 15
9Operationoperator: 31
operands: 16
10Operationoperator: 29
operands: 17
11ExprRangelambda_map: 18
start_index: 44
end_index: 42
12Operationoperator: 34
operands: 19
13Operationoperator: 34
operands: 20
14ExprRangelambda_map: 21
start_index: 44
end_index: 45
15Operationoperator: 22
operands: 23
16ExprTuple37, 24, 39
17ExprTuple25, 36
18Lambdaparameter: 51
body: 26
19ExprTuple38, 40
20ExprTuple36, 40
21Lambdaparameter: 51
body: 27
22Literal
23ExprTuple36, 28
24Operationoperator: 29
operands: 30
25Operationoperator: 31
operands: 32
26Operationoperator: 34
operands: 33
27Operationoperator: 34
operands: 35
28Literal
29Literal
30ExprTuple38, 36
31Literal
32ExprTuple37, 38, 39
33ExprTuple46, 40
34Literal
35ExprTuple47, 40
36Variable
37ExprRangelambda_map: 41
start_index: 44
end_index: 42
38Variable
39ExprRangelambda_map: 43
start_index: 44
end_index: 45
40Literal
41Lambdaparameter: 51
body: 46
42Variable
43Lambdaparameter: 51
body: 47
44Literal
45Variable
46IndexedVarvariable: 48
index: 51
47IndexedVarvariable: 49
index: 51
48Variable
49Variable
50ExprTuple51
51Variable