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(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(k, sub_expr2), f__b_1_to_j), condition = Q__b_1_to_j), ScalarMult(k, sub_expr3)).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[\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] \\  = \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) \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: 58
body: 21
19Operationoperator: 22
operand: 31
20ExprTuple58
21Conditionalvalue: 24
condition: 25
22Literal
23ExprTuple31
24Operationoperator: 26
operands: 27
25Operationoperator: 32
operands: 28
26Literal
27ExprTuple29, 30
28ExprTuple58, 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31Variable
32Literal
33ExprTuple42, 36
34Literal
35ExprTuple37, 38
36Variable
37Operationoperator: 44
operand: 41
38Operationoperator: 55
operands: 40
39ExprTuple41
40ExprTuple58, 42
41Lambdaparameters: 63
body: 43
42Operationoperator: 44
operand: 47
43Conditionalvalue: 46
condition: 52
44Literal
45ExprTuple47
46Operationoperator: 55
operands: 48
47Lambdaparameters: 63
body: 49
48ExprTuple50, 60
49Conditionalvalue: 51
condition: 52
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operands: 56
52Operationoperator: 57
operands: 63
53Literal
54ExprTuple58, 59
55Literal
56ExprTuple59, 60
57Variable
58Variable
59Operationoperator: 61
operands: 63
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