logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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(\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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple52, 44, 53, 54
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14, 15, 16, 17, 18
10Operationoperator: 35
operands: 19
11Operationoperator: 48
operand: 29
12ExprRangelambda_map: 21
start_index: 58
end_index: 56
13Operationoperator: 38
operands: 22
14Operationoperator: 38
operands: 23
15ExprRangelambda_map: 24
start_index: 58
end_index: 59
16Operationoperator: 41
operands: 25
17ExprRangelambda_map: 26
start_index: 58
end_index: 56
18ExprRangelambda_map: 27
start_index: 58
end_index: 59
19ExprTuple44, 28
20ExprTuple29
21Lambdaparameter: 65
body: 30
22ExprTuple44, 46
23ExprTuple53, 46
24Lambdaparameter: 65
body: 31
25ExprTuple53, 47
26Lambdaparameter: 65
body: 32
27Lambdaparameter: 65
body: 33
28Operationoperator: 50
operands: 34
29Operationoperator: 35
operands: 36
30Operationoperator: 38
operands: 37
31Operationoperator: 38
operands: 39
32Operationoperator: 41
operands: 40
33Operationoperator: 41
operands: 42
34ExprTuple52, 43, 54
35Literal
36ExprTuple44, 45
37ExprTuple60, 46
38Literal
39ExprTuple61, 46
40ExprTuple60, 47
41Literal
42ExprTuple61, 47
43Operationoperator: 48
operand: 53
44Variable
45Operationoperator: 50
operands: 51
46Literal
47Literal
48Literal
49ExprTuple53
50Literal
51ExprTuple52, 53, 54
52ExprRangelambda_map: 55
start_index: 58
end_index: 56
53Variable
54ExprRangelambda_map: 57
start_index: 58
end_index: 59
55Lambdaparameter: 65
body: 60
56Variable
57Lambdaparameter: 65
body: 61
58Literal
59Variable
60IndexedVarvariable: 62
index: 65
61IndexedVarvariable: 63
index: 65
62Variable
63Variable
64ExprTuple65
65Variable