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 K, Q, V, 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.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [K, f, Q], 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(vec_summation_b1toj_fQ, V), Equals(ScalarMult(k, vec_summation_b1toj_fQ), VecSum(index_or_indices = [b_1_to_j], summand = ScalarMult(k, f__b_1_to_j), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2), 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}~\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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(k \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, 60, 59
4Operationoperator: 19
operand: 6
5ExprTuple6
6Lambdaparameter: 65
body: 8
7ExprTuple65
8Conditionalvalue: 9
condition: 10
9Operationoperator: 19
operand: 13
10Operationoperator: 37
operands: 12
11ExprTuple13
12ExprTuple65, 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: 57
body: 26
24Operationoperator: 27
operand: 36
25ExprTuple57
26Conditionalvalue: 29
condition: 30
27Literal
28ExprTuple36
29Operationoperator: 31
operands: 32
30Operationoperator: 37
operands: 33
31Literal
32ExprTuple34, 35
33ExprTuple57, 36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36Variable
37Literal
38ExprTuple46, 41
39Literal
40ExprTuple42, 43
41Variable
42Operationoperator: 54
operands: 44
43Operationoperator: 48
operand: 47
44ExprTuple57, 46
45ExprTuple47
46Operationoperator: 48
operand: 51
47Lambdaparameters: 61
body: 50
48Literal
49ExprTuple51
50Conditionalvalue: 52
condition: 56
51Lambdaparameters: 61
body: 53
52Operationoperator: 54
operands: 55
53Conditionalvalue: 58
condition: 56
54Literal
55ExprTuple57, 58
56Operationoperator: 59
operands: 61
57Variable
58Operationoperator: 60
operands: 61
59Variable
60Variable
61ExprTuple62
62ExprRangelambda_map: 63
start_index: 64
end_index: 65
63Lambdaparameter: 69
body: 66
64Literal
65Variable
66IndexedVarvariable: 67
index: 69
67Variable
68ExprTuple69
69Variable