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, 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(j, Conditional(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)), 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)}~\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] \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: 67
body: 3
2ExprTuple67
3Conditionalvalue: 4
condition: 5
4Operationoperator: 14
operand: 8
5Operationoperator: 32
operands: 7
6ExprTuple8
7ExprTuple67, 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: 59
body: 21
19Operationoperator: 22
operand: 31
20ExprTuple59
21Conditionalvalue: 24
condition: 25
22Literal
23ExprTuple31
24Operationoperator: 26
operands: 27
25Operationoperator: 32
operands: 28
26Literal
27ExprTuple29, 30
28ExprTuple59, 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31Variable
32Literal
33ExprTuple41, 36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 53
operands: 39
38Operationoperator: 43
operand: 42
39ExprTuple59, 41
40ExprTuple42
41Operationoperator: 43
operand: 46
42Lambdaparameters: 63
body: 45
43Literal
44ExprTuple46
45Conditionalvalue: 47
condition: 51
46Lambdaparameters: 63
body: 48
47Operationoperator: 53
operands: 49
48Conditionalvalue: 50
condition: 51
49ExprTuple52, 58
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operands: 63
52Operationoperator: 56
operands: 57
53Literal
54ExprTuple60, 58
55Variable
56Literal
57ExprTuple59, 60
58Operationoperator: 61
operands: 63
59Variable
60Operationoperator: 62
operands: 63
61Variable
62Variable
63ExprTuple64
64ExprRangelambda_map: 65
start_index: 66
end_index: 67
65Lambdaparameter: 71
body: 68
66Literal
67Variable
68IndexedVarvariable: 69
index: 71
69Variable
70ExprTuple71
71Variable