logo

Expression of type ExprTuple

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 Conditional, ExprTuple, K, Lambda, V, 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, InClass, InSet
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(V, Conditional(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), InClass(V, VecSpaces(K)))))
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())
\left(V \mapsto \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) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 28
body: 3
2ExprTuple28
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple28, 11
10Lambdaparameter: 44
body: 13
11Operationoperator: 14
operand: 23
12ExprTuple44
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple23
16Operationoperator: 18
operands: 19
17Operationoperator: 24
operands: 20
18Literal
19ExprTuple21, 22
20ExprTuple44, 23
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23Variable
24Literal
25ExprTuple33, 28
26Literal
27ExprTuple29, 30
28Variable
29Operationoperator: 41
operands: 31
30Operationoperator: 35
operand: 34
31ExprTuple44, 33
32ExprTuple34
33Operationoperator: 35
operand: 38
34Lambdaparameters: 48
body: 37
35Literal
36ExprTuple38
37Conditionalvalue: 39
condition: 43
38Lambdaparameters: 48
body: 40
39Operationoperator: 41
operands: 42
40Conditionalvalue: 45
condition: 43
41Literal
42ExprTuple44, 45
43Operationoperator: 46
operands: 48
44Variable
45Operationoperator: 47
operands: 48
46Variable
47Variable
48ExprTuple49
49ExprRangelambda_map: 50
start_index: 51
end_index: 52
50Lambdaparameter: 56
body: 53
51Literal
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable