logo

Expression of type Forall

from the theory of proveit.linear_algebra.scalar_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 Function, K, V, c, j, k
from proveit.core_expr_types import Q__b_1_to_j, b_1_to_j, f__b_1_to_j
from proveit.linear_algebra import ScalarMult, VecSpaces, VecSum
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Mult, NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = Function(c, sub_expr1)
sub_expr3 = VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, f__b_1_to_j), condition = Q__b_1_to_j)
expr = Forall(instance_param_or_params = [j], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [k], instance_expr = Implies(InSet(sub_expr3, V), Equals(ScalarMult(k, sub_expr3), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(k, sub_expr2), f__b_1_to_j), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(1), domain = K), domain = VecSpaces(K)), domain = NaturalPos)
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_{j \in \mathbb{N}^+}~\left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{k \in K}~\left(\begin{array}{c} \begin{array}{l} \left(\left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(c\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right] \in V\right) \\  \Rightarrow \left(\begin{array}{c} \begin{array}{l} \left(k \cdot \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(c\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right]\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(\left(k \cdot c\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right)\right]\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: 15
operand: 2
1ExprTuple2
2Lambdaparameter: 68
body: 4
3ExprTuple68
4Conditionalvalue: 5
condition: 6
5Operationoperator: 15
operand: 9
6Operationoperator: 33
operands: 8
7ExprTuple9
8ExprTuple68, 10
9Lambdaparameter: 37
body: 12
10Literal
11ExprTuple37
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operand: 19
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19
17Literal
18ExprTuple37, 20
19Lambdaparameter: 60
body: 22
20Operationoperator: 23
operand: 32
21ExprTuple60
22Conditionalvalue: 25
condition: 26
23Literal
24ExprTuple32
25Operationoperator: 27
operands: 28
26Operationoperator: 33
operands: 29
27Literal
28ExprTuple30, 31
29ExprTuple60, 32
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Variable
33Literal
34ExprTuple42, 37
35Literal
36ExprTuple38, 39
37Variable
38Operationoperator: 54
operands: 40
39Operationoperator: 44
operand: 43
40ExprTuple60, 42
41ExprTuple43
42Operationoperator: 44
operand: 47
43Lambdaparameters: 64
body: 46
44Literal
45ExprTuple47
46Conditionalvalue: 48
condition: 52
47Lambdaparameters: 64
body: 49
48Operationoperator: 54
operands: 50
49Conditionalvalue: 51
condition: 52
50ExprTuple53, 59
51Operationoperator: 54
operands: 55
52Operationoperator: 56
operands: 64
53Operationoperator: 57
operands: 58
54Literal
55ExprTuple61, 59
56Variable
57Literal
58ExprTuple60, 61
59Operationoperator: 62
operands: 64
60Variable
61Operationoperator: 63
operands: 64
62Variable
63Variable
64ExprTuple65
65ExprRangelambda_map: 66
start_index: 67
end_index: 68
66Lambdaparameter: 72
body: 69
67Literal
68Variable
69IndexedVarvariable: 70
index: 72
70Variable
71ExprTuple72
72Variable