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, ExprRange, ExprTuple, IndexedVar, K, Lambda, V, Variable, a, i, k
from proveit.core_expr_types import a_1_to_i
from proveit.linear_algebra import ScalarMult, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InClass
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(V, Conditional(Forall(instance_param_or_params = [i], instance_expr = Forall(instance_param_or_params = [k, a_1_to_i], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(k, IndexedVar(a, sub_expr1)), one, i)), ScalarMult(k, VecAdd(a_1_to_i))).with_wrapping_at(2), domains = [K, V]), domain = Natural), InClass(V, 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(V \mapsto \left\{\forall_{i \in \mathbb{N}}~\left[\forall_{k \in K,\left(a_{1} \in V\right), \left(a_{2} \in V\right), \ldots, \left(a_{i} \in V\right)}~\left(\begin{array}{c} \begin{array}{l} \left(\left(k \cdot a_{1}\right) +  \left(k \cdot a_{2}\right) +  \ldots +  \left(k \cdot a_{i}\right)\right) =  \\ \left(k \cdot \left(a_{1} +  a_{2} +  \ldots +  a_{i}\right)\right) \end{array} \end{array}\right)\right] \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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: 49
body: 3
2ExprTuple49
3Conditionalvalue: 4
condition: 5
4Operationoperator: 17
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple49, 10
9Lambdaparameter: 54
body: 12
10Operationoperator: 13
operand: 40
11ExprTuple54
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple40
15Operationoperator: 17
operand: 20
16Operationoperator: 45
operands: 19
17Literal
18ExprTuple20
19ExprTuple54, 21
20Lambdaparameters: 22
body: 23
21Literal
22ExprTuple55, 48
23Conditionalvalue: 24
condition: 25
24Operationoperator: 26
operands: 27
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30, 31
28Literal
29ExprTuple32, 33
30Operationoperator: 43
operands: 34
31Operationoperator: 50
operands: 35
32Operationoperator: 45
operands: 36
33ExprRangelambda_map: 37
start_index: 53
end_index: 54
34ExprTuple38
35ExprTuple55, 39
36ExprTuple55, 40
37Lambdaparameter: 59
body: 41
38ExprRangelambda_map: 42
start_index: 53
end_index: 54
39Operationoperator: 43
operands: 44
40Variable
41Operationoperator: 45
operands: 46
42Lambdaparameter: 59
body: 47
43Literal
44ExprTuple48
45Literal
46ExprTuple56, 49
47Operationoperator: 50
operands: 51
48ExprRangelambda_map: 52
start_index: 53
end_index: 54
49Variable
50Literal
51ExprTuple55, 56
52Lambdaparameter: 59
body: 56
53Literal
54Variable
55Variable
56IndexedVarvariable: 57
index: 59
57Variable
58ExprTuple59
59Variable