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, Function, K, Lambda, Q, V, c, 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.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Mult, NaturalPos
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([K, f, Q, c], 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(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), 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, c\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)}~\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)\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, 65, 59, 66
3Operationoperator: 18
operand: 5
4ExprTuple5
5Lambdaparameter: 71
body: 7
6ExprTuple71
7Conditionalvalue: 8
condition: 9
8Operationoperator: 18
operand: 12
9Operationoperator: 36
operands: 11
10ExprTuple12
11ExprTuple71, 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: 63
body: 25
23Operationoperator: 26
operand: 35
24ExprTuple63
25Conditionalvalue: 28
condition: 29
26Literal
27ExprTuple35
28Operationoperator: 30
operands: 31
29Operationoperator: 36
operands: 32
30Literal
31ExprTuple33, 34
32ExprTuple63, 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Variable
36Literal
37ExprTuple45, 40
38Literal
39ExprTuple41, 42
40Variable
41Operationoperator: 57
operands: 43
42Operationoperator: 47
operand: 46
43ExprTuple63, 45
44ExprTuple46
45Operationoperator: 47
operand: 50
46Lambdaparameters: 67
body: 49
47Literal
48ExprTuple50
49Conditionalvalue: 51
condition: 55
50Lambdaparameters: 67
body: 52
51Operationoperator: 57
operands: 53
52Conditionalvalue: 54
condition: 55
53ExprTuple56, 62
54Operationoperator: 57
operands: 58
55Operationoperator: 59
operands: 67
56Operationoperator: 60
operands: 61
57Literal
58ExprTuple64, 62
59Variable
60Literal
61ExprTuple63, 64
62Operationoperator: 65
operands: 67
63Variable
64Operationoperator: 66
operands: 67
65Variable
66Variable
67ExprTuple68
68ExprRangelambda_map: 69
start_index: 70
end_index: 71
69Lambdaparameter: 75
body: 72
70Literal
71Variable
72IndexedVarvariable: 73
index: 75
73Variable
74ExprTuple75
75Variable