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, Function, K, Lambda, V, c, 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, InClass, InSet
from proveit.numbers import Mult
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 = ExprTuple(Lambda(V, Conditional(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), 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)}~\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) \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: 51
body: 13
11Operationoperator: 14
operand: 23
12ExprTuple51
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple23
16Operationoperator: 18
operands: 19
17Operationoperator: 24
operands: 20
18Literal
19ExprTuple21, 22
20ExprTuple51, 23
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23Variable
24Literal
25ExprTuple33, 28
26Literal
27ExprTuple29, 30
28Variable
29Operationoperator: 45
operands: 31
30Operationoperator: 35
operand: 34
31ExprTuple51, 33
32ExprTuple34
33Operationoperator: 35
operand: 38
34Lambdaparameters: 55
body: 37
35Literal
36ExprTuple38
37Conditionalvalue: 39
condition: 43
38Lambdaparameters: 55
body: 40
39Operationoperator: 45
operands: 41
40Conditionalvalue: 42
condition: 43
41ExprTuple44, 50
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operands: 55
44Operationoperator: 48
operands: 49
45Literal
46ExprTuple52, 50
47Variable
48Literal
49ExprTuple51, 52
50Operationoperator: 53
operands: 55
51Variable
52Operationoperator: 54
operands: 55
53Variable
54Variable
55ExprTuple56
56ExprRangelambda_map: 57
start_index: 58
end_index: 59
57Lambdaparameter: 63
body: 60
58Literal
59Variable
60IndexedVarvariable: 61
index: 63
61Variable
62ExprTuple63
63Variable