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, 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 Equals, Forall
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 = Forall(instance_param_or_params = [i, j, k], instance_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(), domain = 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())
\forall_{i, j, k \in \mathbb{N}}~\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}\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('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: 21
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple72, 64, 77
4Conditionalvalue: 5
condition: 6
5Operationoperator: 21
operand: 9
6Operationoperator: 36
operands: 8
7ExprTuple9
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 53
operands: 15
11Operationoperator: 53
operands: 16
12Operationoperator: 53
operands: 17
13ExprTuple68, 70
14Conditionalvalue: 18
condition: 19
15ExprTuple72, 20
16ExprTuple64, 20
17ExprTuple77, 20
18Operationoperator: 21
operand: 24
19Operationoperator: 36
operands: 23
20Literal
21Literal
22ExprTuple24
23ExprTuple25, 26
24Lambdaparameters: 59
body: 27
25ExprRangelambda_map: 28
start_index: 76
end_index: 72
26ExprRangelambda_map: 29
start_index: 76
end_index: 77
27Conditionalvalue: 30
condition: 31
28Lambdaparameter: 84
body: 32
29Lambdaparameter: 84
body: 33
30Operationoperator: 34
operands: 35
31Operationoperator: 36
operands: 37
32Operationoperator: 53
operands: 38
33Operationoperator: 53
operands: 39
34Literal
35ExprTuple40, 41
36Literal
37ExprTuple42
38ExprTuple78, 43
39ExprTuple80, 43
40Operationoperator: 65
operands: 44
41Operationoperator: 50
operand: 48
42ExprRangelambda_map: 46
start_index: 76
end_index: 64
43Literal
44ExprTuple68, 47, 70
45ExprTuple48
46Lambdaparameter: 84
body: 49
47Operationoperator: 50
operand: 55
48Operationoperator: 58
operands: 52
49Operationoperator: 53
operands: 54
50Literal
51ExprTuple55
52ExprTuple56
53Literal
54ExprTuple67, 57
55Operationoperator: 58
operands: 59
56ExprRangelambda_map: 60
start_index: 76
end_index: 64
57Literal
58Literal
59ExprTuple61
60Lambdaparameter: 79
body: 62
61ExprRangelambda_map: 63
start_index: 76
end_index: 64
62Operationoperator: 65
operands: 66
63Lambdaparameter: 84
body: 67
64Variable
65Literal
66ExprTuple68, 69, 70
67IndexedVarvariable: 73
index: 84
68ExprRangelambda_map: 71
start_index: 76
end_index: 72
69IndexedVarvariable: 73
index: 79
70ExprRangelambda_map: 75
start_index: 76
end_index: 77
71Lambdaparameter: 84
body: 78
72Variable
73Variable
74ExprTuple79
75Lambdaparameter: 84
body: 80
76Literal
77Variable
78IndexedVarvariable: 81
index: 84
79Variable
80IndexedVarvariable: 82
index: 84
81Variable
82Variable
83ExprTuple84
84Variable