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 ExprRange, ExprTuple, IndexedVar, K, Lambda, V, Variable, a, n, v
from proveit.core_expr_types import a_1_to_n
from proveit.linear_algebra import ScalarMult, VecAdd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda(K, Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [v], instance_expr = Equals(ScalarMult(VecAdd(a_1_to_n), v), VecAdd(ExprRange(sub_expr1, ScalarMult(IndexedVar(a, sub_expr1), v), one, n))).with_wrapping_at(2), domain = V), domain = K), domain = Natural), domain = VecSpaces(K))))
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(K \mapsto \left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{n \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{n} \in K}~\left[\forall_{v \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} +  a_{2} +  \ldots +  a_{n}\right) \cdot v\right) =  \\ \left(\left(a_{1} \cdot v\right) +  \left(a_{2} \cdot v\right) +  \ldots +  \left(a_{n} \cdot v\right)\right) \end{array} \end{array}\right)\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
1Lambdaparameter: 47
body: 2
2Operationoperator: 27
operand: 4
3ExprTuple4
4Lambdaparameter: 46
body: 6
5ExprTuple46
6Conditionalvalue: 7
condition: 8
7Operationoperator: 27
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple46, 13
12Lambdaparameter: 59
body: 15
13Operationoperator: 16
operand: 47
14ExprTuple59
15Conditionalvalue: 18
condition: 19
16Literal
17ExprTuple47
18Operationoperator: 27
operand: 22
19Operationoperator: 42
operands: 21
20ExprTuple22
21ExprTuple59, 23
22Lambdaparameters: 53
body: 24
23Literal
24Conditionalvalue: 25
condition: 26
25Operationoperator: 27
operand: 31
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31
29Literal
30ExprTuple32
31Lambdaparameter: 63
body: 34
32ExprRangelambda_map: 35
start_index: 58
end_index: 59
33ExprTuple63
34Conditionalvalue: 36
condition: 37
35Lambdaparameter: 66
body: 38
36Operationoperator: 39
operands: 40
37Operationoperator: 42
operands: 41
38Operationoperator: 42
operands: 43
39Literal
40ExprTuple44, 45
41ExprTuple63, 46
42Literal
43ExprTuple62, 47
44Operationoperator: 60
operands: 48
45Operationoperator: 52
operands: 49
46Variable
47Variable
48ExprTuple50, 63
49ExprTuple51
50Operationoperator: 52
operands: 53
51ExprRangelambda_map: 54
start_index: 58
end_index: 59
52Literal
53ExprTuple55
54Lambdaparameter: 66
body: 56
55ExprRangelambda_map: 57
start_index: 58
end_index: 59
56Operationoperator: 60
operands: 61
57Lambdaparameter: 66
body: 62
58Literal
59Variable
60Literal
61ExprTuple62, 63
62IndexedVarvariable: 64
index: 66
63Variable
64Variable
65ExprTuple66
66Variable