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