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, c, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import And, Equals, InSet
from proveit.numbers import Complex, Mult, Neg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Equals(Neg(Mult(a_1_to_i, Neg(b), c_1_to_j)), Mult(a_1_to_i, b, c_1_to_j)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), InSet(b, Complex), ExprRange(sub_expr1, InSet(IndexedVar(c, 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\{\left(-\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(-b\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{j}\right)\right) = \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{j}\right) \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right) ,  b \in \mathbb{C}, \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{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
7Operationoperator: 31
operand: 17
8Operationoperator: 20
operands: 13
9ExprRangelambda_map: 14
start_index: 34
end_index: 30
10Operationoperator: 23
operands: 15
11ExprRangelambda_map: 16
start_index: 34
end_index: 35
12ExprTuple17
13ExprTuple25, 37, 27
14Lambdaparameter: 42
body: 18
15ExprTuple37, 28
16Lambdaparameter: 42
body: 19
17Operationoperator: 20
operands: 21
18Operationoperator: 23
operands: 22
19Operationoperator: 23
operands: 24
20Literal
21ExprTuple25, 26, 27
22ExprTuple36, 28
23Literal
24ExprTuple38, 28
25ExprRangelambda_map: 29
start_index: 34
end_index: 30
26Operationoperator: 31
operand: 37
27ExprRangelambda_map: 33
start_index: 34
end_index: 35
28Literal
29Lambdaparameter: 42
body: 36
30Variable
31Literal
32ExprTuple37
33Lambdaparameter: 42
body: 38
34Literal
35Variable
36IndexedVarvariable: 39
index: 42
37Variable
38IndexedVarvariable: 40
index: 42
39Variable
40Variable
41ExprTuple42
42Variable