logo

Expression of type Conditional

from the theory of proveit.numbers.multiplication

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, a, b, i, j, x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, Equals, InSet
from proveit.numbers import Complex, Mult, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Equals(Mult(a_1_to_i, subtract(x, y), b_1_to_j), subtract(Mult(a_1_to_i, x, b_1_to_j), Mult(a_1_to_i, y, b_1_to_j))).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), InSet(x, Complex), InSet(y, Complex), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j)))
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\{\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(x - y\right)\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot x\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) - \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot y\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\right) \end{array} \end{array} \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right) ,  x \in \mathbb{C} ,  y \in \mathbb{C}, \left(b_{1} \in \mathbb{C}\right) ,  \left(b_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(b_{j} \in \mathbb{C}\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
7Operationoperator: 37
operands: 13
8Operationoperator: 24
operands: 14
9ExprRangelambda_map: 15
start_index: 45
end_index: 43
10Operationoperator: 29
operands: 16
11Operationoperator: 29
operands: 17
12ExprRangelambda_map: 18
start_index: 45
end_index: 46
13ExprTuple39, 19, 41
14ExprTuple20, 21
15Lambdaparameter: 52
body: 22
16ExprTuple32, 34
17ExprTuple40, 34
18Lambdaparameter: 52
body: 23
19Operationoperator: 24
operands: 25
20Operationoperator: 37
operands: 26
21Operationoperator: 35
operand: 33
22Operationoperator: 29
operands: 28
23Operationoperator: 29
operands: 30
24Literal
25ExprTuple32, 31
26ExprTuple39, 32, 41
27ExprTuple33
28ExprTuple47, 34
29Literal
30ExprTuple48, 34
31Operationoperator: 35
operand: 40
32Variable
33Operationoperator: 37
operands: 38
34Literal
35Literal
36ExprTuple40
37Literal
38ExprTuple39, 40, 41
39ExprRangelambda_map: 42
start_index: 45
end_index: 43
40Variable
41ExprRangelambda_map: 44
start_index: 45
end_index: 46
42Lambdaparameter: 52
body: 47
43Variable
44Lambdaparameter: 52
body: 48
45Literal
46Variable
47IndexedVarvariable: 49
index: 52
48IndexedVarvariable: 50
index: 52
49Variable
50Variable
51ExprTuple52
52Variable