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, v
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
from proveit.numbers import Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
expr = ExprTuple(Lambda(V, Conditional(Forall(instance_param_or_params = [v], instance_expr = Implies(InSet(vec_summation_b1toj_fQ, K), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(f__b_1_to_j, v), condition = Q__b_1_to_j), ScalarMult(Sum(index_or_indices = sub_expr1, summand = f__b_1_to_j, condition = Q__b_1_to_j), v)).with_wrapping_at(1)).with_wrapping_at(2), domain = V), 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_{v \in V}~\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 K\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(f\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot v\right)\right] \\  = \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] \cdot v\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: 23
body: 3
2ExprTuple23
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple23, 11
10Lambdaparameter: 45
body: 13
11Operationoperator: 14
operand: 29
12ExprTuple45
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple29
16Operationoperator: 18
operands: 19
17Operationoperator: 24
operands: 20
18Literal
19ExprTuple21, 22
20ExprTuple45, 23
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23Variable
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple30, 31
28Operationoperator: 32
operand: 41
29Variable
30Operationoperator: 32
operand: 35
31Operationoperator: 42
operands: 34
32Literal
33ExprTuple35
34ExprTuple36, 45
35Lambdaparameters: 50
body: 37
36Operationoperator: 38
operand: 41
37Conditionalvalue: 40
condition: 47
38Literal
39ExprTuple41
40Operationoperator: 42
operands: 43
41Lambdaparameters: 50
body: 44
42Literal
43ExprTuple46, 45
44Conditionalvalue: 46
condition: 47
45Variable
46Operationoperator: 48
operands: 50
47Operationoperator: 49
operands: 50
48Variable
49Variable
50ExprTuple51
51ExprRangelambda_map: 52
start_index: 53
end_index: 54
52Lambdaparameter: 58
body: 55
53Literal
54Variable
55IndexedVarvariable: 56
index: 58
56Variable
57ExprTuple58
58Variable