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}")
expr = Conditional(Equals(frac(Mult(w_1_to_m, Neg(x), z_1_to_n), y), Neg(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\{\frac{w_{1} \cdot  w_{2} \cdot  \ldots \cdot  w_{m} \cdot \left(-x\right)\cdot z_{1} \cdot  z_{2} \cdot  \ldots \cdot  z_{n}}{y} = \left(-\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}\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\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
7Operationoperator: 28
operands: 14
8Operationoperator: 37
operand: 23
9ExprRangelambda_map: 16
start_index: 47
end_index: 45
10Operationoperator: 31
operands: 17
11Operationoperator: 31
operands: 18
12ExprRangelambda_map: 19
start_index: 47
end_index: 48
13Operationoperator: 20
operands: 21
14ExprTuple22, 35
15ExprTuple23
16Lambdaparameter: 54
body: 24
17ExprTuple42, 36
18ExprTuple35, 36
19Lambdaparameter: 54
body: 25
20Literal
21ExprTuple35, 26
22Operationoperator: 39
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 31
operands: 30
25Operationoperator: 31
operands: 32
26Literal
27ExprTuple41, 33, 43
28Literal
29ExprTuple34, 35
30ExprTuple49, 36
31Literal
32ExprTuple50, 36
33Operationoperator: 37
operand: 42
34Operationoperator: 39
operands: 40
35Variable
36Literal
37Literal
38ExprTuple42
39Literal
40ExprTuple41, 42, 43
41ExprRangelambda_map: 44
start_index: 47
end_index: 45
42Variable
43ExprRangelambda_map: 46
start_index: 47
end_index: 48
44Lambdaparameter: 54
body: 49
45Variable
46Lambdaparameter: 54
body: 50
47Literal
48Variable
49IndexedVarvariable: 51
index: 54
50IndexedVarvariable: 52
index: 54
51Variable
52Variable
53ExprTuple54
54Variable