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 ExprTuple, K, Lambda, 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 = ExprTuple(Lambda([K, f, Q], 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())
\left(\left(K, f, Q\right) \mapsto \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]\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple35, 59, 58
3Operationoperator: 18
operand: 5
4ExprTuple5
5Lambdaparameter: 64
body: 7
6ExprTuple64
7Conditionalvalue: 8
condition: 9
8Operationoperator: 18
operand: 12
9Operationoperator: 36
operands: 11
10ExprTuple12
11ExprTuple64, 13
12Lambdaparameter: 40
body: 15
13Literal
14ExprTuple40
15Conditionalvalue: 16
condition: 17
16Operationoperator: 18
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple40, 23
22Lambdaparameter: 56
body: 25
23Operationoperator: 26
operand: 35
24ExprTuple56
25Conditionalvalue: 28
condition: 29
26Literal
27ExprTuple35
28Operationoperator: 30
operands: 31
29Operationoperator: 36
operands: 32
30Literal
31ExprTuple33, 34
32ExprTuple56, 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Variable
36Literal
37ExprTuple45, 40
38Literal
39ExprTuple41, 42
40Variable
41Operationoperator: 53
operands: 43
42Operationoperator: 47
operand: 46
43ExprTuple56, 45
44ExprTuple46
45Operationoperator: 47
operand: 50
46Lambdaparameters: 60
body: 49
47Literal
48ExprTuple50
49Conditionalvalue: 51
condition: 55
50Lambdaparameters: 60
body: 52
51Operationoperator: 53
operands: 54
52Conditionalvalue: 57
condition: 55
53Literal
54ExprTuple56, 57
55Operationoperator: 58
operands: 60
56Variable
57Operationoperator: 59
operands: 60
58Variable
59Variable
60ExprTuple61
61ExprRangelambda_map: 62
start_index: 63
end_index: 64
62Lambdaparameter: 68
body: 65
63Literal
64Variable
65IndexedVarvariable: 66
index: 68
66Variable
67ExprTuple68
68Variable