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, Q, V, c, f, 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 = [K, f, Q, c], instance_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_{K, f, Q, c}~\left[\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]\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: 19
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple36, 66, 60, 67
4Operationoperator: 19
operand: 6
5ExprTuple6
6Lambdaparameter: 72
body: 8
7ExprTuple72
8Conditionalvalue: 9
condition: 10
9Operationoperator: 19
operand: 13
10Operationoperator: 37
operands: 12
11ExprTuple13
12ExprTuple72, 14
13Lambdaparameter: 41
body: 16
14Literal
15ExprTuple41
16Conditionalvalue: 17
condition: 18
17Operationoperator: 19
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple41, 24
23Lambdaparameter: 64
body: 26
24Operationoperator: 27
operand: 36
25ExprTuple64
26Conditionalvalue: 29
condition: 30
27Literal
28ExprTuple36
29Operationoperator: 31
operands: 32
30Operationoperator: 37
operands: 33
31Literal
32ExprTuple34, 35
33ExprTuple64, 36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36Variable
37Literal
38ExprTuple46, 41
39Literal
40ExprTuple42, 43
41Variable
42Operationoperator: 58
operands: 44
43Operationoperator: 48
operand: 47
44ExprTuple64, 46
45ExprTuple47
46Operationoperator: 48
operand: 51
47Lambdaparameters: 68
body: 50
48Literal
49ExprTuple51
50Conditionalvalue: 52
condition: 56
51Lambdaparameters: 68
body: 53
52Operationoperator: 58
operands: 54
53Conditionalvalue: 55
condition: 56
54ExprTuple57, 63
55Operationoperator: 58
operands: 59
56Operationoperator: 60
operands: 68
57Operationoperator: 61
operands: 62
58Literal
59ExprTuple65, 63
60Variable
61Literal
62ExprTuple64, 65
63Operationoperator: 66
operands: 68
64Variable
65Operationoperator: 67
operands: 68
66Variable
67Variable
68ExprTuple69
69ExprRangelambda_map: 70
start_index: 71
end_index: 72
70Lambdaparameter: 76
body: 73
71Literal
72Variable
73IndexedVarvariable: 74
index: 76
74Variable
75ExprTuple76
76Variable