logo

Expression of type Conditional

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, 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 = 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\{\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()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11, 12, 13, 14, 15
7Operationoperator: 32
operands: 16
8Operationoperator: 45
operand: 26
9ExprRangelambda_map: 18
start_index: 55
end_index: 53
10Operationoperator: 35
operands: 19
11Operationoperator: 35
operands: 20
12ExprRangelambda_map: 21
start_index: 55
end_index: 56
13Operationoperator: 38
operands: 22
14ExprRangelambda_map: 23
start_index: 55
end_index: 53
15ExprRangelambda_map: 24
start_index: 55
end_index: 56
16ExprTuple41, 25
17ExprTuple26
18Lambdaparameter: 62
body: 27
19ExprTuple41, 43
20ExprTuple50, 43
21Lambdaparameter: 62
body: 28
22ExprTuple50, 44
23Lambdaparameter: 62
body: 29
24Lambdaparameter: 62
body: 30
25Operationoperator: 47
operands: 31
26Operationoperator: 32
operands: 33
27Operationoperator: 35
operands: 34
28Operationoperator: 35
operands: 36
29Operationoperator: 38
operands: 37
30Operationoperator: 38
operands: 39
31ExprTuple49, 40, 51
32Literal
33ExprTuple41, 42
34ExprTuple57, 43
35Literal
36ExprTuple58, 43
37ExprTuple57, 44
38Literal
39ExprTuple58, 44
40Operationoperator: 45
operand: 50
41Variable
42Operationoperator: 47
operands: 48
43Literal
44Literal
45Literal
46ExprTuple50
47Literal
48ExprTuple49, 50, 51
49ExprRangelambda_map: 52
start_index: 55
end_index: 53
50Variable
51ExprRangelambda_map: 54
start_index: 55
end_index: 56
52Lambdaparameter: 62
body: 57
53Variable
54Lambdaparameter: 62
body: 58
55Literal
56Variable
57IndexedVarvariable: 59
index: 62
58IndexedVarvariable: 60
index: 62
59Variable
60Variable
61ExprTuple62
62Variable