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, 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, Natural, RealNonNeg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = 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(), domain = RealNonNeg).with_wrapping(), And(InSet(i, Natural), InSet(j, Natural), InSet(k, Natural)))
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_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k} \in \mathbb{R}^{\ge 0}}~\\
\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}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \in \mathbb{N}\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: 17
operand: 5
2Operationoperator: 32
operands: 4
3ExprTuple5
4ExprTuple6, 7, 8
5Lambdaparameters: 9
body: 10
6Operationoperator: 49
operands: 11
7Operationoperator: 49
operands: 12
8Operationoperator: 49
operands: 13
9ExprTuple64, 66
10Conditionalvalue: 14
condition: 15
11ExprTuple68, 16
12ExprTuple60, 16
13ExprTuple73, 16
14Operationoperator: 17
operand: 20
15Operationoperator: 32
operands: 19
16Literal
17Literal
18ExprTuple20
19ExprTuple21, 22
20Lambdaparameters: 55
body: 23
21ExprRangelambda_map: 24
start_index: 72
end_index: 68
22ExprRangelambda_map: 25
start_index: 72
end_index: 73
23Conditionalvalue: 26
condition: 27
24Lambdaparameter: 80
body: 28
25Lambdaparameter: 80
body: 29
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28Operationoperator: 49
operands: 34
29Operationoperator: 49
operands: 35
30Literal
31ExprTuple36, 37
32Literal
33ExprTuple38
34ExprTuple74, 39
35ExprTuple76, 39
36Operationoperator: 61
operands: 40
37Operationoperator: 46
operand: 44
38ExprRangelambda_map: 42
start_index: 72
end_index: 60
39Literal
40ExprTuple64, 43, 66
41ExprTuple44
42Lambdaparameter: 80
body: 45
43Operationoperator: 46
operand: 51
44Operationoperator: 54
operands: 48
45Operationoperator: 49
operands: 50
46Literal
47ExprTuple51
48ExprTuple52
49Literal
50ExprTuple63, 53
51Operationoperator: 54
operands: 55
52ExprRangelambda_map: 56
start_index: 72
end_index: 60
53Literal
54Literal
55ExprTuple57
56Lambdaparameter: 75
body: 58
57ExprRangelambda_map: 59
start_index: 72
end_index: 60
58Operationoperator: 61
operands: 62
59Lambdaparameter: 80
body: 63
60Variable
61Literal
62ExprTuple64, 65, 66
63IndexedVarvariable: 69
index: 80
64ExprRangelambda_map: 67
start_index: 72
end_index: 68
65IndexedVarvariable: 69
index: 75
66ExprRangelambda_map: 71
start_index: 72
end_index: 73
67Lambdaparameter: 80
body: 74
68Variable
69Variable
70ExprTuple75
71Lambdaparameter: 80
body: 76
72Literal
73Variable
74IndexedVarvariable: 77
index: 80
75Variable
76IndexedVarvariable: 78
index: 80
77Variable
78Variable
79ExprTuple80
80Variable