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, 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 = ExprTuple(Lambda(j, Conditional(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)), InSet(j, 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())
\left(j \mapsto \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] \textrm{ if } j \in \mathbb{N}^+\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: 60
body: 3
2ExprTuple60
3Conditionalvalue: 4
condition: 5
4Operationoperator: 14
operand: 8
5Operationoperator: 32
operands: 7
6ExprTuple8
7ExprTuple60, 9
8Lambdaparameter: 36
body: 11
9Literal
10ExprTuple36
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 18
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18
16Literal
17ExprTuple36, 19
18Lambdaparameter: 52
body: 21
19Operationoperator: 22
operand: 31
20ExprTuple52
21Conditionalvalue: 24
condition: 25
22Literal
23ExprTuple31
24Operationoperator: 26
operands: 27
25Operationoperator: 32
operands: 28
26Literal
27ExprTuple29, 30
28ExprTuple52, 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31Variable
32Literal
33ExprTuple41, 36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 49
operands: 39
38Operationoperator: 43
operand: 42
39ExprTuple52, 41
40ExprTuple42
41Operationoperator: 43
operand: 46
42Lambdaparameters: 56
body: 45
43Literal
44ExprTuple46
45Conditionalvalue: 47
condition: 51
46Lambdaparameters: 56
body: 48
47Operationoperator: 49
operands: 50
48Conditionalvalue: 53
condition: 51
49Literal
50ExprTuple52, 53
51Operationoperator: 54
operands: 56
52Variable
53Operationoperator: 55
operands: 56
54Variable
55Variable
56ExprTuple57
57ExprRangelambda_map: 58
start_index: 59
end_index: 60
58Lambdaparameter: 64
body: 61
59Literal
60Variable
61IndexedVarvariable: 62
index: 64
62Variable
63ExprTuple64
64Variable