logo

Expression of type Forall

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 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 Equals, Forall
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}")
expr = 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()
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple54, 56
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 22
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 45
body: 13
11ExprRangelambda_map: 14
start_index: 62
end_index: 58
12ExprRangelambda_map: 15
start_index: 62
end_index: 63
13Conditionalvalue: 16
condition: 17
14Lambdaparameter: 70
body: 18
15Lambdaparameter: 70
body: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Operationoperator: 39
operands: 24
19Operationoperator: 39
operands: 25
20Literal
21ExprTuple26, 27
22Literal
23ExprTuple28
24ExprTuple64, 29
25ExprTuple66, 29
26Operationoperator: 51
operands: 30
27Operationoperator: 36
operand: 34
28ExprRangelambda_map: 32
start_index: 62
end_index: 50
29Literal
30ExprTuple54, 33, 56
31ExprTuple34
32Lambdaparameter: 70
body: 35
33Operationoperator: 36
operand: 41
34Operationoperator: 44
operands: 38
35Operationoperator: 39
operands: 40
36Literal
37ExprTuple41
38ExprTuple42
39Literal
40ExprTuple53, 43
41Operationoperator: 44
operands: 45
42ExprRangelambda_map: 46
start_index: 62
end_index: 50
43Literal
44Literal
45ExprTuple47
46Lambdaparameter: 65
body: 48
47ExprRangelambda_map: 49
start_index: 62
end_index: 50
48Operationoperator: 51
operands: 52
49Lambdaparameter: 70
body: 53
50Variable
51Literal
52ExprTuple54, 55, 56
53IndexedVarvariable: 59
index: 70
54ExprRangelambda_map: 57
start_index: 62
end_index: 58
55IndexedVarvariable: 59
index: 65
56ExprRangelambda_map: 61
start_index: 62
end_index: 63
57Lambdaparameter: 70
body: 64
58Variable
59Variable
60ExprTuple65
61Lambdaparameter: 70
body: 66
62Literal
63Variable
64IndexedVarvariable: 67
index: 70
65Variable
66IndexedVarvariable: 68
index: 70
67Variable
68Variable
69ExprTuple70
70Variable