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, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Abs, Add, Complex, Mult, RealNonNeg, 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(Forall(instance_param_or_params = [b_1_to_j], instance_expr = 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), domain = Complex).with_wrapping(), And(ExprRange(sub_expr2, InSet(IndexedVar(a, sub_expr2), RealNonNeg), one, i), ExprRange(sub_expr2, InSet(IndexedVar(c, sub_expr2), RealNonNeg), one, k)))
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}{l}\forall_{b_{1}, b_{2}, \ldots, b_{j} \in \mathbb{C}}~\\
\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}\right)\end{array} \textrm{ if } \left(a_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(a_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}^{\ge 0}\right), \left(c_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(c_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(c_{k} \in \mathbb{R}^{\ge 0}\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
operand: 6
2Operationoperator: 18
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 41
body: 9
7ExprRangelambda_map: 10
start_index: 58
end_index: 54
8ExprRangelambda_map: 11
start_index: 58
end_index: 59
9Conditionalvalue: 12
condition: 13
10Lambdaparameter: 66
body: 14
11Lambdaparameter: 66
body: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Operationoperator: 35
operands: 20
15Operationoperator: 35
operands: 21
16Literal
17ExprTuple22, 23
18Literal
19ExprTuple24
20ExprTuple60, 25
21ExprTuple62, 25
22Operationoperator: 47
operands: 26
23Operationoperator: 32
operand: 30
24ExprRangelambda_map: 28
start_index: 58
end_index: 46
25Literal
26ExprTuple50, 29, 52
27ExprTuple30
28Lambdaparameter: 66
body: 31
29Operationoperator: 32
operand: 37
30Operationoperator: 40
operands: 34
31Operationoperator: 35
operands: 36
32Literal
33ExprTuple37
34ExprTuple38
35Literal
36ExprTuple49, 39
37Operationoperator: 40
operands: 41
38ExprRangelambda_map: 42
start_index: 58
end_index: 46
39Literal
40Literal
41ExprTuple43
42Lambdaparameter: 61
body: 44
43ExprRangelambda_map: 45
start_index: 58
end_index: 46
44Operationoperator: 47
operands: 48
45Lambdaparameter: 66
body: 49
46Variable
47Literal
48ExprTuple50, 51, 52
49IndexedVarvariable: 55
index: 66
50ExprRangelambda_map: 53
start_index: 58
end_index: 54
51IndexedVarvariable: 55
index: 61
52ExprRangelambda_map: 57
start_index: 58
end_index: 59
53Lambdaparameter: 66
body: 60
54Variable
55Variable
56ExprTuple61
57Lambdaparameter: 66
body: 62
58Literal
59Variable
60IndexedVarvariable: 63
index: 66
61Variable
62IndexedVarvariable: 64
index: 66
63Variable
64Variable
65ExprTuple66
66Variable