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, frac, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = 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\{\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()
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: 29
operands: 14
8Operationoperator: 27
operands: 15
9ExprRangelambda_map: 16
start_index: 42
end_index: 40
10Operationoperator: 32
operands: 17
11Operationoperator: 32
operands: 18
12ExprRangelambda_map: 19
start_index: 42
end_index: 43
13Operationoperator: 20
operands: 21
14ExprTuple35, 22, 37
15ExprTuple23, 34
16Lambdaparameter: 49
body: 24
17ExprTuple36, 38
18ExprTuple34, 38
19Lambdaparameter: 49
body: 25
20Literal
21ExprTuple34, 26
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operands: 30
24Operationoperator: 32
operands: 31
25Operationoperator: 32
operands: 33
26Literal
27Literal
28ExprTuple36, 34
29Literal
30ExprTuple35, 36, 37
31ExprTuple44, 38
32Literal
33ExprTuple45, 38
34Variable
35ExprRangelambda_map: 39
start_index: 42
end_index: 40
36Variable
37ExprRangelambda_map: 41
start_index: 42
end_index: 43
38Literal
39Lambdaparameter: 49
body: 44
40Variable
41Lambdaparameter: 49
body: 45
42Literal
43Variable
44IndexedVarvariable: 46
index: 49
45IndexedVarvariable: 47
index: 49
46Variable
47Variable
48ExprTuple49
49Variable